summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2003-02-16 02:30:39 +0000
committerTom Lane2003-02-16 02:30:39 +0000
commit51972a9d5d068dd34b24ff4923981ffb90e5cc2d (patch)
treec68fddbb3eaafbd332e84afbafe3c171f6372d4e /src/include
parentde25638d2fbe9e56ecfc60a7dda8a0c56028317a (diff)
COALESCE() and NULLIF() are now first-class expressions, not macros
that turn into CASE expressions. They evaluate their arguments at most once. Patch by Kris Jurka, review and (very light) editorializing by me.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/nodes/execnodes.h17
-rw-r--r--src/include/nodes/nodes.h5
-rw-r--r--src/include/nodes/parsenodes.h3
-rw-r--r--src/include/nodes/primnodes.h20
5 files changed, 41 insertions, 8 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 230f1e277ac..03e452121f0 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.176 2003/02/13 05:24:02 momjian Exp $
+ * $Id: catversion.h,v 1.177 2003/02/16 02:30:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200302131
+#define CATALOG_VERSION_NO 200302151
#endif
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 8d2b1305984..591870be515 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execnodes.h,v 1.94 2003/02/09 00:30:39 tgl Exp $
+ * $Id: execnodes.h,v 1.95 2003/02/16 02:30:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -441,8 +441,9 @@ typedef struct ArrayRefExprState
/* ----------------
* FuncExprState node
*
- * Although named for FuncExpr, this is also used for OpExpr and DistinctExpr
- * nodes; be careful to check what xprstate.expr is actually pointing at!
+ * Although named for FuncExpr, this is also used for OpExpr, DistinctExpr,
+ * and NullIf nodes; be careful to check what xprstate.expr is actually
+ * pointing at!
* ----------------
*/
typedef struct FuncExprState
@@ -540,6 +541,16 @@ typedef struct CaseWhenState
} CaseWhenState;
/* ----------------
+ * CoalesceExprState node
+ * ----------------
+ */
+typedef struct CoalesceExprState
+{
+ ExprState xprstate;
+ List *args; /* the arguments */
+} CoalesceExprState;
+
+/* ----------------
* CoerceToDomainState node
* ----------------
*/
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index a218790194e..356f4b60fa3 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.136 2003/02/03 21:15:44 tgl Exp $
+ * $Id: nodes.h,v 1.137 2003/02/16 02:30:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -112,6 +112,8 @@ typedef enum NodeTag
T_RelabelType,
T_CaseExpr,
T_CaseWhen,
+ T_CoalesceExpr,
+ T_NullIfExpr,
T_NullTest,
T_BooleanTest,
T_CoerceToDomain,
@@ -136,6 +138,7 @@ typedef enum NodeTag
T_SubPlanState,
T_CaseExprState,
T_CaseWhenState,
+ T_CoalesceExprState,
T_CoerceToDomainState,
T_DomainConstraintState,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 9474bc6490b..381c11c3893 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.230 2003/02/13 05:20:03 momjian Exp $
+ * $Id: parsenodes.h,v 1.231 2003/02/16 02:30:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,6 +174,7 @@ typedef enum A_Expr_Kind
AEXPR_OR,
AEXPR_NOT,
AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
+ AEXPR_NULLIF, /* NULLIF - name must be "=" */
AEXPR_OF /* IS (not) OF - name must be "=" or "!=" */
} A_Expr_Kind;
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index be917c4f260..b8a358d6147 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: primnodes.h,v 1.79 2003/02/09 00:30:40 tgl Exp $
+ * $Id: primnodes.h,v 1.80 2003/02/16 02:30:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -537,6 +537,24 @@ typedef struct CaseWhen
Expr *result; /* substitution result */
} CaseWhen;
+/*
+ * CoalesceExpr - a COALESCE expression
+ */
+typedef struct CoalesceExpr
+{
+ Expr xpr;
+ Oid coalescetype; /* type of expression result */
+ List *args; /* the arguments */
+} CoalesceExpr;
+
+/*
+ * NullIfExpr - a NULLIF expression
+ *
+ * Like DistinctExpr, this is represented the same as an OpExpr referencing
+ * the "=" operator for x and y.
+ */
+typedef OpExpr NullIfExpr;
+
/* ----------------
* NullTest
*