Skip to content

Commit cf402ba

Browse files
committed
Tighten up sanity checks for parallel aggregate in execQual.c.
David Rowley
1 parent b33dc77 commit cf402ba

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/backend/executor/execQual.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4510,28 +4510,35 @@ ExecInitExpr(Expr *node, PlanState *parent)
45104510
case T_Aggref:
45114511
{
45124512
AggrefExprState *astate = makeNode(AggrefExprState);
4513+
AggState *aggstate = (AggState *) parent;
4514+
Aggref *aggref = (Aggref *) node;
45134515

45144516
astate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalAggref;
4515-
if (parent && IsA(parent, AggState))
4517+
if (!aggstate || !IsA(aggstate, AggState))
45164518
{
4517-
AggState *aggstate = (AggState *) parent;
4518-
Aggref *aggref = (Aggref *) node;
4519-
4520-
if (aggstate->finalizeAggs &&
4521-
aggref->aggoutputtype != aggref->aggtype)
4522-
{
4523-
/* planner messed up */
4524-
elog(ERROR, "Aggref aggoutputtype must match aggtype");
4525-
}
4526-
4527-
aggstate->aggs = lcons(astate, aggstate->aggs);
4528-
aggstate->numaggs++;
4519+
/* planner messed up */
4520+
elog(ERROR, "Aggref found in non-Agg plan node");
45294521
}
4530-
else
4522+
if (aggref->aggpartial == aggstate->finalizeAggs)
45314523
{
45324524
/* planner messed up */
4533-
elog(ERROR, "Aggref found in non-Agg plan node");
4525+
if (aggref->aggpartial)
4526+
elog(ERROR, "partial Aggref found in finalize agg plan node");
4527+
else
4528+
elog(ERROR, "non-partial Aggref found in non-finalize agg plan node");
45344529
}
4530+
4531+
if (aggref->aggcombine != aggstate->combineStates)
4532+
{
4533+
/* planner messed up */
4534+
if (aggref->aggcombine)
4535+
elog(ERROR, "combine Aggref found in non-combine agg plan node");
4536+
else
4537+
elog(ERROR, "non-combine Aggref found in combine agg plan node");
4538+
}
4539+
4540+
aggstate->aggs = lcons(astate, aggstate->aggs);
4541+
aggstate->numaggs++;
45354542
state = (ExprState *) astate;
45364543
}
45374544
break;

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