Fix partition table's REPLICA IDENTITY checking on the subscriber.
authorAmit Kapila <akapila@postgresql.org>
Tue, 21 Jun 2022 02:18:02 +0000 (07:48 +0530)
committerAmit Kapila <akapila@postgresql.org>
Tue, 21 Jun 2022 02:35:31 +0000 (08:05 +0530)
commit5f113d60e9982b8d5a8c9b2e85dc82330d3c683a
treecb7a6f41f007d763f5fcf1148c31010f78c1b047
parent1f9a7738eb84f341a9b39689f33c887d1ef39487
Fix partition table's REPLICA IDENTITY checking on the subscriber.

In logical replication, we will check if the target table on the
subscriber is updatable by comparing the replica identity of the table on
the publisher with the table on the subscriber. When the target table is a
partitioned table, we only check its replica identity but not for the
partition tables. This leads to assertion failure while applying changes
for update/delete as we expect those to succeed only when the
corresponding partition table has a primary key or has a replica
identity defined.

Fix it by checking the replica identity of the partition table while
applying changes.

Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
src/backend/replication/logical/relation.c
src/backend/replication/logical/worker.c
src/test/subscription/t/013_partition.pl