From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Fix another oversight in checking if a join with LATERAL refs is
Date: Mon, 07 Dec 2015 22:42:28 +0000
Message-ID: <E1a64UG-0005Ua-F5@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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_4_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/0901d68babc324cc09077131fa966f15225e1fab
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(+)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Fix another oversight in checking if a join with LATERAL refs is
In-Reply-To: <E1a64UG-0005Ua-F5@gemulon.postgresql.org>
References: <E1a64UG-0005Ua-F5@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox