Fix another thinko in join_is_legal's handling of semijoins: we have to test
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Jul 2009 17:42:06 +0000 (17:42 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Jul 2009 17:42:06 +0000 (17:42 +0000)
commit1f63bf9c741decd21c80471f3c158f6361517655
tree0a4ad8701a0eeb187407a8522387050ccae057bb
parentb94f1fa6a08e00881766856975edb8c15f1405f9
Fix another thinko in join_is_legal's handling of semijoins: we have to test
for the case that the semijoin was implemented within either input by
unique-ifying its RHS before we test to see if it appears to match the current
join situation.  The previous coding would select semijoin logic in situations
where we'd already unique-ified the RHS and joined it to some unrelated
relation(s), and then came to join it to the semijoin's LHS.  That still gave
the right answer as far as the semijoin itself was concerned, but would lead
to incorrectly examining only an arbitrary one of the matchable rows from the
unrelated relation(s).  The cause of this thinko was incorrect unification of
the pre-8.4 logic for IN joins and OUTER joins --- the comparable case for
outer joins can be handled after making the match test, but that's because
there is nothing like the unique-ification escape hatch for outer joins.
Per bug #4934 from Benjamin Reed.
src/backend/optimizer/path/joinrels.c