agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY @ 2026-09-23 08:41 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-09-23 08:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY SOURCE. When executing a WHEN NOT MATCHED BY SOURCE action in MERGE, if the tuple from the target table was concurrently deleted, the retry code would incorrectly execute a WHEN NOT MATCHED BY TARGET action for the row instead, giving incorrect results. Fix in ExecMergeMatched() -- when handling a TM_Deleted failure status, it should only set *matched to false (telling the caller to execute any WHEN NOT MATCHED BY TARGET actions) if the failed action was a WHEN MATCHED action. For a failed WHEN NOT MATCHED BY SOURCE action, the source tuple did not exist, and the target tuple has just been deleted, so it should do nothing. Back-patch to v17, where support for WHEN NOT MATCHED BY SOURCE actions was introduced. Reported-by: Jeff Davis <pgsql@j-davis.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/ccdab5ba02c65af195b5a6d2d744a01d9de47cd3.camel@j-davis.com Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/85f55534e80b633bdb7bfc91eaa5793021d6bf66 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 35 ++++-- src/test/isolation/expected/merge-delete.out | 158 +++++++++++++++++++++++++++ src/test/isolation/specs/merge-delete.spec | 37 +++++++ 3 files changed, 220 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY @ 2026-09-23 08:41 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-09-23 08:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY SOURCE. When executing a WHEN NOT MATCHED BY SOURCE action in MERGE, if the tuple from the target table was concurrently deleted, the retry code would incorrectly execute a WHEN NOT MATCHED BY TARGET action for the row instead, giving incorrect results. Fix in ExecMergeMatched() -- when handling a TM_Deleted failure status, it should only set *matched to false (telling the caller to execute any WHEN NOT MATCHED BY TARGET actions) if the failed action was a WHEN MATCHED action. For a failed WHEN NOT MATCHED BY SOURCE action, the source tuple did not exist, and the target tuple has just been deleted, so it should do nothing. Back-patch to v17, where support for WHEN NOT MATCHED BY SOURCE actions was introduced. Reported-by: Jeff Davis <pgsql@j-davis.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/ccdab5ba02c65af195b5a6d2d744a01d9de47cd3.camel@j-davis.com Backpatch-through: 17 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fe1d5aeffda796710d97f917121670fd46ae82b1 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 35 ++++-- src/test/isolation/expected/merge-delete.out | 158 +++++++++++++++++++++++++++ src/test/isolation/specs/merge-delete.spec | 37 +++++++ 3 files changed, 220 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY @ 2026-09-23 08:41 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-09-23 08:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY SOURCE. When executing a WHEN NOT MATCHED BY SOURCE action in MERGE, if the tuple from the target table was concurrently deleted, the retry code would incorrectly execute a WHEN NOT MATCHED BY TARGET action for the row instead, giving incorrect results. Fix in ExecMergeMatched() -- when handling a TM_Deleted failure status, it should only set *matched to false (telling the caller to execute any WHEN NOT MATCHED BY TARGET actions) if the failed action was a WHEN MATCHED action. For a failed WHEN NOT MATCHED BY SOURCE action, the source tuple did not exist, and the target tuple has just been deleted, so it should do nothing. Back-patch to v17, where support for WHEN NOT MATCHED BY SOURCE actions was introduced. Reported-by: Jeff Davis <pgsql@j-davis.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/ccdab5ba02c65af195b5a6d2d744a01d9de47cd3.camel@j-davis.com Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ce9bd103e0e34b37187edae5e3b0bd90fedf1373 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 35 ++++-- src/test/isolation/expected/merge-delete.out | 158 +++++++++++++++++++++++++++ src/test/isolation/specs/merge-delete.spec | 37 +++++++ 3 files changed, 220 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY @ 2026-09-23 08:41 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-09-23 08:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY SOURCE. When executing a WHEN NOT MATCHED BY SOURCE action in MERGE, if the tuple from the target table was concurrently deleted, the retry code would incorrectly execute a WHEN NOT MATCHED BY TARGET action for the row instead, giving incorrect results. Fix in ExecMergeMatched() -- when handling a TM_Deleted failure status, it should only set *matched to false (telling the caller to execute any WHEN NOT MATCHED BY TARGET actions) if the failed action was a WHEN MATCHED action. For a failed WHEN NOT MATCHED BY SOURCE action, the source tuple did not exist, and the target tuple has just been deleted, so it should do nothing. Back-patch to v17, where support for WHEN NOT MATCHED BY SOURCE actions was introduced. Reported-by: Jeff Davis <pgsql@j-davis.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/ccdab5ba02c65af195b5a6d2d744a01d9de47cd3.camel@j-davis.com Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/745152e451c10ff8635b0f0f186de98fe0528fec Modified Files -------------- src/backend/executor/nodeModifyTable.c | 35 ++++-- src/test/isolation/expected/merge-delete.out | 158 +++++++++++++++++++++++++++ src/test/isolation/specs/merge-delete.spec | 37 +++++++ 3 files changed, 220 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-09-23 08:41 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-09-23 08:41 pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY Dean Rasheed <dean.a.rasheed@gmail.com> 2026-09-23 08:41 pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY Dean Rasheed <dean.a.rasheed@gmail.com> 2026-09-23 08:41 pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY Dean Rasheed <dean.a.rasheed@gmail.com> 2026-09-23 08:41 pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY Dean Rasheed <dean.a.rasheed@gmail.com>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox