|
6 | 6 | use warnings;
|
7 | 7 | use PostgresNode;
|
8 | 8 | use TestLib;
|
9 |
| -use Test::More tests => 7; |
| 9 | +use Test::More tests => 8; |
10 | 10 |
|
11 | 11 | # Bug #15114
|
12 | 12 |
|
|
298 | 298 |
|
299 | 299 | $node_publisher->stop('fast');
|
300 | 300 | $node_subscriber->stop('fast');
|
| 301 | + |
| 302 | +# The bug was that when the REPLICA IDENTITY FULL is used with dropped columns, |
| 303 | +# we fail to apply updates and deletes |
| 304 | +my $node_publisher_d_cols = get_new_node('node_publisher_d_cols'); |
| 305 | +$node_publisher_d_cols->init(allows_streaming => 'logical'); |
| 306 | +$node_publisher_d_cols->start; |
| 307 | + |
| 308 | +my $node_subscriber_d_cols = get_new_node('node_subscriber_d_cols'); |
| 309 | +$node_subscriber_d_cols->init(allows_streaming => 'logical'); |
| 310 | +$node_subscriber_d_cols->start; |
| 311 | + |
| 312 | +$node_publisher_d_cols->safe_psql( |
| 313 | + 'postgres', qq( |
| 314 | + CREATE TABLE dropped_cols (a int, b_drop int, c int); |
| 315 | + ALTER TABLE dropped_cols REPLICA IDENTITY FULL; |
| 316 | + CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols; |
| 317 | + -- some initial data |
| 318 | + INSERT INTO dropped_cols VALUES (1, 1, 1); |
| 319 | +)); |
| 320 | + |
| 321 | +$node_subscriber_d_cols->safe_psql( |
| 322 | + 'postgres', qq( |
| 323 | + CREATE TABLE dropped_cols (a int, b_drop int, c int); |
| 324 | +)); |
| 325 | + |
| 326 | +my $publisher_connstr_d_cols = |
| 327 | + $node_publisher_d_cols->connstr . ' dbname=postgres'; |
| 328 | +$node_subscriber_d_cols->safe_psql('postgres', |
| 329 | + "CREATE SUBSCRIPTION sub_dropped_cols CONNECTION '$publisher_connstr_d_cols' PUBLICATION pub_dropped_cols" |
| 330 | +); |
| 331 | +$node_subscriber_d_cols->wait_for_subscription_sync; |
| 332 | + |
| 333 | +$node_publisher_d_cols->safe_psql( |
| 334 | + 'postgres', qq( |
| 335 | + ALTER TABLE dropped_cols DROP COLUMN b_drop; |
| 336 | +)); |
| 337 | +$node_subscriber_d_cols->safe_psql( |
| 338 | + 'postgres', qq( |
| 339 | + ALTER TABLE dropped_cols DROP COLUMN b_drop; |
| 340 | +)); |
| 341 | + |
| 342 | +$node_publisher_d_cols->safe_psql( |
| 343 | + 'postgres', qq( |
| 344 | + UPDATE dropped_cols SET a = 100; |
| 345 | +)); |
| 346 | +$node_publisher_d_cols->wait_for_catchup('sub_dropped_cols'); |
| 347 | + |
| 348 | +is( $node_subscriber_d_cols->safe_psql( |
| 349 | + 'postgres', "SELECT count(*) FROM dropped_cols WHERE a = 100"), |
| 350 | + qq(1), |
| 351 | + 'replication with RI FULL and dropped columns'); |
| 352 | + |
| 353 | +$node_publisher_d_cols->stop('fast'); |
| 354 | +$node_subscriber_d_cols->stop('fast'); |
0 commit comments