Skip to content

Commit 5ce158c

Browse files
committed
Remove a no-longer-needed kluge for degenerate aggregate cases,
and update some comments.
1 parent c528c42 commit 5ce158c

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

src/backend/executor/execQual.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.62 1999/09/26 21:21:09 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.63 1999/10/08 03:49:55 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -209,6 +209,9 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
209209
static Datum
210210
ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull)
211211
{
212+
if (econtext->ecxt_aggvalues == NULL) /* safety check */
213+
elog(ERROR, "ExecEvalAggref: no aggregates in this expression context");
214+
212215
*isNull = econtext->ecxt_aggnulls[aggref->aggno];
213216
return econtext->ecxt_aggvalues[aggref->aggno];
214217
}

src/backend/executor/nodeAgg.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* SQL aggregates. (Do not expect POSTQUEL semantics.) -- ay 2/95
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.56 1999/09/28 02:03:19 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.57 1999/10/08 03:49:55 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -136,12 +136,11 @@ copyDatum(Datum val, int typLen, bool typByVal)
136136
* sfunc1 is never applied when the current tuple's aggregated_value
137137
* is NULL. sfunc2 is applied for each tuple if the aggref is marked
138138
* 'usenulls', otherwise it is only applied when aggregated_value is
139-
* not NULL. (usenulls is normally set only for the case of COUNT(*),
140-
* since according to the SQL92 standard that is the only aggregate
141-
* that considers nulls in its input. SQL92 requires COUNT(*) and
142-
* COUNT(field) to behave differently --- the latter doesn't count nulls
143-
* --- so we can't make this flag a column of pg_aggregate but must
144-
* set it according to usage. Ugh.)
139+
* not NULL. (usenulls was formerly used for COUNT(*), but is no longer
140+
* needed for that purpose; as of 10/1999 the support for usenulls is
141+
* dead code. I have not removed it because it seems like a potentially
142+
* useful feature for user-defined aggregates. We'd just need to add a
143+
* flag column to pg_aggregate and a parameter to CREATE AGGREGATE...)
145144
*
146145
* If the outer subplan is a Group node, ExecAgg returns as many tuples
147146
* as there are groups.
@@ -534,27 +533,14 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
534533
outerPlan = outerPlan(node);
535534
ExecInitNode(outerPlan, estate, (Plan *) node);
536535

537-
/*
538-
* Result runs in its own context, but make it use our aggregates fix
539-
* for 'select sum(2+2)'
540-
*/
541-
if (IsA(outerPlan, Result))
542-
{
543-
((Result *) outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_aggvalues =
544-
econtext->ecxt_aggvalues;
545-
((Result *) outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_aggnulls =
546-
econtext->ecxt_aggnulls;
547-
}
548-
549536
/* ----------------
550-
* initialize tuple type.
537+
* initialize source tuple type.
551538
* ----------------
552539
*/
553540
ExecAssignScanTypeFromOuterPlan((Plan *) node, &aggstate->csstate);
554541

555542
/*
556-
* Initialize tuple type for both result and scan. This node does no
557-
* projection
543+
* Initialize result tuple type and projection info.
558544
*/
559545
ExecAssignResultTypeFromTL((Plan *) node, &aggstate->csstate.cstate);
560546
ExecAssignProjectionInfo((Plan *) node, &aggstate->csstate.cstate);

0 commit comments

Comments
 (0)