Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf402ba

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

File tree

Expand file treeCollapse file tree

1 file changed

+22
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-15
lines changed

‎src/backend/executor/execQual.c

Copy file name to clipboardExpand all lines: src/backend/executor/execQual.c
+22-15Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.