]> granicus.if.org Git - postgresql/commit
More fixes for planner's handling of LATERAL.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 12 Aug 2012 20:01:26 +0000 (16:01 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 12 Aug 2012 20:01:26 +0000 (16:01 -0400)
commitc1774d2c8193a322706f681dd984ac439d3a9dbb
tree85fd93fd7dfd6c71bd7236d2dba573fb9f4c51b6
parente76af54137c051cafcb1e39f68383a31d1d55ff6
More fixes for planner's handling of LATERAL.

Re-allow subquery pullup for LATERAL subqueries, except when the subquery
is below an outer join and contains lateral references to relations outside
that outer join.  If we pull up in such a case, we risk introducing lateral
cross-references into outer joins' ON quals, which is something the code is
entirely unprepared to cope with right now; and I'm not sure it'll ever be
worth coping with.

Support lateral refs in VALUES (this seems to be the only additional path
type that needs such support as a consequence of re-allowing subquery
pullup).

Put in a slightly hacky fix for joinpath.c's refusal to consider
parameterized join paths even when there cannot be any unparameterized
ones.  This was causing "could not devise a query plan for the given query"
failures in queries involving more than two FROM items.

Put in an even more hacky fix for distribute_qual_to_rels() being unhappy
with join quals that contain references to rels outside their syntactic
scope; which is to say, disable that test altogether.  Need to think about
how to preserve some sort of debugging cross-check here, while not
expending more cycles than befits a debugging cross-check.
13 files changed:
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/prep/prepjointree.c
src/backend/optimizer/util/pathnode.c
src/include/optimizer/cost.h
src/include/optimizer/pathnode.h
src/include/optimizer/prep.h
src/test/regress/expected/join.out
src/test/regress/sql/join.sql