Fix replica identity checks for MERGE command on published table. - Mailing list pgsql-hackers

From Zhijie Hou (Fujitsu)
Subject Fix replica identity checks for MERGE command on published table.
Date
Msg-id OS3PR01MB57180C87E43A679A730482DF94B62@OS3PR01MB5718.jpnprd01.prod.outlook.com
Whole thread Raw
Responses Re: Fix replica identity checks for MERGE command on published table.
List 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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Silence resource leaks alerts
Next
From: Tom Lane
Date:
Subject: Re: Silence resource leaks alerts