diff options
| author | Tom Lane | 2021-05-12 17:14:10 +0000 |
|---|---|---|
| committer | Tom Lane | 2021-05-12 17:14:10 +0000 |
| commit | def5b065ff22a16a80084587613599fe15627213 (patch) | |
| tree | 13f424449b7fb90c85659071b6adf4e27ae6d272 /src/test/subscription | |
| parent | e6ccd1ce1644d1b40b7981f8bc172394de524f99 (diff) | |
Initial pgindent and pgperltidy run for v14.
Also "make reformat-dat-files".
The only change worthy of note is that pgindent messed up the formatting
of launcher.c's struct LogicalRepWorkerId, which led me to notice that
that struct wasn't used at all anymore, so I just took it out.
Diffstat (limited to 'src/test/subscription')
| -rw-r--r-- | src/test/subscription/t/001_rep_changes.pl | 20 | ||||
| -rw-r--r-- | src/test/subscription/t/004_sync.pl | 11 | ||||
| -rw-r--r-- | src/test/subscription/t/010_truncate.pl | 3 | ||||
| -rw-r--r-- | src/test/subscription/t/015_stream.pl | 44 | ||||
| -rw-r--r-- | src/test/subscription/t/016_stream_subxact.pl | 27 | ||||
| -rw-r--r-- | src/test/subscription/t/017_stream_ddl.pl | 46 | ||||
| -rw-r--r-- | src/test/subscription/t/018_stream_subxact_abort.pl | 41 | ||||
| -rw-r--r-- | src/test/subscription/t/019_stream_subxact_ddl_abort.pl | 26 | ||||
| -rw-r--r-- | src/test/subscription/t/020_messages.pl | 15 | ||||
| -rw-r--r-- | src/test/subscription/t/100_bugs.pl | 7 |
10 files changed, 154 insertions, 86 deletions
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index 46a88b6d305..1f654ee6afc 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -164,7 +164,8 @@ $node_publisher->safe_psql('postgres', # from the publication. $result = $node_subscriber->safe_psql('postgres', "SELECT count(*), min(a), max(a) FROM tab_ins"); -is($result, qq(1052|1|1002), 'check rows on subscriber before table drop from publication'); +is($result, qq(1052|1|1002), + 'check rows on subscriber before table drop from publication'); # Drop the table from publication $node_publisher->safe_psql('postgres', @@ -179,7 +180,8 @@ $node_publisher->wait_for_catchup('tap_sub'); # publication, so row count should remain the same. $result = $node_subscriber->safe_psql('postgres', "SELECT count(*), min(a), max(a) FROM tab_ins"); -is($result, qq(1052|1|1002), 'check rows on subscriber after table drop from publication'); +is($result, qq(1052|1|1002), + 'check rows on subscriber after table drop from publication'); # Delete the inserted row in publisher $node_publisher->safe_psql('postgres', "DELETE FROM tab_ins WHERE a = 8888"); @@ -205,7 +207,8 @@ $node_subscriber->safe_psql('postgres', "CREATE TABLE temp2 (a int)"); # Setup logical replication that will only be used for this test $node_publisher->safe_psql('postgres', - "CREATE PUBLICATION tap_pub_temp1 FOR TABLE temp1 WITH (publish = insert)"); + "CREATE PUBLICATION tap_pub_temp1 FOR TABLE temp1 WITH (publish = insert)" +); $node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub_temp2 FOR TABLE temp2"); $node_subscriber->safe_psql('postgres', @@ -221,9 +224,10 @@ $node_subscriber->poll_query_until('postgres', $synced_query) or die "Timed out while waiting for subscriber to synchronize data"; # Subscriber table will have no rows initially -$result = $node_subscriber->safe_psql('postgres', - "SELECT count(*) FROM temp1"); -is($result, qq(0), 'check initial rows on subscriber with multiple publications'); +$result = + $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM temp1"); +is($result, qq(0), + 'check initial rows on subscriber with multiple publications'); # Insert a row into the table that's part of first publication in subscriber # list of publications. @@ -232,8 +236,8 @@ $node_publisher->safe_psql('postgres', "INSERT INTO temp1 VALUES (1)"); $node_publisher->wait_for_catchup('tap_sub_temp1'); # Subscriber should receive the inserted row -$result = $node_subscriber->safe_psql('postgres', - "SELECT count(*) FROM temp1"); +$result = + $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM temp1"); is($result, qq(1), 'check rows on subscriber with multiple publications'); # Drop subscription as we don't need it anymore diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl index f4afdc241d5..b3c91af21d1 100644 --- a/src/test/subscription/t/004_sync.pl +++ b/src/test/subscription/t/004_sync.pl @@ -161,17 +161,20 @@ $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub"); # at this time. Recreate the subscription which will do the initial copy of # the table again and fails due to unique constraint violation. $node_subscriber->safe_psql('postgres', - "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub"); + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub" +); $result = $node_subscriber->poll_query_until('postgres', $started_query) - or die "Timed out while waiting for subscriber to start sync"; + or die "Timed out while waiting for subscriber to start sync"; # DROP SUBSCRIPTION must clean up slots on the publisher side when the # subscriber is stuck on data copy for constraint violation. $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub"); -$result = $node_publisher->safe_psql('postgres', "SELECT count(*) FROM pg_replication_slots"); -is($result, qq(0), 'DROP SUBSCRIPTION during error can clean up the slots on the publisher'); +$result = $node_publisher->safe_psql('postgres', + "SELECT count(*) FROM pg_replication_slots"); +is($result, qq(0), + 'DROP SUBSCRIPTION during error can clean up the slots on the publisher'); $node_subscriber->stop('fast'); $node_publisher->stop('fast'); diff --git a/src/test/subscription/t/010_truncate.pl b/src/test/subscription/t/010_truncate.pl index cd3f45c1925..2d49f2537b8 100644 --- a/src/test/subscription/t/010_truncate.pl +++ b/src/test/subscription/t/010_truncate.pl @@ -185,4 +185,5 @@ $node_publisher->wait_for_catchup('sub1'); $result = $node_subscriber->safe_psql('postgres', "SELECT count(*), min(a), max(a) FROM tab1"); -is($result, qq(0||), 'truncate replicated in synchronous logical replication'); +is($result, qq(0||), + 'truncate replicated in synchronous logical replication'); diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl index d76e14c3764..6cc8b4a8d26 100644 --- a/src/test/subscription/t/015_stream.pl +++ b/src/test/subscription/t/015_stream.pl @@ -11,7 +11,8 @@ use Test::More tests => 4; # Create publisher node my $node_publisher = get_new_node('publisher'); $node_publisher->init(allows_streaming => 'logical'); -$node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node @@ -26,27 +27,31 @@ $node_publisher->safe_psql('postgres', "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')"); # Setup structure on subscriber -$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"); +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)" +); # Setup logical replication my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); my $appname = 'tap_sub'; $node_subscriber->safe_psql('postgres', -"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" ); $node_publisher->wait_for_catchup($appname); # Also wait for initial table sync to finish my $synced_query = -"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; + "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; $node_subscriber->poll_query_until('postgres', $synced_query) or die "Timed out while waiting for subscriber to synchronize data"; my $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d = 999) FROM test_tab"); is($result, qq(2|2|2), 'check initial data was copied to subscriber'); # Interleave a pair of transactions, each exceeding the 64kB limit. @@ -83,16 +88,17 @@ $h->finish; # errors make the next test fail, so ignore them here $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d = 999) FROM test_tab"); is($result, qq(3334|3334|3334), 'check extra columns contain local defaults'); # Test the streaming in binary mode $node_subscriber->safe_psql('postgres', -"ALTER SUBSCRIPTION tap_sub SET (binary = on)" -); + "ALTER SUBSCRIPTION tap_sub SET (binary = on)"); # Insert, update and delete enough rows to exceed the 64kB limit. -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(5001, 10000) s(i); UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0; @@ -103,21 +109,27 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d = 999) FROM test_tab"); is($result, qq(6667|6667|6667), 'check extra columns contain local defaults'); # Change the local values of the extra columns on the subscriber, # update publisher, and check that subscriber retains the expected # values. This is to ensure that non-streaming transactions behave # properly after a streaming transaction. -$node_subscriber->safe_psql('postgres', "UPDATE test_tab SET c = 'epoch'::timestamptz + 987654321 * interval '1s'"); -$node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = md5(a::text)"); +$node_subscriber->safe_psql('postgres', + "UPDATE test_tab SET c = 'epoch'::timestamptz + 987654321 * interval '1s'" +); +$node_publisher->safe_psql('postgres', + "UPDATE test_tab SET b = md5(a::text)"); $node_publisher->wait_for_catchup($appname); -$result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab"); -is($result, qq(6667|6667|6667), 'check extra columns contain locally changed data'); +$result = $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab" +); +is($result, qq(6667|6667|6667), + 'check extra columns contain locally changed data'); $node_subscriber->stop; $node_publisher->stop; diff --git a/src/test/subscription/t/016_stream_subxact.pl b/src/test/subscription/t/016_stream_subxact.pl index 399036f14b4..0245b0685b1 100644 --- a/src/test/subscription/t/016_stream_subxact.pl +++ b/src/test/subscription/t/016_stream_subxact.pl @@ -11,7 +11,8 @@ use Test::More tests => 2; # Create publisher node my $node_publisher = get_new_node('publisher'); $node_publisher->init(allows_streaming => 'logical'); -$node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node @@ -26,31 +27,36 @@ $node_publisher->safe_psql('postgres', "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')"); # Setup structure on subscriber -$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"); +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)" +); # Setup logical replication my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); my $appname = 'tap_sub'; $node_subscriber->safe_psql('postgres', -"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" ); $node_publisher->wait_for_catchup($appname); # Also wait for initial table sync to finish my $synced_query = -"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; + "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; $node_subscriber->poll_query_until('postgres', $synced_query) or die "Timed out while waiting for subscriber to synchronize data"; my $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d = 999) FROM test_tab"); is($result, qq(2|2|2), 'check initial data was copied to subscriber'); # Insert, update and delete enough rows to exceed 64kB limit. -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series( 3, 500) s(i); UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0; @@ -77,8 +83,11 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); -is($result, qq(1667|1667|1667), 'check data was copied to subscriber in streaming mode and extra columns contain local defaults'); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d = 999) FROM test_tab"); +is($result, qq(1667|1667|1667), + 'check data was copied to subscriber in streaming mode and extra columns contain local defaults' +); $node_subscriber->stop; $node_publisher->stop; diff --git a/src/test/subscription/t/017_stream_ddl.pl b/src/test/subscription/t/017_stream_ddl.pl index 8194a3882ac..35b146827d3 100644 --- a/src/test/subscription/t/017_stream_ddl.pl +++ b/src/test/subscription/t/017_stream_ddl.pl @@ -11,7 +11,8 @@ use Test::More tests => 3; # Create publisher node my $node_publisher = get_new_node('publisher'); $node_publisher->init(allows_streaming => 'logical'); -$node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node @@ -26,31 +27,36 @@ $node_publisher->safe_psql('postgres', "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')"); # Setup structure on subscriber -$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT, f INT)"); +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT, f INT)" +); # Setup logical replication my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); my $appname = 'tap_sub'; $node_subscriber->safe_psql('postgres', -"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" ); $node_publisher->wait_for_catchup($appname); # Also wait for initial table sync to finish my $synced_query = -"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; + "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; $node_subscriber->poll_query_until('postgres', $synced_query) or die "Timed out while waiting for subscriber to synchronize data"; my $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d = 999) FROM test_tab"); is($result, qq(2|0|0), 'check initial data was copied to subscriber'); # a small (non-streamed) transaction with DDL and DML -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab VALUES (3, md5(3::text)); ALTER TABLE test_tab ADD COLUMN c INT; @@ -60,7 +66,8 @@ COMMIT; }); # large (streamed) transaction with DDL and DML -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text), -i FROM generate_series(5, 1000) s(i); ALTER TABLE test_tab ADD COLUMN d INT; @@ -70,7 +77,8 @@ COMMIT; }); # a small (non-streamed) transaction with DDL and DML -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab VALUES (2001, md5(2001::text), -2001, 2*2001); ALTER TABLE test_tab ADD COLUMN e INT; @@ -82,13 +90,17 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d), count(e) FROM test_tab"); -is($result, qq(2002|1999|1002|1), 'check data was copied to subscriber in streaming mode and extra columns contain local defaults'); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d), count(e) FROM test_tab"); +is($result, qq(2002|1999|1002|1), + 'check data was copied to subscriber in streaming mode and extra columns contain local defaults' +); # A large (streamed) transaction with DDL and DML. One of the DDL is performed # after DML to ensure that we invalidate the schema sent for test_tab so that # the next transaction has to send the schema again. -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text), -i, 2*i, -3*i FROM generate_series(2003,5000) s(i); ALTER TABLE test_tab ADD COLUMN f INT; @@ -97,7 +109,8 @@ COMMIT; # A small transaction that won't get streamed. This is just to ensure that we # send the schema again to reflect the last column added in the previous test. -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text), -i, 2*i, -3*i, 4*i FROM generate_series(5001,5005) s(i); COMMIT; @@ -106,8 +119,11 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d), count(e), count(f) FROM test_tab"); -is($result, qq(5005|5002|4005|3004|5), 'check data was copied to subscriber for both streaming and non-streaming transactions'); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c), count(d), count(e), count(f) FROM test_tab"); +is($result, qq(5005|5002|4005|3004|5), + 'check data was copied to subscriber for both streaming and non-streaming transactions' +); $node_subscriber->stop; $node_publisher->stop; diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl b/src/test/subscription/t/018_stream_subxact_abort.pl index aafb555ada5..7fc60b5bde8 100644 --- a/src/test/subscription/t/018_stream_subxact_abort.pl +++ b/src/test/subscription/t/018_stream_subxact_abort.pl @@ -11,7 +11,8 @@ use Test::More tests => 4; # Create publisher node my $node_publisher = get_new_node('publisher'); $node_publisher->init(allows_streaming => 'logical'); -$node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node @@ -26,31 +27,35 @@ $node_publisher->safe_psql('postgres', "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')"); # Setup structure on subscriber -$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT)"); +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT)"); # Setup logical replication my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); my $appname = 'tap_sub'; $node_subscriber->safe_psql('postgres', -"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" ); $node_publisher->wait_for_catchup($appname); # Also wait for initial table sync to finish my $synced_query = -"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; + "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; $node_subscriber->poll_query_until('postgres', $synced_query) or die "Timed out while waiting for subscriber to synchronize data"; my $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c) FROM test_tab"); is($result, qq(2|0), 'check initial data was copied to subscriber'); # large (streamed) transaction with DDL, DML and ROLLBACKs -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3,500) s(i); SAVEPOINT s1; @@ -73,12 +78,16 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c) FROM test_tab"); -is($result, qq(2000|0), 'check rollback to savepoint was reflected on subscriber and extra columns contain local defaults'); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c) FROM test_tab"); +is($result, qq(2000|0), + 'check rollback to savepoint was reflected on subscriber and extra columns contain local defaults' +); # large (streamed) transaction with subscriber receiving out of order # subtransaction ROLLBACKs -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(4001,4500) s(i); SAVEPOINT s1; @@ -96,11 +105,14 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c) FROM test_tab"); -is($result, qq(2500|0), 'check rollback to savepoint was reflected on subscriber'); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c) FROM test_tab"); +is($result, qq(2500|0), + 'check rollback to savepoint was reflected on subscriber'); # large (streamed) transaction with subscriber receiving rollback -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(8501,9000) s(i); SAVEPOINT s1; @@ -113,7 +125,8 @@ ROLLBACK; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c) FROM test_tab"); is($result, qq(2500|0), 'check rollback was reflected on subscriber'); $node_subscriber->stop; diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl index 517a26342ba..81149b86a99 100644 --- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl +++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl @@ -12,7 +12,8 @@ use Test::More tests => 2; # Create publisher node my $node_publisher = get_new_node('publisher'); $node_publisher->init(allows_streaming => 'logical'); -$node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node @@ -27,31 +28,35 @@ $node_publisher->safe_psql('postgres', "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')"); # Setup structure on subscriber -$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT)"); +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text, c INT, d INT, e INT)"); # Setup logical replication my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); my $appname = 'tap_sub'; $node_subscriber->safe_psql('postgres', -"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)" ); $node_publisher->wait_for_catchup($appname); # Also wait for initial table sync to finish my $synced_query = -"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; + "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');"; $node_subscriber->poll_query_until('postgres', $synced_query) or die "Timed out while waiting for subscriber to synchronize data"; my $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c) FROM test_tab"); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c) FROM test_tab"); is($result, qq(2|0), 'check initial data was copied to subscriber'); # large (streamed) transaction with DDL, DML and ROLLBACKs -$node_publisher->safe_psql('postgres', q{ +$node_publisher->safe_psql( + 'postgres', q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3,500) s(i); ALTER TABLE test_tab ADD COLUMN c INT; @@ -72,8 +77,11 @@ COMMIT; $node_publisher->wait_for_catchup($appname); $result = - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c) FROM test_tab"); -is($result, qq(1000|500), 'check rollback to savepoint was reflected on subscriber and extra columns contain local defaults'); + $node_subscriber->safe_psql('postgres', + "SELECT count(*), count(c) FROM test_tab"); +is($result, qq(1000|500), + 'check rollback to savepoint was reflected on subscriber and extra columns contain local defaults' +); $node_subscriber->stop; $node_publisher->stop; diff --git a/src/test/subscription/t/020_messages.pl b/src/test/subscription/t/020_messages.pl index e5d48ec8a00..0940d0f45f2 100644 --- a/src/test/subscription/t/020_messages.pl +++ b/src/test/subscription/t/020_messages.pl @@ -28,7 +28,8 @@ $node_subscriber->safe_psql('postgres', # Setup logical replication my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE tab_test"); +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE tab_test"); $node_subscriber->safe_psql('postgres', "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub" @@ -55,7 +56,7 @@ my $result = $node_publisher->safe_psql( )); # 66 77 67 == B M C == BEGIN MESSAGE COMMIT -is($result, qq(66 +is( $result, qq(66 77 67), 'messages on slot are B M C with message option'); @@ -82,9 +83,10 @@ $result = $node_publisher->safe_psql( )); # 66 67 == B C == BEGIN COMMIT -is($result, qq(66 +is( $result, qq(66 67), - 'option messages defaults to false so message (M) is not available on slot'); + 'option messages defaults to false so message (M) is not available on slot' +); $node_subscriber->safe_psql('postgres', "ALTER SUBSCRIPTION tap_sub ENABLE"); $node_publisher->wait_for_catchup('tap_sub'); @@ -99,7 +101,8 @@ $node_publisher->poll_query_until('postgres', $node_publisher->safe_psql('postgres', "INSERT INTO tab_test VALUES (1)"); my $message_lsn = $node_publisher->safe_psql('postgres', - "SELECT pg_logical_emit_message(false, 'pgoutput', 'a non-transactional message')"); + "SELECT pg_logical_emit_message(false, 'pgoutput', 'a non-transactional message')" +); $node_publisher->safe_psql('postgres', "INSERT INTO tab_test VALUES (2)"); @@ -151,7 +154,7 @@ $result = $node_publisher->safe_psql( 'messages', 'true') )); -is($result, qq(77|0 +is( $result, qq(77|0 77|0), 'non-transactional message on slot from aborted transaction is M'); diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl index 76a9a90bcb9..21eabceb2f6 100644 --- a/src/test/subscription/t/100_bugs.pl +++ b/src/test/subscription/t/100_bugs.pl @@ -137,10 +137,9 @@ $node_twoways->safe_psql( INSERT INTO t SELECT * FROM generate_series(1, $rows); INSERT INTO t2 SELECT * FROM generate_series(1, $rows); }); -$node_twoways->safe_psql( - 'd1', 'ALTER PUBLICATION testpub ADD TABLE t2'); -$node_twoways->safe_psql( - 'd2', 'ALTER SUBSCRIPTION testsub REFRESH PUBLICATION'); +$node_twoways->safe_psql('d1', 'ALTER PUBLICATION testpub ADD TABLE t2'); +$node_twoways->safe_psql('d2', + 'ALTER SUBSCRIPTION testsub REFRESH PUBLICATION'); # We cannot rely solely on wait_for_catchup() here; it isn't sufficient # when tablesync workers might still be running. So in addition to that, |
