diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-02-16 02:30:39 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-02-16 02:30:39 +0000 |
| commit | 51972a9d5d068dd34b24ff4923981ffb90e5cc2d (patch) | |
| tree | c68fddbb3eaafbd332e84afbafe3c171f6372d4e /src/include/nodes | |
| parent | de25638d2fbe9e56ecfc60a7dda8a0c56028317a (diff) | |
| download | postgresql-51972a9d5d068dd34b24ff4923981ffb90e5cc2d.tar.gz | |
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/nodes')
| -rw-r--r-- | src/include/nodes/execnodes.h | 17 | ||||
| -rw-r--r-- | src/include/nodes/nodes.h | 5 | ||||
| -rw-r--r-- | src/include/nodes/parsenodes.h | 3 | ||||
| -rw-r--r-- | src/include/nodes/primnodes.h | 20 |
4 files changed, 39 insertions, 6 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 8d2b130598..591870be51 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 a218790194..356f4b60fa 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 9474bc6490..381c11c389 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 be917c4f26..b8a358d614 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 * |
