mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +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:
@@ -18,7 +18,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.217 2004/03/14 23:41:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.218 2004/03/17 20:48:42 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -403,6 +403,15 @@ _equalCaseWhen(CaseWhen *a, CaseWhen *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalCaseTestExpr(CaseTestExpr *a, CaseTestExpr *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(typeId);
|
||||
COMPARE_SCALAR_FIELD(typeMod);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalArrayExpr(ArrayExpr *a, ArrayExpr *b)
|
||||
{
|
||||
@@ -1724,6 +1733,9 @@ equal(void *a, void *b)
|
||||
case T_CaseWhen:
|
||||
retval = _equalCaseWhen(a, b);
|
||||
break;
|
||||
case T_CaseTestExpr:
|
||||
retval = _equalCaseTestExpr(a, b);
|
||||
break;
|
||||
case T_ArrayExpr:
|
||||
retval = _equalArrayExpr(a, b);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user