]> granicus.if.org Git - postgresql/commitdiff
expression_tree_walker failed to let walker function see the immediate child
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 25 Oct 2006 22:11:32 +0000 (22:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 25 Oct 2006 22:11:32 +0000 (22:11 +0000)
node of a SubLink or SubPlan testexpr field.  Bug resulted from replacing
the old lefthand/exprs list fields with a simple expression field, and not
remembering that expression_tree_walker is coded to save a few cycles by
recursing directly to self on list fields (on the assumption the walker
isn't interested in List nodes per se).  On non-list fields it must of
course call the walker.  Possibly that hack isn't worth the risk of more
such bugs, but I'll leave it be for now.  Per bug report from James Robinson.

src/backend/optimizer/util/clauses.c

index c9d9512b2f5dc576c554e737447aeb9391bbdc9e..3800228398eaf826c40f81be134f6d2d46dc0871 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.222 2006/10/04 00:29:55 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.223 2006/10/25 22:11:32 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -3177,6 +3177,7 @@ expression_tree_walker(Node *node,
                        {
                                Aggref     *expr = (Aggref *) node;
 
+                               /* recurse directly on List */
                                if (expression_tree_walker((Node *) expr->args,
                                                                                   walker, context))
                                        return true;
@@ -3249,8 +3250,7 @@ expression_tree_walker(Node *node,
                        {
                                SubLink    *sublink = (SubLink *) node;
 
-                               if (expression_tree_walker(sublink->testexpr,
-                                                                                  walker, context))
+                               if (walker(sublink->testexpr, context))
                                        return true;
 
                                /*
@@ -3265,8 +3265,7 @@ expression_tree_walker(Node *node,
                                SubPlan    *subplan = (SubPlan *) node;
 
                                /* recurse into the testexpr, but not into the Plan */
-                               if (expression_tree_walker(subplan->testexpr,
-                                                                                  walker, context))
+                               if (walker(subplan->testexpr, context))
                                        return true;
                                /* also examine args list */
                                if (expression_tree_walker((Node *) subplan->args,