mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Reimplement CASE val WHEN compval1 THEN ... WHEN compval2 THEN ... END
so that the 'val' is computed only once, per recent discussion. The speedup is not much when 'val' is just a simple variable, but could be significant for larger expressions. More importantly this avoids issues with multiple evaluations of a volatile 'val', and it allows the CASE expression to be reverse-listed in its original form by ruleutils.c.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.165 2004/01/14 23:01:55 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.166 2004/03/17 20:48:42 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Path and Plan nodes do not have any readfuncs support, because we
|
||||
@ -648,6 +648,20 @@ _readCaseWhen(void)
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readCaseTestExpr
|
||||
*/
|
||||
static CaseTestExpr *
|
||||
_readCaseTestExpr(void)
|
||||
{
|
||||
READ_LOCALS(CaseTestExpr);
|
||||
|
||||
READ_OID_FIELD(typeId);
|
||||
READ_INT_FIELD(typeMod);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readArrayExpr
|
||||
*/
|
||||
@ -1010,6 +1024,8 @@ parseNodeString(void)
|
||||
return_value = _readCaseExpr();
|
||||
else if (MATCH("WHEN", 4))
|
||||
return_value = _readCaseWhen();
|
||||
else if (MATCH("CASETESTEXPR", 12))
|
||||
return_value = _readCaseTestExpr();
|
||||
else if (MATCH("ARRAY", 5))
|
||||
return_value = _readArrayExpr();
|
||||
else if (MATCH("COALESCE", 8))
|
||||
|
Reference in New Issue
Block a user