A subplan invoked within an aggregate function's argument should
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 8 Mar 2001 01:49:01 +0000 (01:49 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 8 Mar 2001 01:49:01 +0000 (01:49 +0000)
be allowed to receive ungrouped variables of the current query level.
Curious that no one reported this bug before...

src/backend/optimizer/util/clauses.c

index e6d51b047ccfa7009e640cbe5f36e4bc2ddcfdf0..bc05908148b372b205f17a561725eb60d630218f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.81 2001/02/12 18:46:40 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.82 2001/03/08 01:49:01 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -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.