Remove a no-longer-needed kluge for degenerate aggregate cases,
and update some comments.
This commit is contained in:
parent
c528c42ec2
commit
5ce158c534
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
*
|
||||
* 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,
|
|||
static Datum
|
||||
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];
|
||||
return econtext->ecxt_aggvalues[aggref->aggno];
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* SQL aggregates. (Do not expect POSTQUEL semantics.) -- ay 2/95
|
||||
*
|
||||
* 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)
|
|||
* sfunc1 is never applied when the current tuple's aggregated_value
|
||||
* is NULL. sfunc2 is applied for each tuple if the aggref is marked
|
||||
* 'usenulls', otherwise it is only applied when aggregated_value is
|
||||
* not NULL. (usenulls is normally set only for the case of COUNT(*),
|
||||
* since according to the SQL92 standard that is the only aggregate
|
||||
* that considers nulls in its input. SQL92 requires COUNT(*) and
|
||||
* COUNT(field) to behave differently --- the latter doesn't count nulls
|
||||
* --- so we can't make this flag a column of pg_aggregate but must
|
||||
* set it according to usage. Ugh.)
|
||||
* not NULL. (usenulls was formerly used for COUNT(*), but is no longer
|
||||
* needed for that purpose; as of 10/1999 the support for usenulls is
|
||||
* dead code. I have not removed it because it seems like a potentially
|
||||
* useful feature for user-defined aggregates. We'd just need to add a
|
||||
* flag column to pg_aggregate and a parameter to CREATE AGGREGATE...)
|
||||
*
|
||||
* If the outer subplan is a Group node, ExecAgg returns as many tuples
|
||||
* as there are groups.
|
||||
|
@ -534,27 +533,14 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
|
|||
outerPlan = outerPlan(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);
|
||||
|
||||
/*
|
||||
* Initialize tuple type for both result and scan. This node does no
|
||||
* projection
|
||||
* Initialize result tuple type and projection info.
|
||||
*/
|
||||
ExecAssignResultTypeFromTL((Plan *) node, &aggstate->csstate.cstate);
|
||||
ExecAssignProjectionInfo((Plan *) node, &aggstate->csstate.cstate);
|
||||
|
|
Loading…
Reference in New Issue