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 replica identity check for INSERT ON CONFLICT DO UPDATE.
Date: Thu, 04 Sep 2025 10:40:01 +0000
Message-ID: <E1uu7Np-000RtR-11@gemulon.postgresql.org> (raw)

Fix replica identity check for INSERT ON CONFLICT DO UPDATE.

If an INSERT has an ON CONFLICT DO UPDATE clause, the executor must
check that the target relation supports UPDATE as well as INSERT. In
particular, it must check that the target relation has a REPLICA
IDENTITY if it publishes updates. Formerly, it was not doing this
check, which could lead to silently breaking replication.

Fix by adding such a check to CheckValidResultRel(), which requires
adding a new onConflictAction argument. In back-branches, preserve ABI
compatibility by introducing a wrapper function with the original
signature.

Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Tested-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/OS3PR01MB57180C87E43A679A730482DF94B62@OS3PR01MB5718.jpnprd01.prod.outlook.com
Backpatch-through: 13

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/344662848ac15efc89e09b7d39662d7c71b30e06

Modified Files
--------------
src/backend/commands/copyfrom.c           |  2 +-
src/backend/executor/execMain.c           | 12 +++++++++++-
src/backend/executor/execPartition.c      |  9 +++++++--
src/backend/executor/nodeModifyTable.c    |  3 ++-
src/include/executor/executor.h           |  1 +
src/test/regress/expected/publication.out | 23 +++++++++++++++++++++++
src/test/regress/sql/publication.sql      | 27 +++++++++++++++++++++++++++
7 files changed, 72 insertions(+), 5 deletions(-)



view thread (7+ messages)

Message-ID: <E1uu7Np-000RtR-11@gemulon.postgresql.org>
Permalink:  ../E1uu7Np-000RtR-11@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uu7Np-000RtR-11@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix replica identity check for INSERT ON CONFLICT DO UPDATE.
  In-Reply-To: <E1uu7Np-000RtR-11@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