Fix miscomputation of direct_lateral_relids for join relations.
Tom Lane <tgl@sss.pgh.pa.us>
Fix miscomputation of direct_lateral_relids for join relations. If a PlaceHolderVar is to be evaluated at a join relation, but its value is only needed there and not at higher levels, we neglected to update the joinrel's direct_lateral_relids to include the PHV's source rel. This causes problems because join_is_legal() then won't allow joining the joinrel to the PHV's source rel at all, leading to "failed to build any N-way joins" planner failures. Per report from Andreas Seltenreich. Back-patch to 9.5 where the problem originated. Discussion: https://postgr.es/m/87blfgqa4t.fsf@aurora.ydns.eu
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/util/placeholder.c | modified | +27 −11 |
| src/test/regress/expected/join.out | modified | +64 −0 |
| src/test/regress/sql/join.sql | modified | +27 −0 |
Discussion
- [sqlsmith] Planner error on lateral joins 3 messages · 2020-11-29 → 2020-11-30