model-writtenrun 2222 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Andres Freund reported missing MERGE INSERT RETURNING rows and incompatible insert projections for inheritance tables, attaching diagnostic instrumentation and a reproducer in #1.
- Alvaro Herrera suspected confusion between child and parent tuples in #2, and Tender Wang traced the missing RETURNING output to an uninitialized root projection in #3, then proposed switching ExecInsert() to resultRelInfo for nonpartitioned tables in #4.
- Dean Rasheed rejected that workaround in #5 and supplied a replacement in #6: INSERT must retain the parent relation even when constraints exclude it from the scan, so ExecInitMerge() must initialize the parent's insert projection, WITH CHECK OPTION state, and RETURNING projection; broader deduplication with partition initialization was deferred to keep the fix smaller.
- Tender tested Dean's replacement successfully in #7, and Jian He proposed avoiding unnecessary attribute mapping in #9; Dean incorporated that optimization in #11 while declining to move RETURNING initialization into ExecInitModifyTable().
- Dean explained the parent-exclusion regression case and the distinction between ResultRelInfo identity and Relation identity in #12 and #13; Tender confirmed the original workaround could crash in #14 and gave his final endorsement in #16 after Dean's further explanation in #15.
- Dean committed #11 with light cleanup as b006bcd531, backpatched the fix through PostgreSQL 15, and announced completion in #17; the reported bugs were resolved, with the optional code-deduplication work left outside this fix.