mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Implement the FILTER clause for aggregate function calls.
This is SQL-standard with a few extensions, namely support for subqueries and outer references in clause expressions. catversion bump due to change in Aggref and WindowFunc. David Fetter, reviewed by Dean Rasheed.
This commit is contained in:
@ -484,10 +484,23 @@ advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup)
|
||||
{
|
||||
AggStatePerAgg peraggstate = &aggstate->peragg[aggno];
|
||||
AggStatePerGroup pergroupstate = &pergroup[aggno];
|
||||
ExprState *filter = peraggstate->aggrefstate->aggfilter;
|
||||
int nargs = peraggstate->numArguments;
|
||||
int i;
|
||||
TupleTableSlot *slot;
|
||||
|
||||
/* Skip anything FILTERed out */
|
||||
if (filter)
|
||||
{
|
||||
bool isnull;
|
||||
Datum res;
|
||||
|
||||
res = ExecEvalExprSwitchContext(filter, aggstate->tmpcontext,
|
||||
&isnull, NULL);
|
||||
if (isnull || !DatumGetBool(res))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Evaluate the current input expressions for this aggregate */
|
||||
slot = ExecProject(peraggstate->evalproj, NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user