Fix replica identity checks for MERGE command on published table.

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix replica identity checks for MERGE command on published table.
Date: 2025-04-11 05:24:13
Message-ID: OS3PR01MB57180C87E43A679A730482DF94B62@OS3PR01MB5718.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While testing publication DDLs, I noticed an unexpected behavior where the
MERGE command can be executed on tables lacking replica identity keys,
regardless of whether they are part of a publication that publishes updates and
deletes.

Replication and application of the updates and deletes generated by MERGE
command require replica identity keys in the WAL record, which are essential
for the apply worker on the subscriber to find local tuples for updating or
deletion. Furthermore, publications require specific columns to be part of the
replica identity key if the table specifies a publication row filter or column
list.

We already have restrictions on executing UPDATE and DELETE commands for tables
without replica identity keys under similar conditions. So, I think the same
restriction should apply to the MERGE command as well.

Attached is a patch that implements this fix.

I have confirmed that this issue has existed since the introduction of the
MERGE command in PG15.

Best Regards,
Hou zj

Attachment Content-Type Size
v1-0001-Fix-replica-identity-check-for-MERGE-command.patch application/octet-stream 4.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-04-11 05:37:24 Re: Silence resource leaks alerts
Previous Message Michael Paquier 2025-04-11 05:08:50 Re: Silence resource leaks alerts