pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix stale source values in MERGE after a concurrent update. 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix stale source values in MERGE after a concurrent update. @ 2026-11-21 12:17 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-11-21 12:17 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale source values in MERGE after a concurrent update. When a MERGE has WHEN NOT MATCHED BY SOURCE actions and an initially matched target row is concurrently updated so that it no longer satisfies the join condition, causing a WHEN NOT MATCHED BY SOURCE action to be executed, the RETURNING list was incorrectly evaluated using the original non-NULL source values. All source values returned by a WHEN NOT MATCHED BY SOURCE action should be NULL. Fix in ExecMergeMatched(), when we transition from MATCHED to NOT MATCHED BY SOURCE after a concurrent update, by building a new all-NULL slot for use in the RETURNING projection. Backpatch to v17, where WHEN NOT MATCHED BY SOURCE support was added to MERGE. Bug: #19912 Reported-by: Chunling Qin <303677365@qq.com> Author: Tender Wang <tndrwang@gmail.com> Author: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/19912-ceea4a1c0a7dd41c%40postgresql.org Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/b291954ea5a4855ded56c334859d7de9fea372eb Modified Files -------------- src/backend/executor/nodeModifyTable.c | 37 ++++++- src/test/isolation/expected/merge-not-matched.out | 113 ++++++++++++++++++++++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/merge-not-matched.spec | 49 ++++++++++ 4 files changed, 197 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix stale source values in MERGE after a concurrent update. @ 2026-11-21 12:17 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-11-21 12:17 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale source values in MERGE after a concurrent update. When a MERGE has WHEN NOT MATCHED BY SOURCE actions and an initially matched target row is concurrently updated so that it no longer satisfies the join condition, causing a WHEN NOT MATCHED BY SOURCE action to be executed, the RETURNING list was incorrectly evaluated using the original non-NULL source values. All source values returned by a WHEN NOT MATCHED BY SOURCE action should be NULL. Fix in ExecMergeMatched(), when we transition from MATCHED to NOT MATCHED BY SOURCE after a concurrent update, by building a new all-NULL slot for use in the RETURNING projection. Backpatch to v17, where WHEN NOT MATCHED BY SOURCE support was added to MERGE. Bug: #19912 Reported-by: Chunling Qin <303677365@qq.com> Author: Tender Wang <tndrwang@gmail.com> Author: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/19912-ceea4a1c0a7dd41c%40postgresql.org Backpatch-through: 17 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9cd821c6532e900cae1b2d2675a3d3c774c38216 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 37 ++++++- src/test/isolation/expected/merge-not-matched.out | 113 ++++++++++++++++++++++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/merge-not-matched.spec | 49 ++++++++++ 4 files changed, 197 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix stale source values in MERGE after a concurrent update. @ 2026-11-21 12:17 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-11-21 12:17 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale source values in MERGE after a concurrent update. When a MERGE has WHEN NOT MATCHED BY SOURCE actions and an initially matched target row is concurrently updated so that it no longer satisfies the join condition, causing a WHEN NOT MATCHED BY SOURCE action to be executed, the RETURNING list was incorrectly evaluated using the original non-NULL source values. All source values returned by a WHEN NOT MATCHED BY SOURCE action should be NULL. Fix in ExecMergeMatched(), when we transition from MATCHED to NOT MATCHED BY SOURCE after a concurrent update, by building a new all-NULL slot for use in the RETURNING projection. Backpatch to v17, where WHEN NOT MATCHED BY SOURCE support was added to MERGE. Bug: #19912 Reported-by: Chunling Qin <303677365@qq.com> Author: Tender Wang <tndrwang@gmail.com> Author: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/19912-ceea4a1c0a7dd41c%40postgresql.org Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/188ba23bc715f6949ed8d29fe96d4354ddd84056 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 37 ++++++- src/test/isolation/expected/merge-not-matched.out | 113 ++++++++++++++++++++++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/merge-not-matched.spec | 49 ++++++++++ 4 files changed, 197 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix stale source values in MERGE after a concurrent update. @ 2026-11-21 12:17 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Dean Rasheed @ 2026-11-21 12:17 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale source values in MERGE after a concurrent update. When a MERGE has WHEN NOT MATCHED BY SOURCE actions and an initially matched target row is concurrently updated so that it no longer satisfies the join condition, causing a WHEN NOT MATCHED BY SOURCE action to be executed, the RETURNING list was incorrectly evaluated using the original non-NULL source values. All source values returned by a WHEN NOT MATCHED BY SOURCE action should be NULL. Fix in ExecMergeMatched(), when we transition from MATCHED to NOT MATCHED BY SOURCE after a concurrent update, by building a new all-NULL slot for use in the RETURNING projection. Backpatch to v17, where WHEN NOT MATCHED BY SOURCE support was added to MERGE. Bug: #19912 Reported-by: Chunling Qin <303677365@qq.com> Author: Tender Wang <tndrwang@gmail.com> Author: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/19912-ceea4a1c0a7dd41c%40postgresql.org Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/590515f95a776c0ff2969a22bad0ecc8a8dc9193 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 37 ++++++- src/test/isolation/expected/merge-not-matched.out | 113 ++++++++++++++++++++++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/merge-not-matched.spec | 49 ++++++++++ 4 files changed, 197 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-11-21 12:17 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-21 12:17 pgsql: Fix stale source values in MERGE after a concurrent update. Dean Rasheed <dean.a.rasheed@gmail.com> 2026-11-21 12:17 pgsql: Fix stale source values in MERGE after a concurrent update. Dean Rasheed <dean.a.rasheed@gmail.com> 2026-11-21 12:17 pgsql: Fix stale source values in MERGE after a concurrent update. Dean Rasheed <dean.a.rasheed@gmail.com> 2026-11-21 12:17 pgsql: Fix stale source values in MERGE after a concurrent update. Dean Rasheed <dean.a.rasheed@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox