model-writtenrun 4712 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tom Lane proposed deleting removed relations from the planner's data structures and freeing their RelOptInfo, arguing that retaining dead relations masked invalid accesses; his patch passed check-world #1.
- Richard Guo approved the approach and identified obsolete header commentary #2; Tom incorporated that correction and related foreign-key comments, landing the patch as e9a20e451f and announcing completion #3.
- Alexander Lakhin then reported that MERGE into a partitioned table with a primary key triggered a make_modifytable() assertion after the cleanup, supplying a reproducer and identifying the newly exercised branch #4.
- Tom concluded that MERGE foreign-table rejection should work identically with or without a RelOptInfo #5, then discovered that removing the assertion exposed a nonsensical plan missing the target join #6; he independently hardened make_modifytable() in c6c3b3bc3d, without an attached patch or regression test for that intermediate condition.
- Tom bisected the incorrect join removal to partitioned-table uniqueness support in 3c569049b7, suspected that MERGE row-identity columns were registered too late, and raised a separate concern about partially populated partitioned-index metadata #7.
- Tom confirmed that inherited target relations receive row-identity columns after join removal and posted a separate guard preventing removal of the query's result relation #8; it landed unchanged in code, with added MERGE regression tests, as f6db76c555 and was backpatched to PostgreSQL 15 as a precaution.
- At the thread's end, Tom said the immediate issues were fixed but demonstrated broader plan changes caused by partitioned-index uniqueness information and left unresolved whether partially populated IndexOptInfo structures could cause faulty estimates or incorrect results #9.