diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c index b000645d48b..6014f2e2482 100644 --- a/src/backend/executor/execReplication.c +++ b/src/backend/executor/execReplication.c @@ -569,6 +569,13 @@ CheckCmdReplicaIdentity(Relation rel, CmdType cmd) { PublicationDesc pubdesc; + /* + * Skip checking the replica identity for partitioned tables, because the + * operations are actually performed on the leaf partitions. + */ + if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) + return; + /* We only need to do checks for UPDATE and DELETE. */ if (cmd != CMD_UPDATE && cmd != CMD_DELETE) return; diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index 428c1f16c7c..e6e082de2f5 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -214,6 +214,8 @@ ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted; Tables: "public.testpub_parted" +-- works despite missing REPLICA IDENTITY, because no actual update happened +UPDATE testpub_parted SET a = 1 WHERE false; -- should now fail, because parent's publication replicates updates UPDATE testpub_parted1 SET a = 1; ERROR: cannot update table "testpub_parted1" because it does not have a replica identity and publishes updates diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql index 9eb86fd54f8..a56387edee3 100644 --- a/src/test/regress/sql/publication.sql +++ b/src/test/regress/sql/publication.sql @@ -119,6 +119,8 @@ UPDATE testpub_parted1 SET a = 1; -- only parent is listed as being in publication, not the partition ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted; \dRp+ testpub_forparted +-- works despite missing REPLICA IDENTITY, because no actual update happened +UPDATE testpub_parted SET a = 1 WHERE false; -- should now fail, because parent's publication replicates updates UPDATE testpub_parted1 SET a = 1; ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1;