model-writtenrun 8919 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Will Leinweber reported two PostgreSQL 12.1 join-planning errors triggered by related LATERAL queries with different LIMIT placements, neither reproducible on the PostgreSQL 11 versions he tested #1.
- Tom Lane reproduced an assertion failure in create_lateral_join_info and suspected the RTE_RESULT optimization changes after comparing PostgreSQL 11's plan #2.
- Tom confirmed that excessive join-tree folding assigned a PlaceHolderVar to the same relation that needed to consume it, and posted a proposed fix #3.
- The patch prevents removal of RTE_RESULT relations when sibling inputs depend on their PlaceHolderVars, extracts range_table_entry_walker to inspect individual RTEs, and adds a regression test; the thread ends with this proposal and no subsequent review response #3.
- Tom subsequently committed the patch with additional scanning optimizations, a revised find_dependent_phvs API, and clearer comments, retaining the regression tests and backpatching the fix to PostgreSQL 12 6ea364e7e7.