pgsql: Further fixes for degenerate outer join clauses.

Started by Tom Lanealmost 11 years ago3 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Further fixes for degenerate outer join clauses.

Further testing revealed that commit f69b4b9495269cc4 was still a few
bricks shy of a load: minor tweaking of the previous test cases resulted
in the same wrong-outer-join-order problem coming back. After study
I concluded that my previous changes in make_outerjoininfo() were just
accidentally masking the problem, and should be reverted in favor of
forcing syntactic join order whenever an upper outer join's predicate
doesn't mention a lower outer join's LHS. This still allows the
chained-outer-joins style that is the normally optimizable case.

I also tightened things up some more in join_is_legal(). It seems to me
on review that what's really happening in the exception case where we
ignore a mismatched special join is that we're allowing the proposed join
to associate into the RHS of the outer join we're comparing it to. As
such, we should *always* insist that the proposed join be a left join,
which eliminates a bunch of rather dubious argumentation. The case where
we weren't enforcing that was the one that was already known buggy anyway
(it had a violatable Assert before the aforesaid commit) so it hardly
deserves a lot of deference.

Back-patch to all active branches, like the previous patch. The added
regression test case failed in all branches back to 9.1, and I think it's
only an unrelated change in costing calculations that kept 9.0 from
choosing a broken plan.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/754ece936ca0938dcb149f7617df14b202034e28

Modified Files
--------------
src/backend/optimizer/README | 23 +++++++---
src/backend/optimizer/path/joinrels.c | 73 ++++++++++++--------------------
src/backend/optimizer/plan/initsplan.c | 28 ++++++------
src/test/regress/expected/join.out | 72 ++++++++++++++++++++++++++++++-
src/test/regress/sql/join.sql | 25 +++++++++++
5 files changed, 153 insertions(+), 68 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#1)
Re: pgsql: Further fixes for degenerate outer join clauses.

On 8/6/15 3:36 PM, Tom Lane wrote:

Further fixes for degenerate outer join clauses.

The <=9.2 versions of this change introduce a new compiler warning:

variable ‘unique_ified’ set but not used [-Wunused-but-set-variable]

This variable is apparently only used in 9.3+ for some LATERAL stuff, so
it could probably be removed in 9.2.

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#2)
Re: pgsql: Further fixes for degenerate outer join clauses.

Peter Eisentraut <peter_e@gmx.net> writes:

On 8/6/15 3:36 PM, Tom Lane wrote:

Further fixes for degenerate outer join clauses.

The <=9.2 versions of this change introduce a new compiler warning:
variable ‘unique_ified’ set but not used [-Wunused-but-set-variable]

My compiler didn't complain about that :-(. Fixed, thanks for the note.

regards, tom lane

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers