Don't call simplify_aggref with a NULL PlannerInfo

42473b3b3 added prosupport infrastructure to allow simplification of
Aggrefs during constant-folding.  In some cases the context->root that's
given to eval_const_expressions_mutator() can be NULL.  42473b3b3 failed
to take that into account, which could result in a crash.

To fix, add a check and only call simplify_aggref() when the PlannerInfo
is set.

Author: David Rowley <[email protected]>
Reported-by: Birler, Altan <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5424f4da9031ac4681ab002d20f021232070c96a

Modified Files
--------------
src/backend/optimizer/util/clauses.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Reply via email to