Fix replica identity checks for MERGE command on published table.
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
From: "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-04-11T05:24:13Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-replica-identity-check-for-MERGE-command.patch (application/octet-stream) patch v1-0001
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
Commits
-
Fix replica identity check for MERGE.
- 5481cc332b0f 15.15 landed
- 421d7a157985 16.11 landed
- 76f45be9315b 17.7 landed
- 311340f17863 18.0 landed
- fc6600fc1cd1 19 (unreleased) landed
-
Fix replica identity check for INSERT ON CONFLICT DO UPDATE.
- 0610b843c971 13.23 landed
- 5fd569ef2d62 14.20 landed
- 451b22efd9ac 15.15 landed
- 0c4d5a45dbd7 16.11 landed
- 0b934d3994ff 17.7 landed
- 344662848ac1 18.0 landed
- 5386bfb9c1f5 19 (unreleased) landed