Assert that RTIs of joined rels are discoverable from join plans.
authorRobert Haas <rhaas@postgresql.org>
Wed, 16 Apr 2025 12:32:00 +0000 (08:32 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 19 May 2025 15:02:50 +0000 (11:02 -0400)
commitf28f3c2498855f8def62d65aed9db70cf3bc4f36
treece38895774b3bf5dea488f41931e467303eb2b16
parentea5fb810cab564dfef22e6065d05b414185f3cf1
Assert that RTIs of joined rels are discoverable from join plans.

Every RTI that appears in the joinrel's relid set should be findable
via the outer or inner plan, except for join RTIs which aren't
necessarily preserved in the final plan. This is a requirement if
we want to be able to reliably determine the chosen join order from
the final plan, although it's not sufficient for that goal of itself,
due to further problems created by setrefs-time processing.

Note that this depends on the earlier commit to add a relids field to
Result nodes; without that change, a join tree involving two or more
Result nodes would be fundamentally ambiguous (and even a join tree
involving one could only be interpreted by guessing at its origin).
src/backend/optimizer/plan/createplan.c