Commit 5ce158c5 authored by Tom Lane's avatar Tom Lane

Remove a no-longer-needed kluge for degenerate aggregate cases,

and update some comments.
parent c528c42e
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.62 1999/09/26 21:21:09 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.63 1999/10/08 03:49:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -209,6 +209,9 @@ ExecEvalArrayRef(ArrayRef *arrayRef, ...@@ -209,6 +209,9 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
static Datum static Datum
ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull) ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull)
{ {
if (econtext->ecxt_aggvalues == NULL) /* safety check */
elog(ERROR, "ExecEvalAggref: no aggregates in this expression context");
*isNull = econtext->ecxt_aggnulls[aggref->aggno]; *isNull = econtext->ecxt_aggnulls[aggref->aggno];
return econtext->ecxt_aggvalues[aggref->aggno]; return econtext->ecxt_aggvalues[aggref->aggno];
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* SQL aggregates. (Do not expect POSTQUEL semantics.) -- ay 2/95 * SQL aggregates. (Do not expect POSTQUEL semantics.) -- ay 2/95
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.56 1999/09/28 02:03:19 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.57 1999/10/08 03:49:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -136,12 +136,11 @@ copyDatum(Datum val, int typLen, bool typByVal) ...@@ -136,12 +136,11 @@ copyDatum(Datum val, int typLen, bool typByVal)
* sfunc1 is never applied when the current tuple's aggregated_value * sfunc1 is never applied when the current tuple's aggregated_value
* is NULL. sfunc2 is applied for each tuple if the aggref is marked * is NULL. sfunc2 is applied for each tuple if the aggref is marked
* 'usenulls', otherwise it is only applied when aggregated_value is * 'usenulls', otherwise it is only applied when aggregated_value is
* not NULL. (usenulls is normally set only for the case of COUNT(*), * not NULL. (usenulls was formerly used for COUNT(*), but is no longer
* since according to the SQL92 standard that is the only aggregate * needed for that purpose; as of 10/1999 the support for usenulls is
* that considers nulls in its input. SQL92 requires COUNT(*) and * dead code. I have not removed it because it seems like a potentially
* COUNT(field) to behave differently --- the latter doesn't count nulls * useful feature for user-defined aggregates. We'd just need to add a
* --- so we can't make this flag a column of pg_aggregate but must * flag column to pg_aggregate and a parameter to CREATE AGGREGATE...)
* set it according to usage. Ugh.)
* *
* If the outer subplan is a Group node, ExecAgg returns as many tuples * If the outer subplan is a Group node, ExecAgg returns as many tuples
* as there are groups. * as there are groups.
...@@ -534,27 +533,14 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) ...@@ -534,27 +533,14 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
outerPlan = outerPlan(node); outerPlan = outerPlan(node);
ExecInitNode(outerPlan, estate, (Plan *) node); ExecInitNode(outerPlan, estate, (Plan *) node);
/*
* Result runs in its own context, but make it use our aggregates fix
* for 'select sum(2+2)'
*/
if (IsA(outerPlan, Result))
{
((Result *) outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_aggvalues =
econtext->ecxt_aggvalues;
((Result *) outerPlan)->resstate->cstate.cs_ProjInfo->pi_exprContext->ecxt_aggnulls =
econtext->ecxt_aggnulls;
}
/* ---------------- /* ----------------
* initialize tuple type. * initialize source tuple type.
* ---------------- * ----------------
*/ */
ExecAssignScanTypeFromOuterPlan((Plan *) node, &aggstate->csstate); ExecAssignScanTypeFromOuterPlan((Plan *) node, &aggstate->csstate);
/* /*
* Initialize tuple type for both result and scan. This node does no * Initialize result tuple type and projection info.
* projection
*/ */
ExecAssignResultTypeFromTL((Plan *) node, &aggstate->csstate.cstate); ExecAssignResultTypeFromTL((Plan *) node, &aggstate->csstate.cstate);
ExecAssignProjectionInfo((Plan *) node, &aggstate->csstate.cstate); ExecAssignProjectionInfo((Plan *) node, &aggstate->csstate.cstate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment