|
3 | 3 | use warnings;
|
4 | 4 | use PostgresNode;
|
5 | 5 | use TestLib; |
6 |
| -use Test::More tests => 5; |
| 6 | +use Test::More tests => 6; |
7 | 7 |
|
8 | 8 | # Bug #15114
|
9 | 9 |
|
|
177 | 177 |
|
178 | 178 | $node_publisher->stop('fast');
|
179 | 179 | $node_subscriber->stop('fast');
|
| 180 | + |
| 181 | +# The bug was that when the REPLICA IDENTITY FULL is used with dropped columns, |
| 182 | +# we fail to apply updates and deletes |
| 183 | +my $node_publisher_d_cols = get_new_node('node_publisher_d_cols'); |
| 184 | +$node_publisher_d_cols->init(allows_streaming => 'logical'); |
| 185 | +$node_publisher_d_cols->start; |
| 186 | + |
| 187 | +my $node_subscriber_d_cols = get_new_node('node_subscriber_d_cols'); |
| 188 | +$node_subscriber_d_cols->init(allows_streaming => 'logical'); |
| 189 | +$node_subscriber_d_cols->start; |
| 190 | + |
| 191 | +$node_publisher_d_cols->safe_psql( |
| 192 | + 'postgres', qq( |
| 193 | + CREATE TABLE dropped_cols (a int, b_drop int, c int); |
| 194 | + ALTER TABLE dropped_cols REPLICA IDENTITY FULL; |
| 195 | + CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols; |
| 196 | + -- some initial data |
| 197 | + INSERT INTO dropped_cols VALUES (1, 1, 1); |
| 198 | +)); |
| 199 | + |
| 200 | +$node_subscriber_d_cols->safe_psql( |
| 201 | + 'postgres', qq( |
| 202 | + CREATE TABLE dropped_cols (a int, b_drop int, c int); |
| 203 | +)); |
| 204 | + |
| 205 | +my $publisher_connstr_d_cols = |
| 206 | + $node_publisher_d_cols->connstr . ' dbname=postgres'; |
| 207 | +$node_subscriber_d_cols->safe_psql('postgres', |
| 208 | + "CREATE SUBSCRIPTION sub_dropped_cols CONNECTION '$publisher_connstr_d_cols application_name=sub_dropped_cols' PUBLICATION pub_dropped_cols" |
| 209 | +); |
| 210 | +$node_subscriber_d_cols->wait_for_subscription_sync($node_publisher_d_cols, |
| 211 | + 'sub_dropped_cols'); |
| 212 | + |
| 213 | +$node_publisher_d_cols->safe_psql( |
| 214 | + 'postgres', qq( |
| 215 | + ALTER TABLE dropped_cols DROP COLUMN b_drop; |
| 216 | +)); |
| 217 | +$node_subscriber_d_cols->safe_psql( |
| 218 | + 'postgres', qq( |
| 219 | + ALTER TABLE dropped_cols DROP COLUMN b_drop; |
| 220 | +)); |
| 221 | + |
| 222 | +$node_publisher_d_cols->safe_psql( |
| 223 | + 'postgres', qq( |
| 224 | + UPDATE dropped_cols SET a = 100; |
| 225 | +)); |
| 226 | +$node_publisher_d_cols->wait_for_catchup('sub_dropped_cols'); |
| 227 | + |
| 228 | +is( $node_subscriber_d_cols->safe_psql( |
| 229 | + 'postgres', "SELECT count(*) FROM dropped_cols WHERE a = 100"), |
| 230 | + qq(1), |
| 231 | + 'replication with RI FULL and dropped columns'); |
| 232 | + |
| 233 | +$node_publisher_d_cols->stop('fast'); |
| 234 | +$node_subscriber_d_cols->stop('fast'); |
0 commit comments