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/backend/nodes/readfuncs.c | |
parent | de25638d2fbe9e56ecfc60a7dda8a0c56028317a (diff) | |
download | postgresql-51972a9d5d068dd34b24ff4923981ffb90e5cc2d.tar.gz postgresql-51972a9d5d068dd34b24ff4923981ffb90e5cc2d.zip |
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/backend/nodes/readfuncs.c')
-rw-r--r-- | src/backend/nodes/readfuncs.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index f37856728b1..410d092c916 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.148 2003/02/09 06:56:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.149 2003/02/16 02:30:37 tgl Exp $ * * NOTES * Path and Plan nodes do not have any readfuncs support, because we @@ -607,6 +607,47 @@ _readCaseWhen(void) } /* + * _readCoalesceExpr + */ +static CoalesceExpr * +_readCoalesceExpr(void) +{ + READ_LOCALS(CoalesceExpr); + + READ_OID_FIELD(coalescetype); + READ_NODE_FIELD(args); + + READ_DONE(); +} + +/* + * _readNullIfExpr + */ +static NullIfExpr * +_readNullIfExpr(void) +{ + READ_LOCALS(NullIfExpr); + + READ_OID_FIELD(opno); + READ_OID_FIELD(opfuncid); + /* + * The opfuncid is stored in the textual format primarily for debugging + * and documentation reasons. We want to always read it as zero to force + * it to be re-looked-up in the pg_operator entry. This ensures that + * stored rules don't have hidden dependencies on operators' functions. + * (We don't currently support an ALTER OPERATOR command, but might + * someday.) + */ + local_node->opfuncid = InvalidOid; + + READ_OID_FIELD(opresulttype); + READ_BOOL_FIELD(opretset); + READ_NODE_FIELD(args); + + READ_DONE(); +} + +/* * _readNullTest */ static NullTest * @@ -895,6 +936,10 @@ parseNodeString(void) return_value = _readCaseExpr(); else if (MATCH("WHEN", 4)) return_value = _readCaseWhen(); + else if (MATCH("COALESCE", 8)) + return_value = _readCoalesceExpr(); + else if (MATCH("NULLIFEXPR", 10)) + return_value = _readNullIfExpr(); else if (MATCH("NULLTEST", 8)) return_value = _readNullTest(); else if (MATCH("BOOLEANTEST", 11)) |