diff options
author | Pavan Deolasee | 2017-07-13 09:22:22 +0000 |
---|---|---|
committer | Pavan Deolasee | 2017-07-13 09:22:22 +0000 |
commit | 03162cb93078de77532bf08498d96345fe14ea68 (patch) | |
tree | e165038efc76fc408b6541edc3eccb121cce1eb5 /src/backend/parser | |
parent | e26a0e07d863777079bfe9fc335ca2b71377b731 (diff) | |
parent | bc2d716ad09fceeb391c755f78c256ddac9d3b9f (diff) |
Merge remote-tracking branch 'remotes/PGSQL/master' of PG 10
This merge includes all commits upto bc2d716ad09fceeb391c755f78c256ddac9d3b9f
of PG 10.
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/parse_agg.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index a07274f77e..455c362768 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -712,21 +712,28 @@ check_agg_arguments_walker(Node *node, } /* Continue and descend into subtree */ } - /* We can throw error on sight for a set-returning function */ - if ((IsA(node, FuncExpr) &&((FuncExpr *) node)->funcretset) || - (IsA(node, OpExpr) &&((OpExpr *) node)->opretset)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("aggregate function calls cannot contain set-returning function calls"), - errhint("You might be able to move the set-returning function into a LATERAL FROM item."), - parser_errposition(context->pstate, exprLocation(node)))); - /* We can throw error on sight for a window function */ - if (IsA(node, WindowFunc)) - ereport(ERROR, - (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregate function calls cannot contain window function calls"), - parser_errposition(context->pstate, - ((WindowFunc *) node)->location))); + + /* + * SRFs and window functions can be rejected immediately, unless we are + * within a sub-select within the aggregate's arguments; in that case + * they're OK. + */ + if (context->sublevels_up == 0) + { + if ((IsA(node, FuncExpr) &&((FuncExpr *) node)->funcretset) || + (IsA(node, OpExpr) &&((OpExpr *) node)->opretset)) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("aggregate function calls cannot contain set-returning function calls"), + errhint("You might be able to move the set-returning function into a LATERAL FROM item."), + parser_errposition(context->pstate, exprLocation(node)))); + if (IsA(node, WindowFunc)) + ereport(ERROR, + (errcode(ERRCODE_GROUPING_ERROR), + errmsg("aggregate function calls cannot contain window function calls"), + parser_errposition(context->pstate, + ((WindowFunc *) node)->location))); + } if (IsA(node, Query)) { /* Recurse into subselects */ |