From bc0bcce2e74bf777b458e3fd815bb125dbda2ce6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 13 Mar 2023 12:40:28 -0400 Subject: Fix failure to detect some cases of improperly-nested aggregates. check_agg_arguments_walker() supposed that it needn't descend into the arguments of a lower-level aggregate function, but this is just wrong in the presence of multiple levels of sub-select. The oversight would lead to executor failures on queries that should be rejected. (Prior to v11, they actually were rejected, thanks to a "redundant" execution-time check.) Per bug #17835 from Anban Company. Back-patch to all supported branches. Discussion: https://postgr.es/m/17835-4f29f3098b2d0ba4@postgresql.org --- src/backend/parser/parse_agg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/backend/parser/parse_agg.c') diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 73da5fa101e..bd98dbd7ace 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -717,8 +717,7 @@ check_agg_arguments_walker(Node *node, context->min_agglevel > agglevelsup) context->min_agglevel = agglevelsup; } - /* no need to examine args of the inner aggregate */ - return false; + /* Continue and descend into subtree */ } if (IsA(node, GroupingFunc)) { -- cgit v1.2.3