diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-10 20:57:45 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-10 20:57:45 +0000 |
commit | 88b229d9076748e09124c3ffae2987cf4ecd9ca3 (patch) | |
tree | e34b3f9325d115b2c603f5e530377a727dda2ce2 /src | |
parent | c8814f4840e0e5e69286b10a5ffbf33be2754ec9 (diff) | |
download | postgresql-88b229d9076748e09124c3ffae2987cf4ecd9ca3.tar.gz postgresql-88b229d9076748e09124c3ffae2987cf4ecd9ca3.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 c6057687b8f..a43256cc1f2 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.186.4.2 2005/02/02 21:49:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.186.4.3 2005/04/10 20:57:45 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -1771,6 +1771,10 @@ eval_const_expressions_mutator(Node *node, newargs = lappend(newargs, e); } + /* If all the arguments were constant null, the result is just null */ + if (newargs == NIL) + return (Node *) makeNullConst(coalesceexpr->coalescetype); + newcoalesce = makeNode(CoalesceExpr); newcoalesce->coalescetype = coalesceexpr->coalescetype; newcoalesce->args = newargs; |