pgsql: Fix another oversight in checking if a join with LATERAL refs is

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix another oversight in checking if a join with LATERAL refs is
Date: 2015-12-07 22:42:28
Message-ID: E1a64UG-0005Uc-FA@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix another oversight in checking if a join with LATERAL refs is legal.

It was possible for the planner to decide to join a LATERAL subquery to
the outer side of an outer join before the outer join itself is completed.
Normally that's fine because of the associativity rules, but it doesn't
work if the subquery contains a lateral reference to the inner side of the
outer join. In such a situation the outer join *must* be done first.
join_is_legal() missed this consideration and would allow the join to be
attempted, but the actual path-building code correctly decided that no
valid join path could be made, sometimes leading to planner errors such as
"failed to build any N-way joins".

Per report from Andreas Seltenreich. Back-patch to 9.3 where LATERAL
support was added.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0a34ff7e9a3a232d675fe03dba00d010c689f33c

Modified Files
--------------
src/backend/optimizer/path/joinrels.c | 30 ++++++++++++++++++++++++
src/backend/optimizer/util/relnode.c | 39 +++++++++++++++++++++++++++++++
src/include/optimizer/pathnode.h | 1 +
src/test/regress/expected/join.out | 41 +++++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 19 +++++++++++++++
5 files changed, 130 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2015-12-07 23:07:15 pgsql: PostgresNode: wrap correctly around port number range end
Previous Message Alvaro Herrera 2015-12-07 22:41:34 pgsql: Cleanup some problems in new Perl test code