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.
This commit is contained in:
parent
6985592967
commit
acde8b3cab
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.193 2005/04/06 16:34:06 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.194 2005/04/10 20:57:32 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
|
@ -1788,6 +1788,10 @@ eval_const_expressions_mutator(Node *node,
|
||||||
newargs = lappend(newargs, e);
|
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 = makeNode(CoalesceExpr);
|
||||||
newcoalesce->coalescetype = coalesceexpr->coalescetype;
|
newcoalesce->coalescetype = coalesceexpr->coalescetype;
|
||||||
newcoalesce->args = newargs;
|
newcoalesce->args = newargs;
|
||||||
|
|
Loading…
Reference in New Issue