diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-10 20:58:03 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-10 20:58:03 +0000 |
commit | 29028762a96741647681495fc16ede97d743107c (patch) | |
tree | 340bd709fdcc1b7a423d60345e508153ae20e06e /src | |
parent | 5c5c797cb29c2662362a05a49f78dbe9276cc5f1 (diff) | |
download | postgresql-29028762a96741647681495fc16ede97d743107c.tar.gz postgresql-29028762a96741647681495fc16ede97d743107c.zip |
Make constant-folding produce sane output for COALESCE(NULL,NULL),
that is a plain NULL and not a COALESCE with no inputs. Fixes crash
reported by Michael Williamson.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/util/clauses.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index d8809a5252d..ae0c387e69a 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154.2.2 2004/01/28 00:05:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154.2.3 2005/04/10 20:58:03 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -1553,6 +1553,10 @@ eval_const_expressions_mutator(Node *node, List *active_fns) FastAppend(&newargs, e); } + /* If all the arguments were constant null, the result is just null */ + if (FastListValue(&newargs) == NIL) + return (Node *) makeNullConst(coalesceexpr->coalescetype); + newcoalesce = makeNode(CoalesceExpr); newcoalesce->coalescetype = coalesceexpr->coalescetype; newcoalesce->args = FastListValue(&newargs); |