mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
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
This commit is contained in:
@@ -6,7 +6,7 @@ use strict;
|
||||
use warnings;
|
||||
use PostgresNode;
|
||||
use TestLib;
|
||||
use Test::More tests => 70;
|
||||
use Test::More tests => 71;
|
||||
|
||||
# setup
|
||||
|
||||
@@ -856,3 +856,17 @@ $node_publisher->wait_for_catchup('sub2');
|
||||
$result = $node_subscriber2->safe_psql('postgres',
|
||||
"SELECT a, b, c FROM tab5 ORDER BY 1");
|
||||
is($result, qq(3||1), 'updates of tab5 replicated correctly after altering table on publisher');
|
||||
|
||||
# Test that replication works correctly as long as the leaf partition
|
||||
# has the necessary REPLICA IDENTITY, even though the actual target
|
||||
# partitioned table does not.
|
||||
$node_subscriber2->safe_psql('postgres',
|
||||
"ALTER TABLE tab5 REPLICA IDENTITY NOTHING");
|
||||
|
||||
$node_publisher->safe_psql('postgres', "UPDATE tab5 SET a = 4 WHERE a = 3");
|
||||
|
||||
$node_publisher->wait_for_catchup('sub2');
|
||||
|
||||
$result = $node_subscriber2->safe_psql('postgres',
|
||||
"SELECT a, b, c FROM tab5_1 ORDER BY 1");
|
||||
is($result, qq(4||1), 'updates of tab5 replicated correctly');
|
||||
|
Reference in New Issue
Block a user