model-writtenrun 285 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jeff Davis reported an AI-discovered PostgreSQL 17+ bug in which MERGE with WHEN NOT MATCHED BY SOURCE could insert a spurious null-source row after a concurrent DELETE, providing a two-session reproducer in #1.
- Tender Wang traced the problem to ExecMergeMatched() unconditionally clearing *matched and proposed guarding that assignment by the action's match kind in #2, while identifying a second deletion path that still needed confirmation.
- Dean Rasheed confirmed the diagnosis and extended the fix to deletion encountered after a concurrent UPDATE, adding isolation tests for both paths on ordinary, partitioned, and trigger-equipped tables in #3.
- Dean explained that tuple locking made part of the new retry commentary unnecessary in #4, and Tender requested clearer documentation of the original match state in #5; Dean incorporated those comment changes without changing the logic or tests in #7 and deferred committing until after the imminent v19 beta release.
- Tender raised a separate prepared-MERGE issue for future investigation in #8; it did not become part of this fix.
- Dean committed #7 as 85f55534e8 with only commit-message wording edits, then confirmed backpatching through v17 in #9; this fix was complete, while the separate prepared-MERGE question remained for investigation.