diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-17 01:20:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-17 01:20:00 +0000 |
commit | 19e34b62395b36513a8e6c35ddfbeef12dd1e89f (patch) | |
tree | cf74ae45a1d9ea3c6f2ffc471d5dea75fb510984 /src/backend/optimizer/plan/planner.c | |
parent | 909346eff0ca2c7a73e889122d6f54669494141b (diff) | |
download | postgresql-19e34b62395b36513a8e6c35ddfbeef12dd1e89f.tar.gz postgresql-19e34b62395b36513a8e6c35ddfbeef12dd1e89f.zip |
Improve sublink pullup code to handle ANY/EXISTS sublinks that are at top
level of a JOIN/ON clause, not only at top level of WHERE. (However, we
can't do this in an outer join's ON clause, unless the ANY/EXISTS refers
only to the nullable side of the outer join, so that it can effectively
be pushed down into the nullable side.) Per request from Kevin Grittner.
In passing, fix a bug in the initial implementation of EXISTS pullup:
it would Assert if the EXIST's WHERE clause used a join alias variable.
Since we haven't yet flattened join aliases when this transformation
happens, it's necessary to include join relids in the computed set of
RHS relids.
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 8b432ba93fb..40a659391c6 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.241 2008/08/14 18:47:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.242 2008/08/17 01:19:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -268,14 +268,13 @@ subquery_planner(PlannerGlobal *glob, Query *parse, root->append_rel_list = NIL; /* - * Look for ANY and EXISTS SubLinks at the top level of WHERE, and try to - * transform them into joins. Note that this step only handles SubLinks - * originally at top level of WHERE; if we pull up any subqueries below, - * their SubLinks are processed just before pulling them up. + * Look for ANY and EXISTS SubLinks in WHERE and JOIN/ON clauses, and try + * to transform them into joins. Note that this step does not descend + * into subqueries; if we pull up any subqueries below, their SubLinks are + * processed just before pulling them up. */ if (parse->hasSubLinks) - parse->jointree->quals = pull_up_sublinks(root, - parse->jointree->quals); + pull_up_sublinks(root); /* * Scan the rangetable for set-returning functions, and inline them |