1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +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:
Noah Misch
2013-07-16 20:15:36 -04:00
parent 7a8e9f298e
commit b560ec1b0d
35 changed files with 403 additions and 51 deletions

View File

@ -575,6 +575,10 @@ assign_collations_walker(Node *node, assign_collations_context *context)
* the case above for T_TargetEntry will apply
* appropriate checks to agg ORDER BY items.
*
* Likewise, we assign collations for the (bool)
* expression in aggfilter, independently of any
* other args.
*
* We need not recurse into the aggorder or
* aggdistinct lists, because those contain only
* SortGroupClause nodes which we need not
@ -595,6 +599,24 @@ assign_collations_walker(Node *node, assign_collations_context *context)
(void) assign_collations_walker((Node *) tle,
&loccontext);
}
assign_expr_collations(context->pstate,
(Node *) aggref->aggfilter);
}
break;
case T_WindowFunc:
{
/*
* WindowFunc requires special processing only for
* its aggfilter clause, as for aggregates.
*/
WindowFunc *wfunc = (WindowFunc *) node;
(void) assign_collations_walker((Node *) wfunc->args,
&loccontext);
assign_expr_collations(context->pstate,
(Node *) wfunc->aggfilter);
}
break;
case T_CaseExpr: