|
204 | 204 | $node_B->wait_for_catchup($subname_AB2);
|
205 | 205 |
|
206 | 206 | # clear the operations done by this test
|
207 |
| -$node_A->safe_psql('postgres', "DROP TABLE tab_new"); |
208 |
| -$node_B->safe_psql('postgres', "DROP TABLE tab_new"); |
209 |
| -$node_A->safe_psql('postgres', "DROP SUBSCRIPTION $subname_AB2"); |
| 207 | +$node_A->safe_psql( |
| 208 | + 'postgres', qq( |
| 209 | +DROP TABLE tab_new; |
| 210 | +DROP SUBSCRIPTION $subname_AB2; |
| 211 | +DROP SUBSCRIPTION $subname_AB; |
| 212 | +DROP PUBLICATION tap_pub_A; |
| 213 | +)); |
| 214 | +$node_B->safe_psql( |
| 215 | + 'postgres', qq( |
| 216 | +DROP TABLE tab_new; |
| 217 | +DROP SUBSCRIPTION $subname_BA; |
| 218 | +DROP PUBLICATION tap_pub_B; |
| 219 | +)); |
| 220 | + |
| 221 | +############################################################################### |
| 222 | +# Specifying origin = NONE and copy_data = on must raise WARNING if we subscribe |
| 223 | +# to a partitioned table and this table contains any remotely originated data. |
| 224 | +# |
| 225 | +# node_B |
| 226 | +# __________________________ |
| 227 | +# | tab_main | --------------> node_C (tab_main) |
| 228 | +# |__________________________| |
| 229 | +# | tab_part1 | tab_part2 | <-------------- node_A (tab_part2) |
| 230 | +# |____________|_____________| |
| 231 | +# | tab_part2_1 | |
| 232 | +# |_____________| |
| 233 | +# |
| 234 | +# node_B |
| 235 | +# __________________________ |
| 236 | +# | tab_main | |
| 237 | +# |__________________________| |
| 238 | +# | tab_part1 | tab_part2 | <-------------- node_A (tab_part2) |
| 239 | +# |____________|_____________| |
| 240 | +# | tab_part2_1 | --------------> node_C (tab_part2_1) |
| 241 | +# |_____________| |
| 242 | +############################################################################### |
| 243 | + |
| 244 | +# create a table on node A which will act as a source for a partition on node B |
| 245 | +$node_A->safe_psql( |
| 246 | + 'postgres', qq( |
| 247 | +CREATE TABLE tab_part2(a int); |
| 248 | +CREATE PUBLICATION tap_pub_A FOR TABLE tab_part2; |
| 249 | +)); |
| 250 | + |
| 251 | +# create a partition table on node B |
| 252 | +$node_B->safe_psql( |
| 253 | + 'postgres', qq( |
| 254 | +CREATE TABLE tab_main(a int) PARTITION BY RANGE(a); |
| 255 | +CREATE TABLE tab_part1 PARTITION OF tab_main FOR VALUES FROM (0) TO (5); |
| 256 | +CREATE TABLE tab_part2(a int) PARTITION BY RANGE(a); |
| 257 | +CREATE TABLE tab_part2_1 PARTITION OF tab_part2 FOR VALUES FROM (5) TO (10); |
| 258 | +ALTER TABLE tab_main ATTACH PARTITION tab_part2 FOR VALUES FROM (5) to (10); |
| 259 | +CREATE SUBSCRIPTION tap_sub_A_B CONNECTION '$node_A_connstr' PUBLICATION tap_pub_A; |
| 260 | +)); |
| 261 | + |
| 262 | +# create a table on node C |
| 263 | +$node_C->safe_psql( |
| 264 | + 'postgres', qq( |
| 265 | +CREATE TABLE tab_main(a int); |
| 266 | +CREATE TABLE tab_part2_1(a int); |
| 267 | +)); |
| 268 | + |
| 269 | +# create a logical replication setup between node B and node C with |
| 270 | +# subscription on node C having origin = NONE and copy_data = on |
| 271 | +$node_B->safe_psql( |
| 272 | + 'postgres', qq( |
| 273 | +CREATE PUBLICATION tap_pub_B FOR TABLE tab_main WITH (publish_via_partition_root); |
| 274 | +CREATE PUBLICATION tap_pub_B_2 FOR TABLE tab_part2_1; |
| 275 | +)); |
| 276 | + |
| 277 | +($result, $stdout, $stderr) = $node_C->psql( |
| 278 | + 'postgres', " |
| 279 | + CREATE SUBSCRIPTION tap_sub_B_C CONNECTION '$node_B_connstr' PUBLICATION tap_pub_B WITH (origin = none, copy_data = on); |
| 280 | +"); |
| 281 | + |
| 282 | +# A warning must be logged as a partition 'tab_part2' in node B is subscribed to |
| 283 | +# node A so partition 'tab_part2' can have remotely originated data |
| 284 | +like( |
| 285 | + $stderr, |
| 286 | + 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/, |
| 287 | + "Create subscription with origin = none and copy_data when the publisher's partition is subscribing from different origin" |
| 288 | +); |
| 289 | +$node_C->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_B_C"); |
| 290 | + |
| 291 | +($result, $stdout, $stderr) = $node_C->psql( |
| 292 | + 'postgres', " |
| 293 | + CREATE SUBSCRIPTION tap_sub_B_C CONNECTION '$node_B_connstr' PUBLICATION tap_pub_B_2 WITH (origin = none, copy_data = on); |
| 294 | +"); |
| 295 | + |
| 296 | +# A warning must be logged as ancestor of table 'tab_part2_1' in node B is |
| 297 | +# subscribed to node A so table 'tab_part2_1' can have remotely originated |
| 298 | +# data |
| 299 | +like( |
| 300 | + $stderr, |
| 301 | + 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/, |
| 302 | + "Create subscription with origin = none and copy_data when the publisher's ancestor is subscribing from different origin" |
| 303 | +); |
| 304 | + |
| 305 | +# clear the operations done by this test |
| 306 | +$node_C->safe_psql( |
| 307 | + 'postgres', qq( |
| 308 | +DROP SUBSCRIPTION tap_sub_B_C; |
| 309 | +DROP TABLE tab_main; |
| 310 | +DROP TABLE tab_part2_1; |
| 311 | +)); |
| 312 | +$node_B->safe_psql( |
| 313 | + 'postgres', qq( |
| 314 | +DROP SUBSCRIPTION tap_sub_A_B; |
| 315 | +DROP PUBLICATION tap_pub_B; |
| 316 | +DROP PUBLICATION tap_pub_B_2; |
| 317 | +DROP TABLE tab_main; |
| 318 | +)); |
| 319 | +$node_A->safe_psql( |
| 320 | + 'postgres', qq( |
| 321 | +DROP PUBLICATION tap_pub_A; |
| 322 | +DROP TABLE tab_part2; |
| 323 | +)); |
210 | 324 |
|
211 | 325 | # shutdown
|
212 | 326 | $node_B->stop('fast');
|
|
0 commit comments