Rethink nullingrel marking rules in build_joinrel_tlist().
authorTom Lane <[email protected]>
Tue, 7 Feb 2023 23:26:16 +0000 (18:26 -0500)
committerTom Lane <[email protected]>
Tue, 7 Feb 2023 23:26:16 +0000 (18:26 -0500)
commitfee7b77b9000f35e445de9954a8cbf241f181e60
tree8d575411ac4540dc31eb440cb9c99710b1f4357c
parente2c78e7ab4b6056ceb79415fddcf126868d028f5
Rethink nullingrel marking rules in build_joinrel_tlist().

The logic for when to add the current outer join's own relid
to the nullingrels sets of output Vars and PHVs was overly
complicated and underly correct.  Not sure why I didn't think
of this before, but since what we want is marking per the
syntactic structure, we can just consult our records about
the syntactic structure, ie syn_righthand/syn_lefthand.

Also, tighten the rule about when to add the commute_above_r
bits, in hopes of eliminating some squishy reasoning.  I do not
know of a reason to think that that's broken as-is, but this way
seems better.

Per bug #17781 from Robins Tharakan.

Discussion: https://postgr.es/m/17781-c0405c8b3cd5e072@postgresql.org
src/backend/optimizer/util/relnode.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql