Skip to content

Commit acde8b3

Browse files
committed
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.
1 parent 6985592 commit acde8b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.193 2005/04/06 16:34:06 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.194 2005/04/10 20:57:32 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHOR DATE MAJOR EVENT
@@ -1788,6 +1788,10 @@ eval_const_expressions_mutator(Node *node,
17881788
newargs = lappend(newargs, e);
17891789
}
17901790

1791+
/* If all the arguments were constant null, the result is just null */
1792+
if (newargs == NIL)
1793+
return (Node *) makeNullConst(coalesceexpr->coalescetype);
1794+
17911795
newcoalesce = makeNode(CoalesceExpr);
17921796
newcoalesce->coalescetype = coalesceexpr->coalescetype;
17931797
newcoalesce->args = newargs;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy