|
251 | 251 | $node_B->wait_for_catchup($subname_AB2);
|
252 | 252 |
|
253 | 253 | # clear the operations done by this test
|
254 |
| -$node_A->safe_psql('postgres', "DROP TABLE tab_new"); |
255 |
| -$node_B->safe_psql('postgres', "DROP TABLE tab_new"); |
256 |
| -$node_A->safe_psql('postgres', "DROP SUBSCRIPTION $subname_AB2"); |
| 254 | +$node_A->safe_psql( |
| 255 | + 'postgres', qq( |
| 256 | +DROP TABLE tab_new; |
| 257 | +DROP SUBSCRIPTION $subname_AB2; |
| 258 | +DROP SUBSCRIPTION $subname_AB; |
| 259 | +DROP PUBLICATION tap_pub_A; |
| 260 | +)); |
| 261 | +$node_B->safe_psql( |
| 262 | + 'postgres', qq( |
| 263 | +DROP TABLE tab_new; |
| 264 | +DROP SUBSCRIPTION $subname_BA; |
| 265 | +DROP PUBLICATION tap_pub_B; |
| 266 | +)); |
| 267 | + |
| 268 | +############################################################################### |
| 269 | +# Specifying origin = NONE and copy_data = on must raise WARNING if we subscribe |
| 270 | +# to a partitioned table and this table contains any remotely originated data. |
| 271 | +# |
| 272 | +# node_B |
| 273 | +# __________________________ |
| 274 | +# | tab_main | --------------> node_C (tab_main) |
| 275 | +# |__________________________| |
| 276 | +# | tab_part1 | tab_part2 | <-------------- node_A (tab_part2) |
| 277 | +# |____________|_____________| |
| 278 | +# | tab_part2_1 | |
| 279 | +# |_____________| |
| 280 | +# |
| 281 | +# node_B |
| 282 | +# __________________________ |
| 283 | +# | tab_main | |
| 284 | +# |__________________________| |
| 285 | +# | tab_part1 | tab_part2 | <-------------- node_A (tab_part2) |
| 286 | +# |____________|_____________| |
| 287 | +# | tab_part2_1 | --------------> node_C (tab_part2_1) |
| 288 | +# |_____________| |
| 289 | +############################################################################### |
| 290 | + |
| 291 | +# create a table on node A which will act as a source for a partition on node B |
| 292 | +$node_A->safe_psql( |
| 293 | + 'postgres', qq( |
| 294 | +CREATE TABLE tab_part2(a int); |
| 295 | +CREATE PUBLICATION tap_pub_A FOR TABLE tab_part2; |
| 296 | +)); |
| 297 | + |
| 298 | +# create a partition table on node B |
| 299 | +$node_B->safe_psql( |
| 300 | + 'postgres', qq( |
| 301 | +CREATE TABLE tab_main(a int) PARTITION BY RANGE(a); |
| 302 | +CREATE TABLE tab_part1 PARTITION OF tab_main FOR VALUES FROM (0) TO (5); |
| 303 | +CREATE TABLE tab_part2(a int) PARTITION BY RANGE(a); |
| 304 | +CREATE TABLE tab_part2_1 PARTITION OF tab_part2 FOR VALUES FROM (5) TO (10); |
| 305 | +ALTER TABLE tab_main ATTACH PARTITION tab_part2 FOR VALUES FROM (5) to (10); |
| 306 | +CREATE SUBSCRIPTION tap_sub_A_B CONNECTION '$node_A_connstr' PUBLICATION tap_pub_A; |
| 307 | +)); |
| 308 | + |
| 309 | +# create a table on node C |
| 310 | +$node_C->safe_psql( |
| 311 | + 'postgres', qq( |
| 312 | +CREATE TABLE tab_main(a int); |
| 313 | +CREATE TABLE tab_part2_1(a int); |
| 314 | +)); |
| 315 | + |
| 316 | +# create a logical replication setup between node B and node C with |
| 317 | +# subscription on node C having origin = NONE and copy_data = on |
| 318 | +$node_B->safe_psql( |
| 319 | + 'postgres', qq( |
| 320 | +CREATE PUBLICATION tap_pub_B FOR TABLE tab_main WITH (publish_via_partition_root); |
| 321 | +CREATE PUBLICATION tap_pub_B_2 FOR TABLE tab_part2_1; |
| 322 | +)); |
| 323 | + |
| 324 | +($result, $stdout, $stderr) = $node_C->psql( |
| 325 | + 'postgres', " |
| 326 | + CREATE SUBSCRIPTION tap_sub_B_C CONNECTION '$node_B_connstr' PUBLICATION tap_pub_B WITH (origin = none, copy_data = on); |
| 327 | +"); |
| 328 | + |
| 329 | +# A warning must be logged as a partition 'tab_part2' in node B is subscribed to |
| 330 | +# node A so partition 'tab_part2' can have remotely originated data |
| 331 | +like( |
| 332 | + $stderr, |
| 333 | + qr/WARNING: ( [A-Z0-9]+:)? subscription "tap_sub_b_c" requested copy_data with origin = NONE but might copy data that had a different origin/, |
| 334 | + "Create subscription with origin = none and copy_data when the publisher's partition is subscribing from different origin" |
| 335 | +); |
| 336 | +$node_C->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_B_C"); |
| 337 | + |
| 338 | +($result, $stdout, $stderr) = $node_C->psql( |
| 339 | + 'postgres', " |
| 340 | + CREATE SUBSCRIPTION tap_sub_B_C CONNECTION '$node_B_connstr' PUBLICATION tap_pub_B_2 WITH (origin = none, copy_data = on); |
| 341 | +"); |
| 342 | + |
| 343 | +# A warning must be logged as ancestor of table 'tab_part2_1' in node B is |
| 344 | +# subscribed to node A so table 'tab_part2_1' can have remotely originated |
| 345 | +# data |
| 346 | +like( |
| 347 | + $stderr, |
| 348 | + qr/WARNING: ( [A-Z0-9]+:)? subscription "tap_sub_b_c" requested copy_data with origin = NONE but might copy data that had a different origin/, |
| 349 | + "Create subscription with origin = none and copy_data when the publisher's ancestor is subscribing from different origin" |
| 350 | +); |
| 351 | + |
| 352 | +# clear the operations done by this test |
| 353 | +$node_C->safe_psql( |
| 354 | + 'postgres', qq( |
| 355 | +DROP SUBSCRIPTION tap_sub_B_C; |
| 356 | +DROP TABLE tab_main; |
| 357 | +DROP TABLE tab_part2_1; |
| 358 | +)); |
| 359 | +$node_B->safe_psql( |
| 360 | + 'postgres', qq( |
| 361 | +DROP SUBSCRIPTION tap_sub_A_B; |
| 362 | +DROP PUBLICATION tap_pub_B; |
| 363 | +DROP PUBLICATION tap_pub_B_2; |
| 364 | +DROP TABLE tab_main; |
| 365 | +)); |
| 366 | +$node_A->safe_psql( |
| 367 | + 'postgres', qq( |
| 368 | +DROP PUBLICATION tap_pub_A; |
| 369 | +DROP TABLE tab_part2; |
| 370 | +)); |
257 | 371 |
|
258 | 372 | # shutdown
|
259 | 373 | $node_B->stop('fast');
|
|
0 commit comments