Fix a thinko in join_is_legal: when we decide we can implement a semijoin
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 19 Jul 2009 20:32:48 +0000 (20:32 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 19 Jul 2009 20:32:48 +0000 (20:32 +0000)
commit9422ae2b863bff2fb8daecdfccf4db0607bd6b72
tree1241446eb982ec037565cc815193c78b8012929d
parentd813cf18425737ee417c1f2d7c55e0525d10d7b9
Fix a thinko in join_is_legal: when we decide we can implement a semijoin
by unique-ifying the RHS and then inner-joining to some other relation,
that is not grounds for violating the RHS of some other outer join.
Noticed while regression-testing new GEQO code, which will blindly follow
any path that join_is_legal says is legal, and then complain later if that
leads to a dead end.

I'm not certain that this can result in any visible failure in 8.4: the
mistake may always be masked by the fact that subsequent attempts to join
the rest of the RHS of the other join will fail.  But I'm not certain it
can't, either, and it's definitely not operating as intended.  So back-patch.

The added regression test depends on the new no-failures-allowed logic
that I'm about to commit in GEQO, so no point back-patching that.
src/backend/optimizer/path/joinrels.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql