Tighten up sanity checks for parallel aggregate in execQual.c.
David Rowley
This commit is contained in:
parent
b33dc77665
commit
cf402ba734
@ -4510,28 +4510,35 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
|||||||
case T_Aggref:
|
case T_Aggref:
|
||||||
{
|
{
|
||||||
AggrefExprState *astate = makeNode(AggrefExprState);
|
AggrefExprState *astate = makeNode(AggrefExprState);
|
||||||
|
|
||||||
astate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalAggref;
|
|
||||||
if (parent && IsA(parent, AggState))
|
|
||||||
{
|
|
||||||
AggState *aggstate = (AggState *) parent;
|
AggState *aggstate = (AggState *) parent;
|
||||||
Aggref *aggref = (Aggref *) node;
|
Aggref *aggref = (Aggref *) node;
|
||||||
|
|
||||||
if (aggstate->finalizeAggs &&
|
astate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalAggref;
|
||||||
aggref->aggoutputtype != aggref->aggtype)
|
if (!aggstate || !IsA(aggstate, AggState))
|
||||||
{
|
|
||||||
/* planner messed up */
|
|
||||||
elog(ERROR, "Aggref aggoutputtype must match aggtype");
|
|
||||||
}
|
|
||||||
|
|
||||||
aggstate->aggs = lcons(astate, aggstate->aggs);
|
|
||||||
aggstate->numaggs++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* planner messed up */
|
/* planner messed up */
|
||||||
elog(ERROR, "Aggref found in non-Agg plan node");
|
elog(ERROR, "Aggref found in non-Agg plan node");
|
||||||
}
|
}
|
||||||
|
if (aggref->aggpartial == aggstate->finalizeAggs)
|
||||||
|
{
|
||||||
|
/* planner messed up */
|
||||||
|
if (aggref->aggpartial)
|
||||||
|
elog(ERROR, "partial Aggref found in finalize agg plan node");
|
||||||
|
else
|
||||||
|
elog(ERROR, "non-partial Aggref found in non-finalize agg plan node");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aggref->aggcombine != aggstate->combineStates)
|
||||||
|
{
|
||||||
|
/* planner messed up */
|
||||||
|
if (aggref->aggcombine)
|
||||||
|
elog(ERROR, "combine Aggref found in non-combine agg plan node");
|
||||||
|
else
|
||||||
|
elog(ERROR, "non-combine Aggref found in combine agg plan node");
|
||||||
|
}
|
||||||
|
|
||||||
|
aggstate->aggs = lcons(astate, aggstate->aggs);
|
||||||
|
aggstate->numaggs++;
|
||||||
state = (ExprState *) astate;
|
state = (ExprState *) astate;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user