From: Tom Lane Date: Thu, 8 Mar 2001 01:49:01 +0000 (+0000) Subject: A subplan invoked within an aggregate function's argument should X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=86207d84f46d425d82d07b8eeec179fa96068c2e;p=users%2Fbernd%2Fpostgres.git A subplan invoked within an aggregate function's argument should be allowed to receive ungrouped variables of the current query level. Curious that no one reported this bug before... --- diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 5ab45f67ac..9a3ac10536 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -542,6 +542,14 @@ check_subplans_for_ungrouped_vars_walker(Node *node, if (node == NULL) return false; + /* + * If we find an aggregate function, do not recurse into its + * arguments. Subplans invoked within aggregate calls are allowed + * to receive ungrouped variables. + */ + if (IsA(node, Aggref)) + return false; + /* * We can ignore Vars other than in subplan args lists, since the * parser already checked 'em.