mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
perltidy: Add option --nooutdent-long-quotes
This commit is contained in:
@ -57,10 +57,11 @@ $node->start;
|
||||
# Create 3 roles with different password methods for each one. The same
|
||||
# password is used for all of them.
|
||||
$node->safe_psql('postgres',
|
||||
"SET password_encryption='scram-sha-256'; CREATE ROLE scram_role LOGIN PASSWORD 'pass';"
|
||||
"SET password_encryption='scram-sha-256'; CREATE ROLE scram_role LOGIN PASSWORD 'pass';"
|
||||
);
|
||||
$node->safe_psql('postgres',
|
||||
"SET password_encryption='md5'; CREATE ROLE md5_role LOGIN PASSWORD 'pass';");
|
||||
"SET password_encryption='md5'; CREATE ROLE md5_role LOGIN PASSWORD 'pass';"
|
||||
);
|
||||
$ENV{"PGPASSWORD"} = 'pass';
|
||||
|
||||
# For "trust" method, all users should be able to connect.
|
||||
|
@ -150,7 +150,7 @@ note "simple bind";
|
||||
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="uid=" ldapsuffix=",dc=example,dc=net"}
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="uid=" ldapsuffix=",dc=example,dc=net"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -166,7 +166,7 @@ note "search+bind";
|
||||
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn"}
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -199,7 +199,7 @@ note "search filters";
|
||||
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"}
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -212,7 +212,7 @@ note "search filters in LDAP URLs";
|
||||
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub?(|(uid=\$username)(mail=\$username))"}
|
||||
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub?(|(uid=\$username)(mail=\$username))"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -226,7 +226,7 @@ test_access($node, 'test2@example.net', 0, 'search filter finds by mail');
|
||||
# override. It might be useful in a case like this.
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"}
|
||||
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -238,7 +238,7 @@ note "diagnostic message";
|
||||
# note bad ldapprefix with a question mark that triggers a diagnostic message
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="?uid=" ldapsuffix=""}
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="?uid=" ldapsuffix=""}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -250,7 +250,7 @@ note "TLS";
|
||||
# request StartTLS with ldaptls=1
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)" ldaptls=1}
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)" ldaptls=1}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -260,7 +260,7 @@ test_access($node, 'test1', 0, 'StartTLS');
|
||||
# request LDAPS with ldapscheme=ldaps
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapscheme=ldaps ldapport=$ldaps_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)"}
|
||||
qq{local all all ldap ldapserver=$ldap_server ldapscheme=ldaps ldapport=$ldaps_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -270,7 +270,7 @@ test_access($node, 'test1', 0, 'LDAPS');
|
||||
# request LDAPS with ldapurl=ldaps://...
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)"}
|
||||
qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)"}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
@ -280,7 +280,7 @@ test_access($node, 'test1', 0, 'LDAPS with URL');
|
||||
# bad combination of LDAPS and StartTLS
|
||||
unlink($node->data_dir . '/pg_hba.conf');
|
||||
$node->append_conf('pg_hba.conf',
|
||||
qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)" ldaptls=1}
|
||||
qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)" ldaptls=1}
|
||||
);
|
||||
$node->restart;
|
||||
|
||||
|
@ -22,7 +22,7 @@ $node->safe_psql(
|
||||
'
|
||||
);
|
||||
my $count = $node->safe_psql('postgres',
|
||||
"select count(*) from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
|
||||
"select count(*) from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
|
||||
);
|
||||
is($count, '1', "initial index state is correct");
|
||||
|
||||
@ -31,11 +31,11 @@ $node->safe_psql('postgres',
|
||||
|
||||
$node->poll_query_until(
|
||||
'postgres',
|
||||
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)",
|
||||
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)",
|
||||
't');
|
||||
|
||||
$count = $node->safe_psql('postgres',
|
||||
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
|
||||
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
|
||||
);
|
||||
is($count, 't', "index got summarized");
|
||||
$node->stop;
|
||||
|
@ -16,11 +16,11 @@ $node->start;
|
||||
$node->safe_psql('postgres',
|
||||
'create table t as select now from (select now(), pg_sleep(1)) f');
|
||||
my $true = $node->safe_psql('postgres',
|
||||
'select t.now - ts.* < \'1s\' from t, pg_class c, pg_xact_commit_timestamp(c.xmin) ts where relname = \'t\''
|
||||
'select t.now - ts.* < \'1s\' from t, pg_class c, pg_xact_commit_timestamp(c.xmin) ts where relname = \'t\''
|
||||
);
|
||||
is($true, 't', 'commit TS is set');
|
||||
my $ts = $node->safe_psql('postgres',
|
||||
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
|
||||
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
|
||||
);
|
||||
|
||||
# Verify that we read the same TS after crash recovery
|
||||
@ -28,6 +28,6 @@ $node->stop('immediate');
|
||||
$node->start;
|
||||
|
||||
my $recovered_ts = $node->safe_psql('postgres',
|
||||
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
|
||||
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
|
||||
);
|
||||
is($recovered_ts, $ts, 'commit TS remains after crash recovery');
|
||||
|
@ -28,7 +28,7 @@ for my $i (1 .. 10)
|
||||
$master->safe_psql('postgres', "create table t$i()");
|
||||
}
|
||||
my $master_ts = $master->safe_psql('postgres',
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
|
||||
);
|
||||
my $master_lsn =
|
||||
$master->safe_psql('postgres', 'select pg_current_wal_lsn()');
|
||||
@ -37,7 +37,7 @@ $standby->poll_query_until('postgres',
|
||||
or die "standby never caught up";
|
||||
|
||||
my $standby_ts = $standby->safe_psql('postgres',
|
||||
qq{select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = 't10'}
|
||||
qq{select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = 't10'}
|
||||
);
|
||||
is($master_ts, $standby_ts, "standby gives same value as master");
|
||||
|
||||
@ -52,7 +52,7 @@ $standby->safe_psql('postgres', 'checkpoint');
|
||||
|
||||
# This one should raise an error now
|
||||
my ($ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql('postgres',
|
||||
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t10\''
|
||||
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t10\''
|
||||
);
|
||||
is($ret, 3, 'standby errors when master turned feature off');
|
||||
is($standby_ts_stdout, '',
|
||||
|
@ -40,7 +40,7 @@ $standby->restart;
|
||||
|
||||
my ($psql_ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql(
|
||||
'postgres',
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
|
||||
);
|
||||
is($psql_ret, 3, 'expect error when getting commit timestamp after restart');
|
||||
is($standby_ts_stdout, '', "standby does not return a value after restart");
|
||||
@ -58,7 +58,7 @@ system_or_bail('pg_ctl', '-D', $standby->data_dir, 'promote');
|
||||
|
||||
$standby->safe_psql('postgres', "create table t11()");
|
||||
my $standby_ts = $standby->safe_psql('postgres',
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't11'}
|
||||
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't11'}
|
||||
);
|
||||
isnt($standby_ts, '',
|
||||
"standby gives valid value ($standby_ts) after promotion");
|
||||
|
@ -190,7 +190,7 @@ my %tests = (
|
||||
'ALTER EXTENSION test_pg_dump' => {
|
||||
create_order => 9,
|
||||
create_sql =>
|
||||
'ALTER EXTENSION test_pg_dump ADD TABLE regress_pg_dump_table_added;',
|
||||
'ALTER EXTENSION test_pg_dump ADD TABLE regress_pg_dump_table_added;',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE public.regress_pg_dump_table_added (\E
|
||||
\n\s+\Qcol1 integer NOT NULL,\E
|
||||
@ -231,7 +231,7 @@ my %tests = (
|
||||
'CREATE TABLE regress_pg_dump_table_added' => {
|
||||
create_order => 7,
|
||||
create_sql =>
|
||||
'CREATE TABLE regress_pg_dump_table_added (col1 int not null, col2 int);',
|
||||
'CREATE TABLE regress_pg_dump_table_added (col1 int not null, col2 int);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE public.regress_pg_dump_table_added (\E
|
||||
\n\s+\Qcol1 integer NOT NULL,\E
|
||||
@ -288,7 +288,7 @@ my %tests = (
|
||||
'GRANT SELECT regress_pg_dump_table_added pre-ALTER EXTENSION' => {
|
||||
create_order => 8,
|
||||
create_sql =>
|
||||
'GRANT SELECT ON regress_pg_dump_table_added TO regress_dump_test_role;',
|
||||
'GRANT SELECT ON regress_pg_dump_table_added TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT SELECT ON TABLE public.regress_pg_dump_table_added TO regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
@ -297,7 +297,7 @@ my %tests = (
|
||||
'REVOKE SELECT regress_pg_dump_table_added post-ALTER EXTENSION' => {
|
||||
create_order => 10,
|
||||
create_sql =>
|
||||
'REVOKE SELECT ON regress_pg_dump_table_added FROM regress_dump_test_role;',
|
||||
'REVOKE SELECT ON regress_pg_dump_table_added FROM regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QREVOKE SELECT ON TABLE public.regress_pg_dump_table_added FROM regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
|
@ -389,7 +389,7 @@ sub set_replication_conf
|
||||
if ($TestLib::windows_os)
|
||||
{
|
||||
print $hba
|
||||
"host replication all $test_localhost/32 sspi include_realm=1 map=regress\n";
|
||||
"host replication all $test_localhost/32 sspi include_realm=1 map=regress\n";
|
||||
}
|
||||
close $hba;
|
||||
}
|
||||
@ -652,7 +652,7 @@ sub init_from_backup
|
||||
$params{has_restoring} = 0 unless defined $params{has_restoring};
|
||||
|
||||
print
|
||||
"# Initializing node \"$node_name\" from backup \"$backup_name\" of node \"$root_name\"\n";
|
||||
"# Initializing node \"$node_name\" from backup \"$backup_name\" of node \"$root_name\"\n";
|
||||
croak "Backup \"$backup_name\" does not exist at $backup_path"
|
||||
unless -d $backup_path;
|
||||
|
||||
@ -1272,7 +1272,7 @@ sub psql
|
||||
die "connection error: '$$stderr'\nwhile running '@psql_params'"
|
||||
if $ret == 2;
|
||||
die
|
||||
"error running SQL: '$$stderr'\nwhile running '@psql_params' with sql '$sql'"
|
||||
"error running SQL: '$$stderr'\nwhile running '@psql_params' with sql '$sql'"
|
||||
if $ret == 3;
|
||||
die "psql returns $ret: '$$stderr'\nwhile running '@psql_params'";
|
||||
}
|
||||
@ -1544,7 +1544,7 @@ sub wait_for_catchup
|
||||
. $lsn_expr . " on "
|
||||
. $self->name . "\n";
|
||||
my $query =
|
||||
qq[SELECT $lsn_expr <= ${mode}_lsn FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';];
|
||||
qq[SELECT $lsn_expr <= ${mode}_lsn FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';];
|
||||
$self->poll_query_until('postgres', $query)
|
||||
or croak "timed out waiting for catchup";
|
||||
print "done\n";
|
||||
@ -1586,7 +1586,7 @@ sub wait_for_slot_catchup
|
||||
. $target_lsn . " on "
|
||||
. $self->name . "\n";
|
||||
my $query =
|
||||
qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name';];
|
||||
qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name';];
|
||||
$self->poll_query_until('postgres', $query)
|
||||
or croak "timed out waiting for catchup";
|
||||
print "done\n";
|
||||
@ -1661,7 +1661,7 @@ sub slot
|
||||
'restart_lsn');
|
||||
return $self->query_hash(
|
||||
'postgres',
|
||||
"SELECT __COLUMNS__ FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name'",
|
||||
"SELECT __COLUMNS__ FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name'",
|
||||
@columns);
|
||||
}
|
||||
|
||||
@ -1736,7 +1736,7 @@ sub pg_recvlogical_upto
|
||||
unless $timeout->is_expired;
|
||||
|
||||
die
|
||||
"$exc_save waiting for endpos $endpos with stdout '$stdout', stderr '$stderr'"
|
||||
"$exc_save waiting for endpos $endpos with stdout '$stdout', stderr '$stderr'"
|
||||
unless wantarray;
|
||||
}
|
||||
};
|
||||
@ -1751,7 +1751,7 @@ sub pg_recvlogical_upto
|
||||
else
|
||||
{
|
||||
die
|
||||
"pg_recvlogical exited with code '$ret', stdout '$stdout' and stderr '$stderr'"
|
||||
"pg_recvlogical exited with code '$ret', stdout '$stdout' and stderr '$stderr'"
|
||||
if $ret;
|
||||
return $stdout;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ sub test_target_session_attrs
|
||||
extra_params => [ '-d', $connstr ]);
|
||||
is( $status == $ret && $stdout eq $target_node->port,
|
||||
1,
|
||||
"connect to node $target_name if mode \"$mode\" and $node1_name,$node2_name listed"
|
||||
"connect to node $target_name if mode \"$mode\" and $node1_name,$node2_name listed"
|
||||
);
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ $node_master->safe_psql('postgres', 'CREATE TABLE replayed(val integer);');
|
||||
sub replay_check
|
||||
{
|
||||
my $newval = $node_master->safe_psql('postgres',
|
||||
'INSERT INTO replayed(val) SELECT coalesce(max(val),0) + 1 AS newval FROM replayed RETURNING val'
|
||||
'INSERT INTO replayed(val) SELECT coalesce(max(val),0) + 1 AS newval FROM replayed RETURNING val'
|
||||
);
|
||||
$node_master->wait_for_catchup($node_standby_1, 'replay',
|
||||
$node_master->lsn('insert'));
|
||||
|
@ -24,10 +24,11 @@ $node_master->safe_psql('postgres',
|
||||
qq[CREATE TABLE decoding_test(x integer, y text);]);
|
||||
|
||||
$node_master->safe_psql('postgres',
|
||||
qq[SELECT pg_create_logical_replication_slot('test_slot', 'test_decoding');]);
|
||||
qq[SELECT pg_create_logical_replication_slot('test_slot', 'test_decoding');]
|
||||
);
|
||||
|
||||
$node_master->safe_psql('postgres',
|
||||
qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,10) s;]
|
||||
qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,10) s;]
|
||||
);
|
||||
|
||||
# Basic decoding works
|
||||
@ -50,7 +51,7 @@ is($result, '', 'Decoding after fast restart repeats no rows');
|
||||
# Insert some rows and verify that we get the same results from pg_recvlogical
|
||||
# and the SQL interface.
|
||||
$node_master->safe_psql('postgres',
|
||||
qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,4) s;]
|
||||
qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,4) s;]
|
||||
);
|
||||
|
||||
my $expected = q{BEGIN
|
||||
@ -61,12 +62,12 @@ table public.decoding_test: INSERT: x[integer]:4 y[text]:'4'
|
||||
COMMIT};
|
||||
|
||||
my $stdout_sql = $node_master->safe_psql('postgres',
|
||||
qq[SELECT data FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]
|
||||
qq[SELECT data FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]
|
||||
);
|
||||
is($stdout_sql, $expected, 'got expected output from SQL decoding session');
|
||||
|
||||
my $endpos = $node_master->safe_psql('postgres',
|
||||
"SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
|
||||
"SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
|
||||
);
|
||||
print "waiting to replay $endpos\n";
|
||||
|
||||
@ -79,7 +80,7 @@ is($stdout_recv, $expected,
|
||||
'got same expected output from pg_recvlogical decoding session');
|
||||
|
||||
$node_master->poll_query_until('postgres',
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_slot' AND active_pid IS NULL)"
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_slot' AND active_pid IS NULL)"
|
||||
) or die "slot never became inactive";
|
||||
|
||||
$stdout_recv = $node_master->pg_recvlogical_upto(
|
||||
@ -94,13 +95,13 @@ $node_master->safe_psql('postgres', 'CREATE DATABASE otherdb');
|
||||
|
||||
is( $node_master->psql(
|
||||
'otherdb',
|
||||
"SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
|
||||
"SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
|
||||
),
|
||||
3,
|
||||
'replaying logical slot from another database fails');
|
||||
|
||||
$node_master->safe_psql('otherdb',
|
||||
qq[SELECT pg_create_logical_replication_slot('otherdb_slot', 'test_decoding');]
|
||||
qq[SELECT pg_create_logical_replication_slot('otherdb_slot', 'test_decoding');]
|
||||
);
|
||||
|
||||
# make sure you can't drop a slot while active
|
||||
@ -114,7 +115,7 @@ SKIP:
|
||||
[ 'pg_recvlogical', '-d', $node_master->connstr('otherdb'),
|
||||
'-S', 'otherdb_slot', '-f', '-', '--start' ]);
|
||||
$node_master->poll_query_until('otherdb',
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NOT NULL)"
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NOT NULL)"
|
||||
) or die "slot never became active";
|
||||
is($node_master->psql('postgres', 'DROP DATABASE otherdb'),
|
||||
3, 'dropping a DB with active logical slots fails');
|
||||
@ -124,7 +125,7 @@ SKIP:
|
||||
}
|
||||
|
||||
$node_master->poll_query_until('otherdb',
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NULL)"
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NULL)"
|
||||
) or die "slot never became inactive";
|
||||
|
||||
is($node_master->psql('postgres', 'DROP DATABASE otherdb'),
|
||||
|
@ -7,7 +7,7 @@ use Test::More tests => 11;
|
||||
|
||||
# Query checking sync_priority and sync_state of each standby
|
||||
my $check_sql =
|
||||
"SELECT application_name, sync_priority, sync_state FROM pg_stat_replication ORDER BY application_name;";
|
||||
"SELECT application_name, sync_priority, sync_state FROM pg_stat_replication ORDER BY application_name;";
|
||||
|
||||
# Check that sync_state of each standby is expected (waiting till it is).
|
||||
# If $setting is given, synchronous_standby_names is set to it and
|
||||
|
@ -48,7 +48,7 @@ $node_master->start;
|
||||
note "testing logical timeline following with a filesystem-level copy";
|
||||
|
||||
$node_master->safe_psql('postgres',
|
||||
"SELECT pg_create_logical_replication_slot('before_basebackup', 'test_decoding');"
|
||||
"SELECT pg_create_logical_replication_slot('before_basebackup', 'test_decoding');"
|
||||
);
|
||||
$node_master->safe_psql('postgres', "CREATE TABLE decoding(blah text);");
|
||||
$node_master->safe_psql('postgres',
|
||||
@ -60,7 +60,8 @@ $node_master->safe_psql('postgres',
|
||||
# the same physical copy trick, so:
|
||||
$node_master->safe_psql('postgres', 'CREATE DATABASE dropme;');
|
||||
$node_master->safe_psql('dropme',
|
||||
"SELECT pg_create_logical_replication_slot('dropme_slot', 'test_decoding');");
|
||||
"SELECT pg_create_logical_replication_slot('dropme_slot', 'test_decoding');"
|
||||
);
|
||||
|
||||
$node_master->safe_psql('postgres', 'CHECKPOINT;');
|
||||
|
||||
@ -95,7 +96,7 @@ is($node_master->slot('dropme_slot')->{'slot_name'},
|
||||
|
||||
# Back to testing failover...
|
||||
$node_master->safe_psql('postgres',
|
||||
"SELECT pg_create_logical_replication_slot('after_basebackup', 'test_decoding');"
|
||||
"SELECT pg_create_logical_replication_slot('after_basebackup', 'test_decoding');"
|
||||
);
|
||||
$node_master->safe_psql('postgres',
|
||||
"INSERT INTO decoding(blah) VALUES ('afterbb');");
|
||||
@ -141,7 +142,7 @@ $node_replica->safe_psql('postgres',
|
||||
|
||||
# Shouldn't be able to read from slot created after base backup
|
||||
($ret, $stdout, $stderr) = $node_replica->psql('postgres',
|
||||
"SELECT data FROM pg_logical_slot_peek_changes('after_basebackup', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');"
|
||||
"SELECT data FROM pg_logical_slot_peek_changes('after_basebackup', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');"
|
||||
);
|
||||
is($ret, 3, 'replaying from after_basebackup slot fails');
|
||||
like(
|
||||
@ -152,7 +153,7 @@ like(
|
||||
# Should be able to read from slot created before base backup
|
||||
($ret, $stdout, $stderr) = $node_replica->psql(
|
||||
'postgres',
|
||||
"SELECT data FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');",
|
||||
"SELECT data FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');",
|
||||
timeout => 30);
|
||||
is($ret, 0, 'replay from slot before_basebackup succeeds');
|
||||
|
||||
@ -174,7 +175,7 @@ is($stderr, '', 'replay from slot before_basebackup produces no stderr');
|
||||
# of the last transaction. There's no max(pg_lsn), so:
|
||||
|
||||
my $endpos = $node_replica->safe_psql('postgres',
|
||||
"SELECT lsn FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
|
||||
"SELECT lsn FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
|
||||
);
|
||||
|
||||
# now use the walsender protocol to peek the slot changes and make sure we see
|
||||
|
@ -177,7 +177,7 @@ recovery_target_timeline='latest'
|
||||
$node_standby->start;
|
||||
$psql_rc = $node_master->psql('postgres', "COMMIT PREPARED 'xact_012_1'");
|
||||
is($psql_rc, '0',
|
||||
"Restore of PGPROC_MAX_CACHED_SUBXIDS+ prepared transaction on promoted standby"
|
||||
"Restore of PGPROC_MAX_CACHED_SUBXIDS+ prepared transaction on promoted standby"
|
||||
);
|
||||
|
||||
$node_master->psql(
|
||||
@ -218,7 +218,7 @@ recovery_target_timeline='latest'
|
||||
$node_standby->start;
|
||||
$psql_rc = $node_master->psql('postgres', "ROLLBACK PREPARED 'xact_012_1'");
|
||||
is($psql_rc, '0',
|
||||
"Rollback of PGPROC_MAX_CACHED_SUBXIDS+ prepared transaction on promoted standby"
|
||||
"Rollback of PGPROC_MAX_CACHED_SUBXIDS+ prepared transaction on promoted standby"
|
||||
);
|
||||
|
||||
$node_master->psql(
|
||||
|
@ -111,7 +111,7 @@ SELECT 1;
|
||||
ok( pump_until(
|
||||
$killme,
|
||||
\$killme_stderr,
|
||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
|
||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
|
||||
),
|
||||
"psql query died successfully after SIGQUIT");
|
||||
$killme_stderr = '';
|
||||
@ -124,7 +124,7 @@ $killme->finish;
|
||||
ok( pump_until(
|
||||
$monitor,
|
||||
\$monitor_stderr,
|
||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
|
||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
|
||||
),
|
||||
"psql monitor died successfully after SIGQUIT");
|
||||
$monitor->finish;
|
||||
@ -204,7 +204,7 @@ $killme->finish;
|
||||
ok( pump_until(
|
||||
$monitor,
|
||||
\$monitor_stderr,
|
||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
|
||||
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
|
||||
),
|
||||
"psql monitor died successfully after SIGKILL");
|
||||
$monitor->finish;
|
||||
@ -220,7 +220,8 @@ is( $node->safe_psql('postgres', 'SELECT * FROM alive'),
|
||||
|
||||
is( $node->safe_psql(
|
||||
'postgres',
|
||||
'INSERT INTO alive VALUES($$before-orderly-restart$$) RETURNING status'),
|
||||
'INSERT INTO alive VALUES($$before-orderly-restart$$) RETURNING status'
|
||||
),
|
||||
'before-orderly-restart',
|
||||
'can still write after crash restart');
|
||||
|
||||
@ -228,7 +229,7 @@ is( $node->safe_psql(
|
||||
$node->restart();
|
||||
|
||||
is( $node->safe_psql('postgres', 'SELECT * FROM alive'),
|
||||
"committed-before-sigquit\ncommitted-before-sigkill\nbefore-orderly-restart",
|
||||
"committed-before-sigquit\ncommitted-before-sigkill\nbefore-orderly-restart",
|
||||
'data survived');
|
||||
|
||||
is( $node->safe_psql(
|
||||
|
@ -91,10 +91,10 @@ sub configure_test_server_for_ssl
|
||||
if (defined($password))
|
||||
{
|
||||
$node->psql('postgres',
|
||||
"SET password_encryption='$password_enc'; ALTER USER ssltestuser PASSWORD '$password';"
|
||||
"SET password_encryption='$password_enc'; ALTER USER ssltestuser PASSWORD '$password';"
|
||||
);
|
||||
$node->psql('postgres',
|
||||
"SET password_encryption='$password_enc'; ALTER USER anotheruser PASSWORD '$password';"
|
||||
"SET password_encryption='$password_enc'; ALTER USER anotheruser PASSWORD '$password';"
|
||||
);
|
||||
}
|
||||
|
||||
@ -161,14 +161,14 @@ sub configure_hba_for_ssl
|
||||
# When connecting to certdb, also check the client certificate.
|
||||
open my $hba, '>', "$pgdata/pg_hba.conf";
|
||||
print $hba
|
||||
"# TYPE DATABASE USER ADDRESS METHOD\n";
|
||||
"# TYPE DATABASE USER ADDRESS METHOD\n";
|
||||
print $hba
|
||||
"hostssl trustdb all $serverhost/32 $authmethod\n";
|
||||
"hostssl trustdb all $serverhost/32 $authmethod\n";
|
||||
print $hba
|
||||
"hostssl trustdb all ::1/128 $authmethod\n";
|
||||
"hostssl trustdb all ::1/128 $authmethod\n";
|
||||
print $hba
|
||||
"hostssl certdb all $serverhost/32 cert\n";
|
||||
"hostssl certdb all $serverhost/32 cert\n";
|
||||
print $hba
|
||||
"hostssl certdb all ::1/128 cert\n";
|
||||
"hostssl certdb all ::1/128 cert\n";
|
||||
close $hba;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ note "running client tests";
|
||||
switch_server_cert($node, 'server-cn-only');
|
||||
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test";
|
||||
|
||||
# The server should not accept non-SSL connections.
|
||||
test_connect_fails(
|
||||
@ -167,20 +167,20 @@ test_connect_ok(
|
||||
# A CRL belonging to a different CA is not accepted, fails
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/client.crl",
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/client.crl",
|
||||
qr/SSL error/,
|
||||
"CRL belonging to a different CA");
|
||||
|
||||
# With the correct CRL, succeeds (this cert is not revoked)
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl",
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl",
|
||||
"CRL with a non-revoked cert");
|
||||
|
||||
# Check that connecting with verify-full fails, when the hostname doesn't
|
||||
# match the hostname in the server's certificate.
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
|
||||
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
@ -193,14 +193,14 @@ test_connect_ok(
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"sslmode=verify-full host=wronghost.test",
|
||||
qr/\Qserver certificate for "common-name.pg-ssltest.test" does not match host name "wronghost.test"\E/,
|
||||
qr/\Qserver certificate for "common-name.pg-ssltest.test" does not match host name "wronghost.test"\E/,
|
||||
"mismatch between host name and server certificate sslmode=verify-full");
|
||||
|
||||
# Test Subject Alternative Names.
|
||||
switch_server_cert($node, 'server-multiple-alt-names');
|
||||
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
|
||||
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
@ -218,12 +218,12 @@ test_connect_ok(
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"host=wronghost.alt-name.pg-ssltest.test",
|
||||
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "wronghost.alt-name.pg-ssltest.test"\E/,
|
||||
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "wronghost.alt-name.pg-ssltest.test"\E/,
|
||||
"host name not matching with X.509 Subject Alternative Names");
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"host=deep.subdomain.wildcard.pg-ssltest.test",
|
||||
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/,
|
||||
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/,
|
||||
"host name not matching with X.509 Subject Alternative Names wildcard");
|
||||
|
||||
# Test certificate with a single Subject Alternative Name. (this gives a
|
||||
@ -231,7 +231,7 @@ qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names)
|
||||
switch_server_cert($node, 'server-single-alt-name');
|
||||
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
|
||||
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
@ -241,13 +241,13 @@ test_connect_ok(
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"host=wronghost.alt-name.pg-ssltest.test",
|
||||
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "wronghost.alt-name.pg-ssltest.test"\E/,
|
||||
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "wronghost.alt-name.pg-ssltest.test"\E/,
|
||||
"host name not matching with a single X.509 Subject Alternative Name");
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"host=deep.subdomain.wildcard.pg-ssltest.test",
|
||||
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/,
|
||||
"host name not matching with a single X.509 Subject Alternative Name wildcard"
|
||||
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/,
|
||||
"host name not matching with a single X.509 Subject Alternative Name wildcard"
|
||||
);
|
||||
|
||||
# Test server certificate with a CN and SANs. Per RFCs 2818 and 6125, the CN
|
||||
@ -255,7 +255,7 @@ qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match hos
|
||||
switch_server_cert($node, 'server-cn-and-alt-names');
|
||||
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
|
||||
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
@ -268,14 +268,14 @@ test_connect_ok(
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"host=common-name.pg-ssltest.test",
|
||||
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 1 other name) does not match host name "common-name.pg-ssltest.test"\E/,
|
||||
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 1 other name) does not match host name "common-name.pg-ssltest.test"\E/,
|
||||
"certificate with both a CN and SANs ignores CN");
|
||||
|
||||
# Finally, test a server certificate that has no CN or SANs. Of course, that's
|
||||
# not a very sensible certificate, but libpq should handle it gracefully.
|
||||
switch_server_cert($node, 'server-no-names');
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
|
||||
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
@ -291,7 +291,7 @@ test_connect_fails(
|
||||
switch_server_cert($node, 'server-revoked');
|
||||
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test";
|
||||
"user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test";
|
||||
|
||||
# Without the CRL, succeeds. With it, fails.
|
||||
test_connect_ok(
|
||||
@ -300,7 +300,7 @@ test_connect_ok(
|
||||
"connects without client-side CRL");
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl",
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl",
|
||||
qr/SSL error/,
|
||||
"does not connect with client-side CRL");
|
||||
|
||||
@ -311,7 +311,7 @@ test_connect_fails(
|
||||
note "running server tests";
|
||||
|
||||
$common_connstr =
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=require dbname=certdb hostaddr=$SERVERHOSTADDR";
|
||||
"sslrootcert=ssl/root+server_ca.crt sslmode=require dbname=certdb hostaddr=$SERVERHOSTADDR";
|
||||
|
||||
# no client cert
|
||||
test_connect_fails(
|
||||
@ -329,8 +329,8 @@ test_connect_ok(
|
||||
# client key with wrong permissions
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_wrongperms_tmp.key",
|
||||
qr!\Qprivate key file "ssl/client_wrongperms_tmp.key" has group or world access\E!,
|
||||
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_wrongperms_tmp.key",
|
||||
qr!\Qprivate key file "ssl/client_wrongperms_tmp.key" has group or world access\E!,
|
||||
"certificate authorization fails because of file permissions");
|
||||
|
||||
# client cert belonging to another user
|
||||
@ -338,19 +338,20 @@ test_connect_fails(
|
||||
$common_connstr,
|
||||
"user=anotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
|
||||
qr/certificate authentication failed for user "anotheruser"/,
|
||||
"certificate authorization fails with client cert belonging to another user");
|
||||
"certificate authorization fails with client cert belonging to another user"
|
||||
);
|
||||
|
||||
# revoked client cert
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"user=ssltestuser sslcert=ssl/client-revoked.crt sslkey=ssl/client-revoked_tmp.key",
|
||||
"user=ssltestuser sslcert=ssl/client-revoked.crt sslkey=ssl/client-revoked_tmp.key",
|
||||
qr/SSL error/,
|
||||
"certificate authorization fails with revoked client cert");
|
||||
|
||||
# intermediate client_ca.crt is provided by client, and isn't in server's ssl_ca_file
|
||||
switch_server_cert($node, 'server-cn-only', 'root_ca');
|
||||
$common_connstr =
|
||||
"user=ssltestuser dbname=certdb sslkey=ssl/client_tmp.key sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
|
||||
"user=ssltestuser dbname=certdb sslkey=ssl/client_tmp.key sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
|
||||
|
||||
test_connect_ok(
|
||||
$common_connstr,
|
||||
|
@ -68,7 +68,7 @@ else
|
||||
test_connect_fails(
|
||||
$common_connstr,
|
||||
"scram_channel_binding=tls-server-end-point",
|
||||
qr/channel binding type "tls-server-end-point" is not supported by this build/,
|
||||
qr/channel binding type "tls-server-end-point" is not supported by this build/,
|
||||
"SCRAM authentication with tls-server-end-point as channel binding");
|
||||
$number_of_tests++;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ $node_publisher->safe_psql('postgres',
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO tab_mixed (a, b) VALUES (1, 'foo')");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
|
||||
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
|
||||
);
|
||||
|
||||
# Setup structure on subscriber
|
||||
@ -49,7 +49,7 @@ $node_subscriber->safe_psql('postgres',
|
||||
|
||||
# replication of the table with included index
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
|
||||
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
|
||||
);
|
||||
|
||||
# Setup logical replication
|
||||
@ -58,21 +58,21 @@ $node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include"
|
||||
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_mixed, tab_include"
|
||||
);
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins");
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub, tap_pub_ins_only"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub, tap_pub_ins_only"
|
||||
);
|
||||
|
||||
$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";
|
||||
|
||||
@ -168,20 +168,20 @@ my $oldpid = $node_publisher->safe_psql('postgres',
|
||||
"SELECT pid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
);
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"ALTER SUBSCRIPTION tap_sub CONNECTION 'application_name=$appname $publisher_connstr'"
|
||||
"ALTER SUBSCRIPTION tap_sub CONNECTION 'application_name=$appname $publisher_connstr'"
|
||||
);
|
||||
$node_publisher->poll_query_until('postgres',
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
) or die "Timed out while waiting for apply to restart";
|
||||
|
||||
$oldpid = $node_publisher->safe_psql('postgres',
|
||||
"SELECT pid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
);
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only WITH (copy_data = false)"
|
||||
"ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only WITH (copy_data = false)"
|
||||
);
|
||||
$node_publisher->poll_query_until('postgres',
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
) or die "Timed out while waiting for apply to restart";
|
||||
|
||||
$node_publisher->safe_psql('postgres',
|
||||
@ -230,7 +230,7 @@ $oldpid = $node_publisher->safe_psql('postgres',
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"ALTER SUBSCRIPTION tap_sub RENAME TO tap_sub_renamed");
|
||||
$node_publisher->poll_query_until('postgres',
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';"
|
||||
) or die "Timed out while waiting for apply to restart";
|
||||
|
||||
# check all the cleanup
|
||||
|
@ -103,14 +103,14 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (slot_name = tap_sub_slot)"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (slot_name = tap_sub_slot)"
|
||||
);
|
||||
|
||||
$node_publisher->wait_for_catchup($appname);
|
||||
|
||||
# Wait for initial sync to finish as well
|
||||
my $synced_query =
|
||||
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
|
||||
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
|
||||
$node_subscriber->poll_query_until('postgres', $synced_query)
|
||||
or die "Timed out while waiting for subscriber to synchronize data";
|
||||
|
||||
|
@ -19,14 +19,14 @@ $node_subscriber->start;
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE tab_fk (bid int PRIMARY KEY);");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE TABLE tab_fk_ref (id int PRIMARY KEY, bid int REFERENCES tab_fk (bid));"
|
||||
"CREATE TABLE tab_fk_ref (id int PRIMARY KEY, bid int REFERENCES tab_fk (bid));"
|
||||
);
|
||||
|
||||
# Setup structure on subscriber
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE tab_fk (bid int PRIMARY KEY);");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE TABLE tab_fk_ref (id int PRIMARY KEY, bid int REFERENCES tab_fk (bid));"
|
||||
"CREATE TABLE tab_fk_ref (id int PRIMARY KEY, bid int REFERENCES tab_fk (bid));"
|
||||
);
|
||||
|
||||
# Setup logical replication
|
||||
@ -36,7 +36,7 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)"
|
||||
);
|
||||
|
||||
$node_publisher->wait_for_catchup($appname);
|
||||
|
@ -34,14 +34,14 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
);
|
||||
|
||||
$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";
|
||||
|
||||
@ -57,7 +57,7 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
# recreate the subscription, it will try to do initial copy
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
);
|
||||
|
||||
# but it will be stuck on data copy as it will fail on constraint
|
||||
@ -79,12 +79,12 @@ is($result, qq(20), 'initial data synced for second sub');
|
||||
|
||||
# now check another subscription for the same node pair
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub2 CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)"
|
||||
"CREATE SUBSCRIPTION tap_sub2 CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)"
|
||||
);
|
||||
|
||||
# wait for it to start
|
||||
$node_subscriber->poll_query_until('postgres',
|
||||
"SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL"
|
||||
"SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL"
|
||||
) or die "Timed out while waiting for subscriber to start";
|
||||
|
||||
# and drop both subscriptions
|
||||
@ -101,7 +101,7 @@ $node_subscriber->safe_psql('postgres', "DELETE FROM tab_rep;");
|
||||
|
||||
# recreate the subscription again
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
);
|
||||
|
||||
# and wait for data sync to finish again
|
||||
|
@ -27,14 +27,14 @@ my $appname = 'encoding_test';
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION mypub FOR ALL TABLES;");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
);
|
||||
|
||||
$node_publisher->wait_for_catchup($appname);
|
||||
|
||||
# Wait for initial sync to finish as well
|
||||
my $synced_query =
|
||||
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
|
||||
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
|
||||
$node_subscriber->poll_query_until('postgres', $synced_query)
|
||||
or die "Timed out while waiting for subscriber to synchronize data";
|
||||
|
||||
|
@ -23,14 +23,14 @@ my $appname = 'encoding_test';
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION mypub FOR ALL TABLES;");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
);
|
||||
|
||||
$node_publisher->wait_for_catchup($appname);
|
||||
|
||||
# Wait for initial sync to finish as well
|
||||
my $synced_query =
|
||||
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
|
||||
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
|
||||
$node_subscriber->poll_query_until('postgres', $synced_query)
|
||||
or die "Timed out while waiting for subscriber to synchronize data";
|
||||
|
||||
|
@ -23,7 +23,7 @@ my $appname = 'replication_test';
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION mypub FOR ALL TABLES;");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
);
|
||||
|
||||
$node_publisher->wait_for_catchup($appname);
|
||||
|
@ -23,7 +23,7 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
# 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, e int GENERATED BY DEFAULT AS IDENTITY)"
|
||||
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999, e int GENERATED BY DEFAULT AS IDENTITY)"
|
||||
);
|
||||
|
||||
# Setup logical replication
|
||||
@ -33,14 +33,14 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub"
|
||||
);
|
||||
|
||||
$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";
|
||||
|
||||
@ -73,7 +73,7 @@ $node_publisher->safe_psql('postgres',
|
||||
$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"
|
||||
"SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab"
|
||||
);
|
||||
is($result, qq(2|2|2), 'check extra columns contain locally changed data');
|
||||
|
||||
|
@ -19,7 +19,7 @@ my $appname = 'replication_test';
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION mypub FOR ALL TABLES;");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
|
||||
);
|
||||
|
||||
$node_publisher->safe_psql('postgres',
|
||||
|
@ -52,18 +52,18 @@ $node_publisher->safe_psql('postgres',
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION pub3 FOR TABLE tab3, tab4");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr application_name=sub1' PUBLICATION pub1"
|
||||
"CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr application_name=sub1' PUBLICATION pub1"
|
||||
);
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION sub2 CONNECTION '$publisher_connstr application_name=sub2' PUBLICATION pub2"
|
||||
"CREATE SUBSCRIPTION sub2 CONNECTION '$publisher_connstr application_name=sub2' PUBLICATION pub2"
|
||||
);
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION sub3 CONNECTION '$publisher_connstr application_name=sub3' PUBLICATION pub3"
|
||||
"CREATE SUBSCRIPTION sub3 CONNECTION '$publisher_connstr application_name=sub3' PUBLICATION pub3"
|
||||
);
|
||||
|
||||
# Wait for initial sync of all subscriptions
|
||||
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";
|
||||
|
||||
|
Reference in New Issue
Block a user