diff options
author | Tom Lane | 2023-05-19 21:24:48 +0000 |
---|---|---|
committer | Tom Lane | 2023-05-19 21:24:48 +0000 |
commit | 0245f8db36f375326c2bae0c3420d3c77714e72d (patch) | |
tree | 7ce91f23658a05ea24be4703fb06cdc6b56248f7 /src/test/subscription/t | |
parent | df6b19fbbc20d830de91d9bea68715a39635b568 (diff) |
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files.
This set of diffs is a bit larger than typical. We've updated to
pg_bsd_indent 2.1.2, which properly indents variable declarations that
have multi-line initialization expressions (the continuation lines are
now indented one tab stop). We've also updated to perltidy version
20230309 and changed some of its settings, which reduces its desire to
add whitespace to lines to make assignments etc. line up. Going
forward, that should make for fewer random-seeming changes to existing
code.
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/test/subscription/t')
-rw-r--r-- | src/test/subscription/t/001_rep_changes.pl | 3 | ||||
-rw-r--r-- | src/test/subscription/t/005_encoding.pl | 6 | ||||
-rw-r--r-- | src/test/subscription/t/012_collation.pl | 4 | ||||
-rw-r--r-- | src/test/subscription/t/014_binary.pl | 2 | ||||
-rw-r--r-- | src/test/subscription/t/015_stream.pl | 23 | ||||
-rw-r--r-- | src/test/subscription/t/018_stream_subxact_abort.pl | 3 | ||||
-rw-r--r-- | src/test/subscription/t/023_twophase_stream.pl | 3 | ||||
-rw-r--r-- | src/test/subscription/t/025_rep_changes_for_schema.pl | 3 | ||||
-rw-r--r-- | src/test/subscription/t/026_stats.pl | 2 | ||||
-rw-r--r-- | src/test/subscription/t/027_nosuperuser.pl | 18 | ||||
-rw-r--r-- | src/test/subscription/t/028_row_filter.pl | 8 | ||||
-rw-r--r-- | src/test/subscription/t/030_origin.pl | 6 | ||||
-rw-r--r-- | src/test/subscription/t/031_column_list.pl | 2 | ||||
-rw-r--r-- | src/test/subscription/t/032_subscribe_use_index.pl | 150 | ||||
-rw-r--r-- | src/test/subscription/t/033_run_as_table_owner.pl | 25 | ||||
-rw-r--r-- | src/test/subscription/t/100_bugs.pl | 6 |
16 files changed, 146 insertions, 118 deletions
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index 91aa068c95b..0a399cdb82b 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -233,7 +233,8 @@ $node_subscriber->safe_psql('postgres', ); # Wait for initial table sync to finish -$node_subscriber->wait_for_subscription_sync($node_publisher, 'tap_sub_temp1'); +$node_subscriber->wait_for_subscription_sync($node_publisher, + 'tap_sub_temp1'); # Subscriber table will have no rows initially $result = diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl index 297adfb3bb6..2f0bf7730b9 100644 --- a/src/test/subscription/t/005_encoding.pl +++ b/src/test/subscription/t/005_encoding.pl @@ -11,13 +11,13 @@ use Test::More; my $node_publisher = PostgreSQL::Test::Cluster->new('publisher'); $node_publisher->init( allows_streaming => 'logical', - extra => [ '--locale=C', '--encoding=UTF8' ]); + extra => [ '--locale=C', '--encoding=UTF8' ]); $node_publisher->start; my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); $node_subscriber->init( allows_streaming => 'logical', - extra => [ '--locale=C', '--encoding=LATIN1' ]); + extra => [ '--locale=C', '--encoding=LATIN1' ]); $node_subscriber->start; my $ddl = "CREATE TABLE test1 (a int, b text);"; @@ -42,7 +42,7 @@ $node_publisher->wait_for_catchup('mysub'); is( $node_subscriber->safe_psql( 'postgres', q{SELECT a FROM test1 WHERE b = E'Mot\xf6rhead'} - ), # LATIN1 + ), # LATIN1 qq(1), 'data replicated to subscriber'); diff --git a/src/test/subscription/t/012_collation.pl b/src/test/subscription/t/012_collation.pl index 4d947f1375d..823550a31b5 100644 --- a/src/test/subscription/t/012_collation.pl +++ b/src/test/subscription/t/012_collation.pl @@ -17,13 +17,13 @@ if ($ENV{with_icu} ne 'yes') my $node_publisher = PostgreSQL::Test::Cluster->new('publisher'); $node_publisher->init( allows_streaming => 'logical', - extra => [ '--locale=C', '--encoding=UTF8' ]); + extra => [ '--locale=C', '--encoding=UTF8' ]); $node_publisher->start; my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); $node_subscriber->init( allows_streaming => 'logical', - extra => [ '--locale=C', '--encoding=UTF8' ]); + extra => [ '--locale=C', '--encoding=UTF8' ]); $node_subscriber->start; my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; diff --git a/src/test/subscription/t/014_binary.pl b/src/test/subscription/t/014_binary.pl index feefbe734e4..e5ce849c191 100644 --- a/src/test/subscription/t/014_binary.pl +++ b/src/test/subscription/t/014_binary.pl @@ -57,7 +57,7 @@ $node_publisher->safe_psql( my $publisher_connstring = $node_publisher->connstr . ' dbname=postgres'; $node_subscriber->safe_psql('postgres', - "CREATE SUBSCRIPTION tsub CONNECTION '$publisher_connstring' " + "CREATE SUBSCRIPTION tsub CONNECTION '$publisher_connstring' " . "PUBLICATION tpub WITH (slot_name = tpub_slot, binary = true)"); # Ensure the COPY command is executed in binary format on the publisher diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl index 88344bdbaa0..5c00711ef2d 100644 --- a/src/test/subscription/t/015_stream.pl +++ b/src/test/subscription/t/015_stream.pl @@ -30,13 +30,13 @@ sub test_streaming # Interleave a pair of transactions, each exceeding the 64kB limit. my $offset = 0; - my $h = $node_publisher->background_psql('postgres', - on_error_stop => 0); + my $h = $node_publisher->background_psql('postgres', on_error_stop => 0); # Check the subscriber log from now on. $offset = -s $node_subscriber->logfile; - $h->query_safe(q{ + $h->query_safe( + q{ BEGIN; INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(3, 5000) s(i); UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0; @@ -52,7 +52,7 @@ sub test_streaming }); $h->query_safe('COMMIT'); - # errors make the next test fail, so ignore them here + # errors make the next test fail, so ignore them here $h->quit; $node_publisher->wait_for_catchup($appname); @@ -211,15 +211,15 @@ $node_subscriber->reload; $node_subscriber->safe_psql('postgres', q{SELECT 1}); # Interleave a pair of transactions, each exceeding the 64kB limit. -my $h = $node_publisher->background_psql('postgres', - on_error_stop => 0); +my $h = $node_publisher->background_psql('postgres', on_error_stop => 0); # Confirm if a deadlock between the leader apply worker and the parallel apply # worker can be detected. my $offset = -s $node_subscriber->logfile; -$h->query_safe(q{ +$h->query_safe( + q{ BEGIN; INSERT INTO test_tab_2 SELECT i FROM generate_series(1, 5000) s(i); }); @@ -260,7 +260,8 @@ $node_subscriber->safe_psql('postgres', # Check the subscriber log from now on. $offset = -s $node_subscriber->logfile; -$h->query_safe(q{ +$h->query_safe( + q{ BEGIN; INSERT INTO test_tab_2 SELECT i FROM generate_series(1, 5000) s(i); }); @@ -296,7 +297,8 @@ is($result, qq(10000), 'data replicated to subscriber after dropping index'); $node_subscriber->append_conf('postgresql.conf', 'logical_replication_mode = immediate'); # Reset the log_min_messages to default. -$node_subscriber->append_conf('postgresql.conf', "log_min_messages = warning"); +$node_subscriber->append_conf('postgresql.conf', + "log_min_messages = warning"); $node_subscriber->reload; # Run a query to make sure that the reload has taken effect. @@ -317,7 +319,8 @@ $node_publisher->wait_for_catchup($appname); # Check that transaction is committed on subscriber $result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM test_tab_2"); -is($result, qq(15000), 'parallel apply worker replayed all changes from file'); +is($result, qq(15000), + 'parallel apply worker replayed all changes from file'); $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 2b67ae1e0ac..91d19ae672a 100644 --- a/src/test/subscription/t/018_stream_subxact_abort.pl +++ b/src/test/subscription/t/018_stream_subxact_abort.pl @@ -205,7 +205,8 @@ test_streaming($node_publisher, $node_subscriber, $appname, 1); $node_subscriber->append_conf('postgresql.conf', 'logical_replication_mode = immediate'); # Reset the log_min_messages to default. -$node_subscriber->append_conf('postgresql.conf', "log_min_messages = warning"); +$node_subscriber->append_conf('postgresql.conf', + "log_min_messages = warning"); $node_subscriber->reload; # Run a query to make sure that the reload has taken effect. diff --git a/src/test/subscription/t/023_twophase_stream.pl b/src/test/subscription/t/023_twophase_stream.pl index f4af44414b6..fdcc4b359d2 100644 --- a/src/test/subscription/t/023_twophase_stream.pl +++ b/src/test/subscription/t/023_twophase_stream.pl @@ -391,7 +391,8 @@ test_streaming($node_publisher, $node_subscriber, $appname, 1); $node_subscriber->append_conf('postgresql.conf', 'logical_replication_mode = immediate'); # Reset the log_min_messages to default. -$node_subscriber->append_conf('postgresql.conf', "log_min_messages = warning"); +$node_subscriber->append_conf('postgresql.conf', + "log_min_messages = warning"); $node_subscriber->reload; # Run a query to make sure that the reload has taken effect. diff --git a/src/test/subscription/t/025_rep_changes_for_schema.pl b/src/test/subscription/t/025_rep_changes_for_schema.pl index a22ae0a2ac0..8543f52710c 100644 --- a/src/test/subscription/t/025_rep_changes_for_schema.pl +++ b/src/test/subscription/t/025_rep_changes_for_schema.pl @@ -63,7 +63,8 @@ $node_subscriber->safe_psql('postgres', ); # Wait for initial table sync to finish -$node_subscriber->wait_for_subscription_sync($node_publisher, 'tap_sub_schema'); +$node_subscriber->wait_for_subscription_sync($node_publisher, + 'tap_sub_schema'); # Check the schema table data is synced up my $result = $node_subscriber->safe_psql('postgres', diff --git a/src/test/subscription/t/026_stats.pl b/src/test/subscription/t/026_stats.pl index 96a6d686eb6..45e51c5a52c 100644 --- a/src/test/subscription/t/026_stats.pl +++ b/src/test/subscription/t/026_stats.pl @@ -43,7 +43,7 @@ sub create_sub_pub_w_errors ]); # Set up publication. - my $pub_name = $table_name . '_pub'; + my $pub_name = $table_name . '_pub'; my $publisher_connstr = $node_publisher->connstr . qq( dbname=$db); $node_publisher->safe_psql($db, diff --git a/src/test/subscription/t/027_nosuperuser.pl b/src/test/subscription/t/027_nosuperuser.pl index 8a7e79cacac..d7a7e3ef5bb 100644 --- a/src/test/subscription/t/027_nosuperuser.pl +++ b/src/test/subscription/t/027_nosuperuser.pl @@ -81,7 +81,7 @@ sub grant_superuser # "regress_admin". For partitioned tables, layout the partitions differently # on the publisher than on the subscriber. # -$node_publisher = PostgreSQL::Test::Cluster->new('publisher'); +$node_publisher = PostgreSQL::Test::Cluster->new('publisher'); $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); $node_publisher->init(allows_streaming => 'logical'); $node_subscriber->init; @@ -89,10 +89,10 @@ $node_publisher->start; $node_subscriber->start; $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; my %remainder_a = ( - publisher => 0, + publisher => 0, subscriber => 1); my %remainder_b = ( - publisher => 1, + publisher => 1, subscriber => 0); for my $node ($node_publisher, $node_subscriber) @@ -197,8 +197,7 @@ publish_insert("alice.hashpart", 103); publish_update("alice.hashpart", 102 => 120); publish_delete("alice.hashpart", 101); expect_replication("alice.hashpart", 2, 103, 120, - "nosuperuser admin with privileges on role can replicate into hashpart" -); + "nosuperuser admin with privileges on role can replicate into hashpart"); # Force RLS on the target table and check that replication fails. $node_subscriber->safe_psql( @@ -223,8 +222,7 @@ $node_subscriber->safe_psql( ALTER TABLE alice.unpartitioned NO FORCE ROW LEVEL SECURITY; )); expect_replication("alice.unpartitioned", 3, 11, 15, - "non-superuser admin can replicate insert if rls is not forced" -); + "non-superuser admin can replicate insert if rls is not forced"); $node_subscriber->safe_psql( 'postgres', qq( @@ -237,8 +235,7 @@ expect_failure( 11, 15, qr/ERROR: ( [A-Z0-9]+:)? user "regress_alice" cannot replicate into relation with row-level security enabled: "unpartitioned\w*"/msi, - "replication of update into table with forced rls fails" -); + "replication of update into table with forced rls fails"); $node_subscriber->safe_psql( 'postgres', qq( ALTER TABLE alice.unpartitioned NO FORCE ROW LEVEL SECURITY; @@ -258,8 +255,7 @@ expect_failure( 13, 17, qr/ERROR: ( [A-Z0-9]+:)? permission denied for table unpartitioned/msi, - "replication of insert fails if table owner lacks insert permission" -); + "replication of insert fails if table owner lacks insert permission"); # alice needs INSERT but not SELECT to replicate an INSERT. $node_subscriber->safe_psql( diff --git a/src/test/subscription/t/028_row_filter.pl b/src/test/subscription/t/028_row_filter.pl index b0d4b2d5b17..aec483f785f 100644 --- a/src/test/subscription/t/028_row_filter.pl +++ b/src/test/subscription/t/028_row_filter.pl @@ -18,7 +18,7 @@ $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -my $appname = 'tap_sub'; +my $appname = 'tap_sub'; # ==================================================================== # Testcase start: FOR ALL TABLES @@ -544,13 +544,11 @@ is( $result, qq(20 $result = $node_subscriber->safe_psql('postgres', "SELECT a FROM tab_rowfilter_parent_sync ORDER BY 1"); -is( $result, qq(16), - 'check initial data copy from tab_rowfilter_parent_sync'); +is($result, qq(16), 'check initial data copy from tab_rowfilter_parent_sync'); $result = $node_subscriber->safe_psql('postgres', "SELECT a FROM tab_rowfilter_child_sync ORDER BY 1"); -is( $result, qq(), - 'check initial data copy from tab_rowfilter_child_sync'); +is($result, qq(), 'check initial data copy from tab_rowfilter_child_sync'); # The following commands are executed after CREATE SUBSCRIPTION, so these SQL # commands are for testing normal logical replication behavior. diff --git a/src/test/subscription/t/030_origin.pl b/src/test/subscription/t/030_origin.pl index b9b1351ddbb..9ca1fa25d8f 100644 --- a/src/test/subscription/t/030_origin.pl +++ b/src/test/subscription/t/030_origin.pl @@ -9,10 +9,10 @@ use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Utils; use Test::More; -my $subname_AB = 'tap_sub_A_B'; +my $subname_AB = 'tap_sub_A_B'; my $subname_AB2 = 'tap_sub_A_B_2'; -my $subname_BA = 'tap_sub_B_A'; -my $subname_BC = 'tap_sub_B_C'; +my $subname_BA = 'tap_sub_B_A'; +my $subname_BC = 'tap_sub_B_C'; my $result; my $stdout; diff --git a/src/test/subscription/t/031_column_list.pl b/src/test/subscription/t/031_column_list.pl index b67292ba9c6..dbff8060402 100644 --- a/src/test/subscription/t/031_column_list.pl +++ b/src/test/subscription/t/031_column_list.pl @@ -20,7 +20,7 @@ $node_subscriber->append_conf('postgresql.conf', $node_subscriber->start; my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -my $offset = 0; +my $offset = 0; # setup tables on both nodes diff --git a/src/test/subscription/t/032_subscribe_use_index.pl b/src/test/subscription/t/032_subscribe_use_index.pl index 76d7c85fff4..576eec6a578 100644 --- a/src/test/subscription/t/032_subscribe_use_index.pl +++ b/src/test/subscription/t/032_subscribe_use_index.pl @@ -18,8 +18,8 @@ $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; -my $appname = 'tap_sub'; -my $result = ''; +my $appname = 'tap_sub'; +my $result = ''; # ============================================================================= # Testcase start: Subscription can use index with multiple rows and columns @@ -60,19 +60,24 @@ $node_publisher->safe_psql('postgres', # wait until the index is used on the subscriber $node_publisher->wait_for_catchup($appname); -$node_subscriber->poll_query_until( - 'postgres', q{select (idx_scan = 4) from pg_stat_all_indexes where indexrelname = 'test_replica_id_full_idx';} -) or die "Timed out while waiting for check subscriber tap_sub_rep_full updates 4 rows via index"; +$node_subscriber->poll_query_until('postgres', + q{select (idx_scan = 4) from pg_stat_all_indexes where indexrelname = 'test_replica_id_full_idx';} + ) + or die + "Timed out while waiting for check subscriber tap_sub_rep_full updates 4 rows via index"; # make sure that the subscriber has the correct data after the UPDATE $result = $node_subscriber->safe_psql('postgres', - "select count(*) from test_replica_id_full WHERE (x = 100 and y = '200')"); -is($result, qq(2), 'ensure subscriber has the correct data at the end of the test'); + "select count(*) from test_replica_id_full WHERE (x = 100 and y = '200')" +); +is($result, qq(2), + 'ensure subscriber has the correct data at the end of the test'); # make sure that the subscriber has the correct data after the first DELETE $result = $node_subscriber->safe_psql('postgres', "select count(*) from test_replica_id_full where x in (5, 6)"); -is($result, qq(0), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(0), + 'ensure subscriber has the correct data at the end of the test'); # cleanup pub $node_publisher->safe_psql('postgres', "DROP PUBLICATION tap_pub_rep_full"); @@ -145,17 +150,21 @@ $node_publisher->safe_psql('postgres', # wait until the index is used on the subscriber $node_publisher->wait_for_catchup($appname); -$node_subscriber->poll_query_until( - 'postgres', q{select sum(idx_scan)=3 from pg_stat_all_indexes where indexrelname ilike 'users_table_part_%';} -) or die "Timed out while waiting for check subscriber tap_sub_rep_full updates partitioned table"; +$node_subscriber->poll_query_until('postgres', + q{select sum(idx_scan)=3 from pg_stat_all_indexes where indexrelname ilike 'users_table_part_%';} + ) + or die + "Timed out while waiting for check subscriber tap_sub_rep_full updates partitioned table"; # make sure that the subscriber has the correct data $result = $node_subscriber->safe_psql('postgres', "select sum(user_id+value_1+value_2) from users_table_part"); -is($result, qq(10907), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(10907), + 'ensure subscriber has the correct data at the end of the test'); $result = $node_subscriber->safe_psql('postgres', "select count(DISTINCT(user_id,value_1, value_2)) from users_table_part"); -is($result, qq(99), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(99), + 'ensure subscriber has the correct data at the end of the test'); # cleanup pub $node_publisher->safe_psql('postgres', "DROP PUBLICATION tap_pub_rep_full"); @@ -182,15 +191,18 @@ $node_subscriber->safe_psql('postgres', # index with only an expression $node_subscriber->safe_psql('postgres', - "CREATE INDEX people_names_expr_only ON people ((firstname || ' ' || lastname))"); + "CREATE INDEX people_names_expr_only ON people ((firstname || ' ' || lastname))" +); # partial index $node_subscriber->safe_psql('postgres', - "CREATE INDEX people_names_partial ON people(firstname) WHERE (firstname = 'first_name_1')"); + "CREATE INDEX people_names_partial ON people(firstname) WHERE (firstname = 'first_name_1')" +); # insert some initial data $node_publisher->safe_psql('postgres', - "INSERT INTO people SELECT 'first_name_' || i::text, 'last_name_' || i::text FROM generate_series(0,200) i"); + "INSERT INTO people SELECT 'first_name_' || i::text, 'last_name_' || i::text FROM generate_series(0,200) i" +); # create pub/sub $node_publisher->safe_psql('postgres', @@ -204,31 +216,41 @@ $node_subscriber->wait_for_subscription_sync($node_publisher, $appname); # update 2 rows $node_publisher->safe_psql('postgres', - "UPDATE people SET firstname = 'no-name' WHERE firstname = 'first_name_1'"); + "UPDATE people SET firstname = 'no-name' WHERE firstname = 'first_name_1'" +); $node_publisher->safe_psql('postgres', - "UPDATE people SET firstname = 'no-name' WHERE firstname = 'first_name_2' AND lastname = 'last_name_2'"); + "UPDATE people SET firstname = 'no-name' WHERE firstname = 'first_name_2' AND lastname = 'last_name_2'" +); # make sure none of the indexes is used on the subscriber $node_publisher->wait_for_catchup($appname); $result = $node_subscriber->safe_psql('postgres', - "select sum(idx_scan) from pg_stat_all_indexes where indexrelname IN ('people_names_expr_only', 'people_names_partial')"); -is($result, qq(0), 'ensure subscriber tap_sub_rep_full updates two rows via seq. scan with index on expressions'); + "select sum(idx_scan) from pg_stat_all_indexes where indexrelname IN ('people_names_expr_only', 'people_names_partial')" +); +is($result, qq(0), + 'ensure subscriber tap_sub_rep_full updates two rows via seq. scan with index on expressions' +); $node_publisher->safe_psql('postgres', "DELETE FROM people WHERE firstname = 'first_name_3'"); $node_publisher->safe_psql('postgres', - "DELETE FROM people WHERE firstname = 'first_name_4' AND lastname = 'last_name_4'"); + "DELETE FROM people WHERE firstname = 'first_name_4' AND lastname = 'last_name_4'" +); # make sure the index is not used on the subscriber $node_publisher->wait_for_catchup($appname); $result = $node_subscriber->safe_psql('postgres', - "select sum(idx_scan) from pg_stat_all_indexes where indexrelname IN ('people_names_expr_only', 'people_names_partial')"); -is($result, qq(0), 'ensure subscriber tap_sub_rep_full updates two rows via seq. scan with index on expressions'); + "select sum(idx_scan) from pg_stat_all_indexes where indexrelname IN ('people_names_expr_only', 'people_names_partial')" +); +is($result, qq(0), + 'ensure subscriber tap_sub_rep_full updates two rows via seq. scan with index on expressions' +); # make sure that the subscriber has the correct data -$result = $node_subscriber->safe_psql('postgres', - "SELECT count(*) FROM people"); -is($result, qq(199), 'ensure subscriber has the correct data at the end of the test'); +$result = + $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM people"); +is($result, qq(199), + 'ensure subscriber has the correct data at the end of the test'); # cleanup pub $node_publisher->safe_psql('postgres', "DROP PUBLICATION tap_pub_rep_full"); @@ -252,11 +274,13 @@ $node_publisher->safe_psql('postgres', $node_subscriber->safe_psql('postgres', "CREATE TABLE people (firstname text, lastname text)"); $node_subscriber->safe_psql('postgres', - "CREATE INDEX people_names ON people (firstname, lastname, (firstname || ' ' || lastname))"); + "CREATE INDEX people_names ON people (firstname, lastname, (firstname || ' ' || lastname))" +); # insert some initial data $node_publisher->safe_psql('postgres', - "INSERT INTO people SELECT 'first_name_' || i::text, 'last_name_' || i::text FROM generate_series(0, 20) i"); + "INSERT INTO people SELECT 'first_name_' || i::text, 'last_name_' || i::text FROM generate_series(0, 20) i" +); # create pub/sub $node_publisher->safe_psql('postgres', @@ -270,7 +294,8 @@ $node_subscriber->wait_for_subscription_sync($node_publisher, $appname); # update 1 row $node_publisher->safe_psql('postgres', - "UPDATE people SET firstname = 'no-name' WHERE firstname = 'first_name_1'"); + "UPDATE people SET firstname = 'no-name' WHERE firstname = 'first_name_1'" +); # delete the updated row $node_publisher->safe_psql('postgres', @@ -278,22 +303,25 @@ $node_publisher->safe_psql('postgres', # wait until the index is used on the subscriber $node_publisher->wait_for_catchup($appname); -$node_subscriber->poll_query_until( - 'postgres', q{select idx_scan=2 from pg_stat_all_indexes where indexrelname = 'people_names';} -) or die "Timed out while waiting for check subscriber tap_sub_rep_full deletes two rows via index scan with index on expressions and columns"; +$node_subscriber->poll_query_until('postgres', + q{select idx_scan=2 from pg_stat_all_indexes where indexrelname = 'people_names';} + ) + or die + "Timed out while waiting for check subscriber tap_sub_rep_full deletes two rows via index scan with index on expressions and columns"; # make sure that the subscriber has the correct data -$result = $node_subscriber->safe_psql('postgres', - "SELECT count(*) FROM people"); -is($result, qq(20), 'ensure subscriber has the correct data at the end of the test'); +$result = + $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM people"); +is($result, qq(20), + 'ensure subscriber has the correct data at the end of the test'); $result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM people WHERE firstname = 'no-name'"); -is($result, qq(0), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(0), + 'ensure subscriber has the correct data at the end of the test'); # now, drop the index with the expression, we'll use sequential scan -$node_subscriber->safe_psql('postgres', - "DROP INDEX people_names"); +$node_subscriber->safe_psql('postgres', "DROP INDEX people_names"); # delete 1 row $node_publisher->safe_psql('postgres', @@ -303,7 +331,8 @@ $node_publisher->safe_psql('postgres', $node_publisher->wait_for_catchup($appname); $result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM people WHERE lastname = 'last_name_18'"); -is($result, qq(0), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(0), + 'ensure subscriber has the correct data at the end of the test'); # cleanup pub $node_publisher->safe_psql('postgres', "DROP PUBLICATION tap_pub_rep_full"); @@ -319,19 +348,16 @@ $node_subscriber->safe_psql('postgres', "DROP TABLE people"); # Testcase start: Null values and missing column $node_publisher->safe_psql('postgres', - "CREATE TABLE test_replica_id_full (x int)" -); + "CREATE TABLE test_replica_id_full (x int)"); $node_publisher->safe_psql('postgres', "ALTER TABLE test_replica_id_full REPLICA IDENTITY FULL"); $node_subscriber->safe_psql('postgres', - "CREATE TABLE test_replica_id_full (x int, y int)" -); + "CREATE TABLE test_replica_id_full (x int, y int)"); $node_subscriber->safe_psql('postgres', - "CREATE INDEX test_replica_id_full_idx ON test_replica_id_full(x,y)" -); + "CREATE INDEX test_replica_id_full_idx ON test_replica_id_full(x,y)"); # create pub/sub $node_publisher->safe_psql('postgres', @@ -352,19 +378,23 @@ $node_publisher->safe_psql('postgres', # check if the index is used even when the index has NULL values $node_publisher->wait_for_catchup($appname); -$node_subscriber->poll_query_until( - 'postgres', q{select idx_scan=1 from pg_stat_all_indexes where indexrelname = 'test_replica_id_full_idx';} -) or die "Timed out while waiting for check subscriber tap_sub_rep_full updates test_replica_id_full table"; +$node_subscriber->poll_query_until('postgres', + q{select idx_scan=1 from pg_stat_all_indexes where indexrelname = 'test_replica_id_full_idx';} + ) + or die + "Timed out while waiting for check subscriber tap_sub_rep_full updates test_replica_id_full table"; # make sure that the subscriber has the correct data $result = $node_subscriber->safe_psql('postgres', "select sum(x) from test_replica_id_full WHERE y IS NULL"); -is($result, qq(7), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(7), + 'ensure subscriber has the correct data at the end of the test'); # make sure that the subscriber has the correct data $result = $node_subscriber->safe_psql('postgres', "select count(*) from test_replica_id_full WHERE y IS NULL"); -is($result, qq(3), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(3), + 'ensure subscriber has the correct data at the end of the test'); # cleanup pub $node_publisher->safe_psql('postgres', "DROP PUBLICATION tap_pub_rep_full"); @@ -394,11 +424,13 @@ $node_publisher->safe_psql('postgres', $node_subscriber->safe_psql('postgres', "CREATE TABLE test_replica_id_full (x int, y int)"); $node_subscriber->safe_psql('postgres', - "CREATE UNIQUE INDEX test_replica_id_full_idxy ON test_replica_id_full(x,y)"); + "CREATE UNIQUE INDEX test_replica_id_full_idxy ON test_replica_id_full(x,y)" +); # insert some initial data $node_publisher->safe_psql('postgres', - "INSERT INTO test_replica_id_full SELECT i, i FROM generate_series(0,21) i"); + "INSERT INTO test_replica_id_full SELECT i, i FROM generate_series(0,21) i" +); # create pub/sub $node_publisher->safe_psql('postgres', @@ -412,7 +444,8 @@ $node_subscriber->wait_for_subscription_sync($node_publisher, $appname); # duplicate the data in subscriber for y column $node_subscriber->safe_psql('postgres', - "INSERT INTO test_replica_id_full SELECT i+100, i FROM generate_series(0,21) i"); + "INSERT INTO test_replica_id_full SELECT i+100, i FROM generate_series(0,21) i" +); # now, we update only 1 row on the publisher and expect the subscriber to only # update 1 row although there are two tuples with y = 15 on the subscriber @@ -421,15 +454,18 @@ $node_publisher->safe_psql('postgres', # wait until the index is used on the subscriber $node_publisher->wait_for_catchup($appname); -$node_subscriber->poll_query_until( - 'postgres', q{select (idx_scan = 1) from pg_stat_all_indexes where indexrelname = 'test_replica_id_full_idxy';} -) or die "Timed out while waiting for check subscriber tap_sub_rep_full updates one row via index"; +$node_subscriber->poll_query_until('postgres', + q{select (idx_scan = 1) from pg_stat_all_indexes where indexrelname = 'test_replica_id_full_idxy';} + ) + or die + "Timed out while waiting for check subscriber tap_sub_rep_full updates one row via index"; # make sure that the subscriber has the correct data # we only updated 1 row $result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM test_replica_id_full WHERE x = 2000"); -is($result, qq(1), 'ensure subscriber has the correct data at the end of the test'); +is($result, qq(1), + 'ensure subscriber has the correct data at the end of the test'); # cleanup pub $node_publisher->safe_psql('postgres', "DROP PUBLICATION tap_pub_rep_full"); diff --git a/src/test/subscription/t/033_run_as_table_owner.pl b/src/test/subscription/t/033_run_as_table_owner.pl index cabc8a7c59a..0aa8a093efc 100644 --- a/src/test/subscription/t/033_run_as_table_owner.pl +++ b/src/test/subscription/t/033_run_as_table_owner.pl @@ -73,7 +73,7 @@ sub revoke_superuser # "regress_admin". For partitioned tables, layout the partitions differently # on the publisher than on the subscriber. # -$node_publisher = PostgreSQL::Test::Cluster->new('publisher'); +$node_publisher = PostgreSQL::Test::Cluster->new('publisher'); $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); $node_publisher->init(allows_streaming => 'logical'); $node_subscriber->init; @@ -120,18 +120,14 @@ publish_insert("alice.unpartitioned", 3); publish_insert("alice.unpartitioned", 5); publish_update("alice.unpartitioned", 1 => 7); publish_delete("alice.unpartitioned", 3); -expect_replication("alice.unpartitioned", 2, 5, 7, - "superuser can replicate"); +expect_replication("alice.unpartitioned", 2, 5, 7, "superuser can replicate"); # Revoke superuser privilege for "regress_admin", and verify that we now # fail to replicate an insert. revoke_superuser("regress_admin"); publish_insert("alice.unpartitioned", 9); expect_failure( - "alice.unpartitioned", - 2, - 5, - 7, + "alice.unpartitioned", 2, 5, 7, qr/ERROR: ( [A-Z0-9]+:)? permission denied for table unpartitioned/msi, "with no privileges cannot replicate"); @@ -144,8 +140,7 @@ GRANT INSERT,UPDATE,DELETE ON alice.unpartitioned TO regress_admin; REVOKE SELECT ON alice.unpartitioned FROM regress_admin; )); expect_replication("alice.unpartitioned", 3, 5, 9, - "with INSERT privilege can replicate INSERT" -); + "with INSERT privilege can replicate INSERT"); # We can't yet replicate an UPDATE because we don't have SELECT. publish_update("alice.unpartitioned", 5 => 11); @@ -156,8 +151,7 @@ expect_failure( 5, 9, qr/ERROR: ( [A-Z0-9]+:)? permission denied for table unpartitioned/msi, - "without SELECT privilege cannot replicate UPDATE or DELETE" -); + "without SELECT privilege cannot replicate UPDATE or DELETE"); # After granting SELECT, replication resumes. $node_subscriber->safe_psql( @@ -166,8 +160,7 @@ SET SESSION AUTHORIZATION regress_alice; GRANT SELECT ON alice.unpartitioned TO regress_admin; )); expect_replication("alice.unpartitioned", 2, 7, 11, - "with all privileges can replicate" -); + "with all privileges can replicate"); # Remove all privileges again. Instead, give the ability to SET ROLE to # regress_alice. @@ -189,8 +182,7 @@ expect_failure( 7, 11, qr/ERROR: ( [A-Z0-9]+:)? permission denied for table unpartitioned/msi, - "with SET ROLE but not INHERIT cannot replicate" -); + "with SET ROLE but not INHERIT cannot replicate"); # Now remove SET ROLE and add INHERIT and check that things start working. $node_subscriber->safe_psql( @@ -198,7 +190,6 @@ $node_subscriber->safe_psql( GRANT regress_alice TO regress_admin WITH INHERIT TRUE, SET FALSE; )); expect_replication("alice.unpartitioned", 3, 7, 13, - "with INHERIT but not SET ROLE can replicate" -); + "with INHERIT but not SET ROLE can replicate"); done_testing(); diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl index b832ddcf63e..4fabc441683 100644 --- a/src/test/subscription/t/100_bugs.pl +++ b/src/test/subscription/t/100_bugs.pl @@ -127,8 +127,8 @@ $node_twoways->start; for my $db (qw(d1 d2)) { $node_twoways->safe_psql('postgres', "CREATE DATABASE $db"); - $node_twoways->safe_psql($db, "CREATE TABLE t (f int)"); - $node_twoways->safe_psql($db, "CREATE TABLE t2 (f int)"); + $node_twoways->safe_psql($db, "CREATE TABLE t (f int)"); + $node_twoways->safe_psql($db, "CREATE TABLE t2 (f int)"); } my $rows = 3000; @@ -141,7 +141,7 @@ $node_twoways->safe_psql( }); $node_twoways->safe_psql('d2', - "CREATE SUBSCRIPTION testsub CONNECTION \$\$" + "CREATE SUBSCRIPTION testsub CONNECTION \$\$" . $node_twoways->connstr('d1') . "\$\$ PUBLICATION testpub WITH (create_slot=false, " . "slot_name='testslot')"); |