aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeAgg.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-12-13 19:46:01 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-12-13 19:46:01 +0000
commit3a4f7dde16ad81b2319b9a4924a6023710a2fefd (patch)
tree248cf66fd94d40072b5ba8bb8e5437a6ea8399e5 /src/backend/executor/nodeAgg.c
parent77b7a740f95250af7d78f69e9c906c3e53f32e7b (diff)
downloadpostgresql-3a4f7dde16ad81b2319b9a4924a6023710a2fefd.tar.gz
postgresql-3a4f7dde16ad81b2319b9a4924a6023710a2fefd.zip
Phase 3 of read-only-plans project: ExecInitExpr now builds expression
execution state trees, and ExecEvalExpr takes an expression state tree not an expression plan tree. The plan tree is now read-only as far as the executor is concerned. Next step is to begin actually exploiting this property.
Diffstat (limited to 'src/backend/executor/nodeAgg.c')
-rw-r--r--src/backend/executor/nodeAgg.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 73e4a8044ef..e6ba3887630 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.99 2002/12/12 15:49:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.100 2002/12/13 19:45:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -82,7 +82,8 @@ typedef struct AggStatePerAggData
* thereafter:
*/
- /* Link to Aggref node this working state is for */
+ /* Links to Aggref expr and state nodes this working state is for */
+ AggrefExprState *aggrefstate;
Aggref *aggref;
/* Oids of transfer functions */
@@ -237,7 +238,7 @@ initialize_aggregates(AggState *aggstate,
{
AggStatePerAgg peraggstate = &peragg[aggno];
AggStatePerGroup pergroupstate = &pergroup[aggno];
- Aggref *aggref = peraggstate->aggref;
+ Aggref *aggref = peraggstate->aggref;
/*
* Start a fresh sort operation for each DISTINCT aggregate.
@@ -411,11 +412,12 @@ advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup)
{
AggStatePerAgg peraggstate = &aggstate->peragg[aggno];
AggStatePerGroup pergroupstate = &pergroup[aggno];
+ AggrefExprState *aggrefstate = peraggstate->aggrefstate;
Aggref *aggref = peraggstate->aggref;
Datum newVal;
bool isNull;
- newVal = ExecEvalExprSwitchContext((Node *) aggref->target, econtext,
+ newVal = ExecEvalExprSwitchContext(aggrefstate->target, econtext,
&isNull, NULL);
if (aggref->aggdistinct)
@@ -1145,10 +1147,10 @@ ExecInitAgg(Agg *node, EState *estate)
* particular order.
*/
aggstate->ss.ps.targetlist = (List *)
- ExecInitExpr((Node *) node->plan.targetlist,
+ ExecInitExpr((Expr *) node->plan.targetlist,
(PlanState *) aggstate);
aggstate->ss.ps.qual = (List *)
- ExecInitExpr((Node *) node->plan.qual,
+ ExecInitExpr((Expr *) node->plan.qual,
(PlanState *) aggstate);
/*
@@ -1227,7 +1229,8 @@ ExecInitAgg(Agg *node, EState *estate)
aggno = -1;
foreach(alist, aggstate->aggs)
{
- Aggref *aggref = (Aggref *) lfirst(alist);
+ AggrefExprState *aggrefstate = (AggrefExprState *) lfirst(alist);
+ Aggref *aggref = (Aggref *) aggrefstate->xprstate.expr;
AggStatePerAgg peraggstate = &peragg[++aggno];
HeapTuple aggTuple;
Form_pg_aggregate aggform;
@@ -1236,10 +1239,11 @@ ExecInitAgg(Agg *node, EState *estate)
finalfn_oid;
Datum textInitVal;
- /* Mark Aggref node with its associated index in the result array */
- aggref->aggno = aggno;
+ /* Mark Aggref state node with assigned index in the result array */
+ aggrefstate->aggno = aggno;
/* Fill in the peraggstate data */
+ peraggstate->aggrefstate = aggrefstate;
peraggstate->aggref = aggref;
aggTuple = SearchSysCache(AGGFNOID,