mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +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:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.113 2004/03/17 01:02:24 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.114 2004/03/17 20:48:42 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -113,6 +113,10 @@ typedef struct ExprContext
|
||||
Datum *ecxt_aggvalues; /* precomputed values for Aggref nodes */
|
||||
bool *ecxt_aggnulls; /* null flags for Aggref nodes */
|
||||
|
||||
/* Value to substitute for CaseTestExpr nodes in expression */
|
||||
Datum caseValue_datum;
|
||||
bool caseValue_isNull;
|
||||
|
||||
/* Value to substitute for CoerceToDomainValue nodes in expression */
|
||||
Datum domainValue_datum;
|
||||
bool domainValue_isNull;
|
||||
@ -566,6 +570,7 @@ typedef struct SubPlanState
|
||||
typedef struct CaseExprState
|
||||
{
|
||||
ExprState xprstate;
|
||||
ExprState *arg; /* implicit equality comparison argument */
|
||||
List *args; /* the arguments (list of WHEN clauses) */
|
||||
ExprState *defresult; /* the default result (ELSE clause) */
|
||||
} CaseExprState;
|
||||
|
Reference in New Issue
Block a user