pgsql: Rewrite make_outerjoininfo's construction of min_lefthand and

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rewrite make_outerjoininfo's construction of min_lefthand and
Date: 2007-08-31 01:44:14
Message-ID: 20070831014414.CBB92754201@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Rewrite make_outerjoininfo's construction of min_lefthand and min_righthand
sets for outer joins, in the light of bug #3588 and additional thought and
experimentation. The original methodology was fatally flawed for nests of
more than two outer joins: it got the relationships between adjacent joins
right, but didn't always come to the right conclusions about whether a join
could be interchanged with one two or more levels below it. This was largely
caused by a mistaken idea that we should use the min_lefthand + min_righthand
sets of a sub-join as the minimum left or right input set of an upper join
when we conclude that the sub-join can't commute with the upper one. If
there's a still-lower join that the sub-join *can* commute with, this method
led us to think that that one could commute with the topmost join; which it
can't. Another problem (not directly connected to bug #3588) was that
make_outerjoininfo's processing-order-dependent method for enforcing outer
join identity #3 didn't work right: if we decided that join A could safely
commute with lower join B, we dropped all information about sub-joins under B
that join A could perhaps not safely commute with, because we removed B's
entire min_righthand from A's.

To fix, make an explicit computation of all inner join combinations that occur
below an outer join, and add to that the full syntactic relsets of any lower
outer joins that we determine it can't commute with. This method gives much
more direct enforcement of the outer join rearrangement identities, and it
turns out not to cost a lot of additional bookkeeping.

Thanks to Richard Harris for the bug report and test case.

Tags:
----
REL8_2_STABLE

Modified Files:
--------------
pgsql/src/backend/nodes:
copyfuncs.c (r1.353.2.1 -> r1.353.2.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/copyfuncs.c?r1=1.353.2.1&r2=1.353.2.2)
equalfuncs.c (r1.287.2.1 -> r1.287.2.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/equalfuncs.c?r1=1.287.2.1&r2=1.287.2.2)
outfuncs.c (r1.285.2.3 -> r1.285.2.4)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/outfuncs.c?r1=1.285.2.3&r2=1.285.2.4)
pgsql/src/backend/optimizer/plan:
initsplan.c (r1.123.2.5 -> r1.123.2.6)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/initsplan.c?r1=1.123.2.5&r2=1.123.2.6)
pgsql/src/include/nodes:
relation.h (r1.128.2.3 -> r1.128.2.4)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/relation.h?r1=1.128.2.3&r2=1.128.2.4)
pgsql/src/test/regress/expected:
join.out (r1.28.2.3 -> r1.28.2.4)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join.out?r1=1.28.2.3&r2=1.28.2.4)
join_1.out (r1.10.2.3 -> r1.10.2.4)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join_1.out?r1=1.10.2.3&r2=1.10.2.4)
pgsql/src/test/regress/sql:
join.sql (r1.19.2.3 -> r1.19.2.4)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/join.sql?r1=1.19.2.3&r2=1.19.2.4)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2007-08-31 02:03:02 pgsql: Add openjade warning -wfully-tagged to warn about missing close
Previous Message Tom Lane 2007-08-31 01:44:06 pgsql: Rewrite make_outerjoininfo's construction of min_lefthand and