Fix thinko in join removal.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 May 2023 19:24:07 +0000 (15:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 May 2023 19:24:07 +0000 (15:24 -0400)
commitd0f952691ff532aa0c54e9d146fac8d590596646
tree4d6a46d5e535cd1cd8b982c74dbea5a612c0771d
parent70b42f2790292cc30aa07563f343f7ba6749af01
Fix thinko in join removal.

In commit 9df8f903e I (tgl) switched join_is_removable() from
using the min relid sets of the join under consideration to
using its full syntactic relid sets.  This was a mistake,
as it allowed join removal in cases where a reference to the
join output would survive in some syntactically-lower join
condition.  Revert to the former coding.

Richard Guo

Discussion: https://postgr.es/m/CAMbWs4-EU9uBGSP7G-iTwLBhRQ=rnZKvFDhD+n+xhajokyPCKg@mail.gmail.com
src/backend/optimizer/plan/analyzejoins.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql