Skip to content

Commit 66dee28

Browse files
committed
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 0436f6b by copying the logic for window functions ... but that was broken too, and had been since commit eaccfde. Repair both cases in HEAD, and the window function case back to 9.3. 9.2 gets this right.
1 parent cb59949 commit 66dee28

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/parser/parse_agg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ check_agg_arguments_walker(Node *node,
390390
return false;
391391
}
392392
/* We can throw error on sight for a window function */
393-
if (IsA(node, WindowFunc))
393+
if (IsA(node, WindowFunc) && context->sublevels_up == 0)
394394
ereport(ERROR,
395395
(errcode(ERRCODE_GROUPING_ERROR),
396396
errmsg("aggregate function calls cannot contain window function calls"),

0 commit comments

Comments
 (0)