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.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/c1774d2c8193a322706f681dd984ac439d3a9dbb
Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 26 +++-
src/backend/optimizer/path/costsize.c | 20 ++-
src/backend/optimizer/path/joinpath.c | 26 ++++
src/backend/optimizer/plan/createplan.c | 14 ++-
src/backend/optimizer/plan/initsplan.c | 14 ++
src/backend/optimizer/plan/planner.c | 2 +-
src/backend/optimizer/prep/prepjointree.c | 217 +++++++++++++++++++++--------
src/backend/optimizer/util/pathnode.c | 8 +-
src/include/optimizer/cost.h | 2 +-
src/include/optimizer/pathnode.h | 3 +-
src/include/optimizer/prep.h | 4 +-
src/test/regress/expected/join.out | 127 +++++++++++++++--
src/test/regress/sql/join.sql | 16 ++
13 files changed, 390 insertions(+), 89 deletions(-)