model-writtenrun 3544 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Wenjiang Zhang reported inconsistent results from concurrent MERGE statements using a UNION ALL source, including unexpected inserts instead of updates, in #1.
- Dean Rasheed traced the problem to UNION ALL pullup leaving rowmarks ineffective during EvalPlanQual rechecks in #2, and demonstrated related UPDATE behavior differing from an ordinary source table in #3.
- Dean proposed disabling UNION ALL pullup only for MERGE and supplied isolation tests in #4, leaving UPDATE and DELETE unchanged and noting that concurrent unmatched inserts remained a documented limitation.
- Tom Lane asked Dean to hold that workaround because it masked the appendrel rowmark problem in #5, then supplied executor-level EPQ substitution in #6; the draft exposed a mismatch between whole-row identity values and Append output columns.
- Dean extended Tom's draft in #7 by preserving original targetlists and constructing projections only when EPQ runs, reporting successful isolation and ad hoc testing while emphasizing that the patch remained rough.
- Jian he questioned memory-context switching and expression-context initialization in #8; Dean explained the intended allocation lifetime and identified missing expression-context resets in #9, while Jian subsequently questioned targetlist initialization timing in #10.
- Wenjiang reported a separate case where concurrent updates suppressed MERGE's duplicate-source-row error in #11; Dean diagnosed inconsistent TM_SelfModified handlers and supplied a patch making both handlers check duplicate modifications and trigger-induced changes in #12.
- The self-modified-tuple fix landed as 29ef1dd19b, with unchanged executor logic from #12 plus isolation and trigger regression tests; the other supplied candidate, b5c645d2a2, is its PostgreSQL 15 backport.
- Dean confirmed the commit and backpatching in #13, but explicitly left the original UNION ALL bug unresolved and requested more review of the executor proof of concept from #7.