mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +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/outfuncs.c,v 1.232 2004/01/31 05:09:40 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.233 2004/03/17 20:48:42 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@ -805,6 +805,15 @@ _outCaseWhen(StringInfo str, CaseWhen *node)
|
||||
WRITE_NODE_FIELD(result);
|
||||
}
|
||||
|
||||
static void
|
||||
_outCaseTestExpr(StringInfo str, CaseTestExpr *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("CASETESTEXPR");
|
||||
|
||||
WRITE_OID_FIELD(typeId);
|
||||
WRITE_INT_FIELD(typeMod);
|
||||
}
|
||||
|
||||
static void
|
||||
_outArrayExpr(StringInfo str, ArrayExpr *node)
|
||||
{
|
||||
@ -1701,6 +1710,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_CaseWhen:
|
||||
_outCaseWhen(str, obj);
|
||||
break;
|
||||
case T_CaseTestExpr:
|
||||
_outCaseTestExpr(str, obj);
|
||||
break;
|
||||
case T_ArrayExpr:
|
||||
_outArrayExpr(str, obj);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user