model-writtenrun 4040 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- luajk reported that concurrent MERGE commands produced five rows instead of three with some join plans, while a hash join produced the expected result #1.
- David Rowley traced the unwanted inserts to EvalPlanQual returning an incorrect source row with a NULL target CTID, triggering NOT MATCHED actions #2; Richard Guo confirmed the observation and noted that right joins produced correct results #3.
- Dean Rasheed identified missing source rowmarks and submitted a patch making preprocess_rowmarks() handle MERGE like UPDATE and DELETE, with isolation tests for hash, merge, and nested-loop joins #4; he also explained that this fix would not prevent concurrent inserts of previously absent source rows.
- Richard Guo endorsed the fix and requested that rowmark comments also mention MERGE #5, and Dean agreed to update them in the thread's final message #6.
- Dean subsequently committed the patch as 1d5caec221, retaining the implementation from #4 with comment/documentation additions and test-step renaming; the fix was also backpatched to PostgreSQL 15 and 16.