1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00

Re-allow SRFs and window functions within sub-selects within aggregates.

check_agg_arguments_walker threw an error upon seeing a SRF or window
function, but that is too aggressive: if the function is within a
sub-select then it's perfectly fine.  I broke the SRF case in commit
0436f6bde by copying the logic for window functions ... but that was
broken too, and had been since commit eaccfded9.

Repair both cases in HEAD, and the window function case back to 9.3.
9.2 gets this right.
This commit is contained in:
Tom Lane 2017-06-27 17:51:11 -04:00
parent df31a9fc66
commit 3a7bd59c44

View File

@ -700,7 +700,7 @@ check_agg_arguments_walker(Node *node,
/* Continue and descend into subtree */ /* Continue and descend into subtree */
} }
/* We can throw error on sight for a window function */ /* We can throw error on sight for a window function */
if (IsA(node, WindowFunc)) if (IsA(node, WindowFunc) && context->sublevels_up == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR), (errcode(ERRCODE_GROUPING_ERROR),
errmsg("aggregate function calls cannot contain window function calls"), errmsg("aggregate function calls cannot contain window function calls"),