mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
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.
This commit is contained in:
@ -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
|
||||
@ -606,6 +606,47 @@ _readCaseWhen(void)
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _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
|
||||
*/
|
||||
@ -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))
|
||||
|
Reference in New Issue
Block a user