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-c0405c8b3cd5e...@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/fee7b77b9000f35e445de9954a8cbf241f181e60 Modified Files -------------- src/backend/optimizer/util/relnode.c | 43 +++++++++++++++++++---------------- src/test/regress/expected/join.out | 44 ++++++++++++++++++++++++++++++++++++ src/test/regress/sql/join.sql | 28 +++++++++++++++++++++++ 3 files changed, 96 insertions(+), 19 deletions(-)