|
6 | 6 | use warnings; |
7 | 7 | use PostgresNode; |
8 | 8 | use TestLib; |
9 | | -use Test::More tests => 31; |
| 9 | +use Test::More tests => 32; |
10 | 10 |
|
11 | 11 | # Initialize publisher node |
12 | 12 | my $node_publisher = get_new_node('publisher'); |
|
50 | 50 | $node_publisher->safe_psql('postgres', |
51 | 51 | "ALTER TABLE tab_nothing REPLICA IDENTITY NOTHING"); |
52 | 52 |
|
| 53 | +# Replicate the changes without replica identity index |
| 54 | +$node_publisher->safe_psql('postgres', "CREATE TABLE tab_no_replidentity_index(c1 int)"); |
| 55 | +$node_publisher->safe_psql('postgres', "CREATE INDEX idx_no_replidentity_index ON tab_no_replidentity_index(c1)"); |
| 56 | + |
53 | 57 | # Setup structure on subscriber |
54 | 58 | $node_subscriber->safe_psql('postgres', "CREATE TABLE tab_notrep (a int)"); |
55 | 59 | $node_subscriber->safe_psql('postgres', "CREATE TABLE tab_ins (a int)"); |
|
73 | 77 | "CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))" |
74 | 78 | ); |
75 | 79 |
|
| 80 | +# replication of the table without replica identity index |
| 81 | +$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_no_replidentity_index(c1 int)"); |
| 82 | +$node_subscriber->safe_psql('postgres', "CREATE INDEX idx_no_replidentity_index ON tab_no_replidentity_index(c1)"); |
| 83 | + |
76 | 84 | # Setup logical replication |
77 | 85 | my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; |
78 | 86 | $node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub"); |
79 | 87 | $node_publisher->safe_psql('postgres', |
80 | 88 | "CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)"); |
81 | 89 | $node_publisher->safe_psql('postgres', |
82 | | - "ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing, tab_full_pk" |
| 90 | + "ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include, tab_nothing, tab_full_pk, tab_no_replidentity_index" |
83 | 91 | ); |
84 | 92 | $node_publisher->safe_psql('postgres', |
85 | 93 | "ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins"); |
|
129 | 137 | "DELETE FROM tab_include WHERE a > 20"); |
130 | 138 | $node_publisher->safe_psql('postgres', "UPDATE tab_include SET a = -a"); |
131 | 139 |
|
| 140 | +$node_publisher->safe_psql('postgres', "INSERT INTO tab_no_replidentity_index VALUES(1)"); |
| 141 | + |
132 | 142 | $node_publisher->wait_for_catchup('tap_sub'); |
133 | 143 |
|
134 | 144 | $result = $node_subscriber->safe_psql('postgres', |
|
152 | 162 | is($result, qq(20|-20|-1), |
153 | 163 | 'check replicated changes with primary key index with included columns'); |
154 | 164 |
|
| 165 | +is($node_subscriber->safe_psql('postgres', q(SELECT c1 FROM tab_no_replidentity_index)), |
| 166 | + 1, "value replicated to subscriber without replica identity index"); |
| 167 | + |
155 | 168 | # insert some duplicate rows |
156 | 169 | $node_publisher->safe_psql('postgres', |
157 | 170 | "INSERT INTO tab_full SELECT generate_series(1,10)"); |
|
0 commit comments