Don't call simplify_aggref with a NULL PlannerInfo

David Rowley <drowley@postgresql.org>

Commit: 5424f4da9031ac4681ab002d20f021232070c96a
Author: David Rowley <drowley@postgresql.org>
Date: 2025-11-29T23:55:34Z
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 <dgrowleyml@gmail.com>
Reported-by: Birler, Altan <altan.birler@tum.de>
Discussion: https://postgr.es/m/132d4da23b844d5ab9e352d34096eab5@tum.de

Files

PathChange+/−
src/backend/optimizer/util/clauses.c modified +3 −1

Discussion