|
3 | 3 | use warnings;
|
4 | 4 | use PostgresNode;
|
5 | 5 | use TestLib;
|
6 |
| -use Test::More tests => 7; |
| 6 | +use Test::More tests => 8; |
7 | 7 |
|
8 | 8 | # Bug #15114
|
9 | 9 |
|
|
227 | 227 |
|
228 | 228 | $node_publisher->stop('fast');
|
229 | 229 | $node_subscriber->stop('fast');
|
| 230 | + |
| 231 | +# The bug was that when the REPLICA IDENTITY FULL is used with dropped columns, |
| 232 | +# we fail to apply updates and deletes |
| 233 | +my $node_publisher_d_cols = get_new_node('node_publisher_d_cols'); |
| 234 | +$node_publisher_d_cols->init(allows_streaming => 'logical'); |
| 235 | +$node_publisher_d_cols->start; |
| 236 | + |
| 237 | +my $node_subscriber_d_cols = get_new_node('node_subscriber_d_cols'); |
| 238 | +$node_subscriber_d_cols->init(allows_streaming => 'logical'); |
| 239 | +$node_subscriber_d_cols->start; |
| 240 | + |
| 241 | +$node_publisher_d_cols->safe_psql( |
| 242 | + 'postgres', qq( |
| 243 | + CREATE TABLE dropped_cols (a int, b_drop int, c int); |
| 244 | + ALTER TABLE dropped_cols REPLICA IDENTITY FULL; |
| 245 | + CREATE PUBLICATION pub_dropped_cols FOR TABLE dropped_cols; |
| 246 | + -- some initial data |
| 247 | + INSERT INTO dropped_cols VALUES (1, 1, 1); |
| 248 | +)); |
| 249 | + |
| 250 | +$node_subscriber_d_cols->safe_psql( |
| 251 | + 'postgres', qq( |
| 252 | + CREATE TABLE dropped_cols (a int, b_drop int, c int); |
| 253 | +)); |
| 254 | + |
| 255 | +my $publisher_connstr_d_cols = |
| 256 | + $node_publisher_d_cols->connstr . ' dbname=postgres'; |
| 257 | +$node_subscriber_d_cols->safe_psql('postgres', |
| 258 | + "CREATE SUBSCRIPTION sub_dropped_cols CONNECTION '$publisher_connstr_d_cols' PUBLICATION pub_dropped_cols" |
| 259 | +); |
| 260 | +$node_subscriber_d_cols->wait_for_subscription_sync; |
| 261 | + |
| 262 | +$node_publisher_d_cols->safe_psql( |
| 263 | + 'postgres', qq( |
| 264 | + ALTER TABLE dropped_cols DROP COLUMN b_drop; |
| 265 | +)); |
| 266 | +$node_subscriber_d_cols->safe_psql( |
| 267 | + 'postgres', qq( |
| 268 | + ALTER TABLE dropped_cols DROP COLUMN b_drop; |
| 269 | +)); |
| 270 | + |
| 271 | +$node_publisher_d_cols->safe_psql( |
| 272 | + 'postgres', qq( |
| 273 | + UPDATE dropped_cols SET a = 100; |
| 274 | +)); |
| 275 | +$node_publisher_d_cols->wait_for_catchup('sub_dropped_cols'); |
| 276 | + |
| 277 | +is( $node_subscriber_d_cols->safe_psql( |
| 278 | + 'postgres', "SELECT count(*) FROM dropped_cols WHERE a = 100"), |
| 279 | + qq(1), |
| 280 | + 'replication with RI FULL and dropped columns'); |
| 281 | + |
| 282 | +$node_publisher_d_cols->stop('fast'); |
| 283 | +$node_subscriber_d_cols->stop('fast'); |
0 commit comments