pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix transition tables for MERGE with cross-partition UPDATEs.
Date: Wed, 18 Nov 2026 16:05:53 +0000
Message-ID: <E1xTiAS-00000000GQW-1zV2@gemulon.postgresql.org> (raw)

Fix transition tables for MERGE with cross-partition UPDATEs.

When a MERGE UPDATE action moved a row between partitions, the old and
new rows were not included in the transition tables of AFTER UPDATE
statement triggers, and could instead be incorrectly included in the
transition tables of AFTER INSERT and AFTER DELETE statement triggers.

Fix by capturing both halves of a cross-partition MERGE UPDATE action
in the UPDATE transition tables and exclude them from the DELETE and
INSERT transition tables, as we do for a plain UPDATE.

Backpatch to v15, where MERGE was introduced.

Reported-by: Michael Ries <mries@salesforce.com>
Reported-by: Tender Wang <tndrwang@gmail.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/CAKWDHLgETF86qEW40HcEzMgn5DdmS6yR-nSYwemXF7zFGrU%2BsQ%40mail.gmail.com
Discussion: https://postgr.es/m/CAHewXNk8MgaFMD87s%3DxHeguzmErEjsqeroxrMyQbKyXwG5eocw%40mail.gmail.com
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1e676702cac06e3d51942cc69efc282663515fba

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 69 ++++++++++++++++------------------
src/test/regress/expected/triggers.out | 31 +++++++++++++++
src/test/regress/sql/triggers.sql      | 30 +++++++++++++++
3 files changed, 94 insertions(+), 36 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xTiAS-00000000GQW-1zV2@gemulon.postgresql.org>
Permalink:  ../E1xTiAS-00000000GQW-1zV2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xTiAS-00000000GQW-1zV2@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Fix transition tables for MERGE with cross-partition UPDATEs.
  In-Reply-To: <E1xTiAS-00000000GQW-1zV2@gemulon.postgresql.org>
  References: <E1xTiAS-00000000GQW-1zV2@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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