From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix replica identity check for INSERT ON CONFLICT DO UPDATE. |
Date: | 2025-09-04 10:40:00 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Tested-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/OS3PR01MB57180C87E43A679A730482DF94B62@OS3PR01MB5718.jpnprd01.prod.outlook.com
Backpatch-through: 13
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/5386bfb9c1f566887d084e4ea2e350e7efd188c1
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Rasheed | 2025-09-04 10:40:01 | pgsql: Fix replica identity check for INSERT ON CONFLICT DO UPDATE. |
Previous Message | Michael Paquier | 2025-09-03 23:35:12 | pgsql: Fix incorrect comment in pgstat_backend.c |