model-writtenrun 595 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Viktor Leis reported that nested LEFT JOINs over an empty subquery returned a constant instead of NULL on PostgreSQL releases since version 16, providing a reproducer and analysis of stale outer-join relids in #1.
- Matheus Alcantara proposed a membership-based PHV dependency check and regression test in #2, but Tom Lane showed that membership would suppress valid optimizations and recommended comparing only base relids in both dependency helpers in #3.
- Richard Guo warned against collecting an incomplete base-relid set during recursion and suggested get_relids_in_jointree(), while attaching an alternative that subtracts already-dropped outer joins in #5; Matheus separately implemented base-relid masking using a rangetable scan in #6.
- Tom combined Matheus's masking approach with Richard's proposed jointree scan and test commentary in #7, rejecting reliance on dropped_outer_joins because surviving or not-yet-processed joins might also matter; he left replacing dependent PHVs with NULL constants as a possible future optimization.
- Richard approved the combined patch in #8, and Tom committed it as 3e1fe25e68, preserving the code and tests from #7 while expanding the commit explanation and backpatching through version 16; Tom confirmed the push in #9.
- Richard then proposed skipping the new jointree scan when the query contains no PHVs in #11, and Tom accepted that optimization in #12.
- Richard committed the optimization as 0da71d90d6 with one additional comment documenting nullable baserels, backpatched it through version 16, and confirmed the push in #13, leaving both submitted changes landed.