diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2020-11-24 10:45:00 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2020-11-24 10:45:00 +0200 |
commit | 0a2bc5d61e713e3fe72438f020eea5fcc90b0f0b (patch) | |
tree | 8f630f828fa6bbfb5984f037118211cd68d8a50e /src/backend/executor/execExpr.c | |
parent | e522024bd8dd28a0f13dcccfd39170698f45c939 (diff) | |
download | postgresql-0a2bc5d61e713e3fe72438f020eea5fcc90b0f0b.tar.gz postgresql-0a2bc5d61e713e3fe72438f020eea5fcc90b0f0b.zip |
Move per-agg and per-trans duplicate finding to the planner.
This has the advantage that the cost estimates for aggregates can count
the number of calls to transition and final functions correctly.
Bump catalog version, because views can contain Aggrefs.
Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/b2e3536b-1dbc-8303-c97e-89cb0b4a9a48%40iki.fi
Diffstat (limited to 'src/backend/executor/execExpr.c')
-rw-r--r-- | src/backend/executor/execExpr.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c index d76836c09b1..79b325c7cfb 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -99,8 +99,7 @@ static void ExecBuildAggTransCall(ExprState *state, AggState *aggstate, * the same as the per-query context of the associated ExprContext. * * Any Aggref, WindowFunc, or SubPlan nodes found in the tree are added to - * the lists of such nodes held by the parent PlanState (or more accurately, - * the AggrefExprState etc. nodes created for them are added). + * the lists of such nodes held by the parent PlanState. * * Note: there is no ExecEndExpr function; we assume that any resource * cleanup needed will be handled by just releasing the memory context @@ -779,18 +778,15 @@ ExecInitExprRec(Expr *node, ExprState *state, case T_Aggref: { Aggref *aggref = (Aggref *) node; - AggrefExprState *astate = makeNode(AggrefExprState); scratch.opcode = EEOP_AGGREF; - scratch.d.aggref.astate = astate; - astate->aggref = aggref; + scratch.d.aggref.aggno = aggref->aggno; if (state->parent && IsA(state->parent, AggState)) { AggState *aggstate = (AggState *) state->parent; - aggstate->aggs = lappend(aggstate->aggs, astate); - aggstate->numaggs++; + aggstate->aggs = lappend(aggstate->aggs, aggref); } else { |