From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix improper interaction of FULL JOINs with lateral references.
Date: Mon, 08 Apr 2019 20:09:41 +0000
Message-ID: <E1hDaaL-0007Lv-3H@gemulon.postgresql.org> (raw)
Fix improper interaction of FULL JOINs with lateral references.
join_is_legal() needs to reject forming certain outer joins in cases
where that would lead the planner down a blind alley. However, it
mistakenly supposed that the way to handle full joins was to treat them
as applying the same constraints as for left joins, only to both sides.
That doesn't work, as shown in bug #15741 from Anthony Skorski: given
a lateral reference out of a join that's fully enclosed by a full join,
the code would fail to believe that any join ordering is legal, resulting
in errors like "failed to build any N-way joins".
However, we don't really need to consider full joins at all for this
purpose, because we effectively force them to be evaluated in syntactic
order, and that order is always legal for lateral references. Hence,
get rid of this broken logic for full joins and just ignore them instead.
This seems to have been an oversight in commit 7e19db0c0.
Back-patch to all supported branches, as that was.
Discussion: https://postgr.es/m/15741-276f1f464b3f40eb@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/45f8eaa8e3031c9cb12deb1b5e294bc052b378f2
Modified Files
--------------
src/backend/optimizer/path/joinrels.c | 13 ++++---------
src/test/regress/expected/rangefuncs.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/rangefuncs.sql | 15 +++++++++++++++
3 files changed, 44 insertions(+), 9 deletions(-)
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 improper interaction of FULL JOINs with lateral references.
In-Reply-To: <E1hDaaL-0007Lv-3H@gemulon.postgresql.org>
References: <E1hDaaL-0007Lv-3H@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