Skip to content

Commit 5424f4d

Browse files
committed
Don't call simplify_aggref with a NULL PlannerInfo
42473b3 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. 42473b3 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
1 parent c902bd5 commit 5424f4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2638,7 +2638,9 @@ eval_const_expressions_mutator(Node *node,
26382638
}
26392639
case T_Aggref:
26402640
node = ece_generic_processing(node);
2641-
return simplify_aggref((Aggref *) node, context);
2641+
if (context->root != NULL)
2642+
return simplify_aggref((Aggref *) node, context);
2643+
return node;
26422644
case T_OpExpr:
26432645
{
26442646
OpExpr *expr = (OpExpr *) node;

0 commit comments

Comments
 (0)