*/
bool aggshared;
- /*
- * Nominal number of arguments for aggregate function. For plain aggs,
- * this excludes any ORDER BY expressions. For ordered-set aggs, this
- * counts both the direct and aggregated (ORDER BY) arguments.
- */
- int numArguments;
-
/*
* Number of aggregated input columns. This includes ORDER BY expressions
* in both the plain-agg and ordered-set cases. Ordered-set direct args
/* Oid of state value's datatype */
Oid aggtranstype;
- /* ExprStates for any direct-argument expressions */
- List *aggdirectargs;
-
/*
* fmgr lookup data for transition function or combine function. Note in
* particular that the fn_strict flag is kept here.
*/
int numFinalArgs;
+ /* ExprStates for any direct-argument expressions */
+ List *aggdirectargs;
+
/*
* We need the len and byval info for the agg's result data type in order
* to know how to copy/delete values.
* for the transition state value.
*/
i = 1;
- foreach(lc, pertrans->aggdirectargs)
+ foreach(lc, peragg->aggdirectargs)
{
ExprState *expr = (ExprState *) lfirst(lc);
else
peragg->numFinalArgs = numDirectArgs + 1;
+ /* Initialize any direct-argument expressions */
+ peragg->aggdirectargs = ExecInitExprList(aggref->aggdirectargs,
+ (PlanState *) aggstate);
+
/*
* build expression trees using actual argument & result types for the
* finalfn, if it exists and is required.
}
- /* Initialize any direct-argument expressions */
- pertrans->aggdirectargs = ExecInitExprList(aggref->aggdirectargs,
- (PlanState *) aggstate);
-
/*
* If we're doing either DISTINCT or ORDER BY for a plain agg, then we
* have a list of SortGroupClause nodes; fish out the data in them and
newagg->aggstar != existingRef->aggstar ||
newagg->aggvariadic != existingRef->aggvariadic ||
newagg->aggkind != existingRef->aggkind ||
- !equal(newagg->aggdirectargs, existingRef->aggdirectargs) ||
!equal(newagg->args, existingRef->args) ||
!equal(newagg->aggorder, existingRef->aggorder) ||
!equal(newagg->aggdistinct, existingRef->aggdistinct) ||
/* if it's the same aggregate function then report exact match */
if (newagg->aggfnoid == existingRef->aggfnoid &&
newagg->aggtype == existingRef->aggtype &&
- newagg->aggcollid == existingRef->aggcollid)
+ newagg->aggcollid == existingRef->aggcollid &&
+ equal(newagg->aggdirectargs, existingRef->aggdirectargs))
{
list_free(*same_input_transnos);
*same_input_transnos = NIL;