diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-03-17 20:48:43 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-03-17 20:48:43 +0000 |
commit | 55f7c3300d164d370d28b127210223d078da524d (patch) | |
tree | e5c91b7d50eef3b40dd395e3ecce877bb6663636 /src/backend/nodes/copyfuncs.c | |
parent | 8c702ea7ace30026dfff4f2e514027cd4d6d7579 (diff) | |
download | postgresql-55f7c3300d164d370d28b127210223d078da524d.tar.gz postgresql-55f7c3300d164d370d28b127210223d078da524d.zip |
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.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index c1c4ddfed8b..c7d6193280e 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.278 2004/03/11 01:47:35 ishii Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.279 2004/03/17 20:48:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -969,6 +969,20 @@ _copyCaseWhen(CaseWhen *from) } /* + * _copyCaseTestExpr + */ +static CaseTestExpr * +_copyCaseTestExpr(CaseTestExpr *from) +{ + CaseTestExpr *newnode = makeNode(CaseTestExpr); + + COPY_SCALAR_FIELD(typeId); + COPY_SCALAR_FIELD(typeMod); + + return newnode; +} + +/* * _copyArrayExpr */ static ArrayExpr * @@ -2643,6 +2657,9 @@ copyObject(void *from) case T_CaseWhen: retval = _copyCaseWhen(from); break; + case T_CaseTestExpr: + retval = _copyCaseTestExpr(from); + break; case T_ArrayExpr: retval = _copyArrayExpr(from); break; |