It's as opinionated as ever.
"index scan logged, json mode");
# Extension options.
-$log_contents = query_log(
- $node,
- "SELECT 1;",
+$log_contents = query_log($node, "SELECT 1;",
{ "auto_explain.log_extension_options" => "debug" });
like(
'prefetch mode succeeded');
# test_user should be unable to prewarm table/index without privileges
-($cmdret, $stdout, $stderr) =
- $node->psql(
- "postgres", "SELECT pg_prewarm('test');",
- extra_params => [ '--username' => 'test_user' ]);
-ok($stderr =~ /permission denied for table test/, 'pg_prewarm failed as expected');
-($cmdret, $stdout, $stderr) =
- $node->psql(
- "postgres", "SELECT pg_prewarm('test_idx');",
- extra_params => [ '--username' => 'test_user' ]);
-ok($stderr =~ /permission denied for index test_idx/, 'pg_prewarm failed as expected');
+($cmdret, $stdout, $stderr) = $node->psql(
+ "postgres",
+ "SELECT pg_prewarm('test');",
+ extra_params => [ '--username' => 'test_user' ]);
+ok($stderr =~ /permission denied for table test/,
+ 'pg_prewarm failed as expected');
+($cmdret, $stdout, $stderr) = $node->psql(
+ "postgres",
+ "SELECT pg_prewarm('test_idx');",
+ extra_params => [ '--username' => 'test_user' ]);
+ok($stderr =~ /permission denied for index test_idx/,
+ 'pg_prewarm failed as expected');
# test_user should be able to prewarm table/index with privileges
$node->safe_psql("postgres", "GRANT SELECT ON test TO test_user;");
-$result =
- $node->safe_psql(
- "postgres", "SELECT pg_prewarm('test');",
- extra_params => [ '--username' => 'test_user' ]);
+$result = $node->safe_psql(
+ "postgres",
+ "SELECT pg_prewarm('test');",
+ extra_params => [ '--username' => 'test_user' ]);
like($result, qr/^[1-9][0-9]*$/, 'pg_prewarm succeeded as expected');
-$result =
- $node->safe_psql(
- "postgres", "SELECT pg_prewarm('test_idx');",
- extra_params => [ '--username' => 'test_user' ]);
+$result = $node->safe_psql(
+ "postgres",
+ "SELECT pg_prewarm('test_idx');",
+ extra_params => [ '--username' => 'test_user' ]);
like($result, qr/^[1-9][0-9]*$/, 'pg_prewarm succeeded as expected');
# test autoprewarm_dump_now()
pg_stash_advice.persist_interval = 0});
$node->start;
-$node->safe_psql("postgres",
- "CREATE EXTENSION pg_stash_advice;\n");
+$node->safe_psql("postgres", "CREATE EXTENSION pg_stash_advice;\n");
# Create two stashes: one with 2 entries, one with 1 entry.
-$node->safe_psql("postgres", qq{
+$node->safe_psql(
+ "postgres", qq{
SELECT pg_create_advice_stash('stash_a');
SELECT pg_set_stashed_advice('stash_a', 1001, 'IndexScan(t)');
SELECT pg_set_stashed_advice('stash_a', 1002, E'line1\\nline2\\ttab\\\\backslash');
# Verify before restart.
my $result = $node->safe_psql("postgres",
- "SELECT stash_name, num_entries FROM pg_get_advice_stashes() ORDER BY stash_name");
+ "SELECT stash_name, num_entries FROM pg_get_advice_stashes() ORDER BY stash_name"
+);
is($result, "stash_a|2\nstash_b|1", 'stashes present before restart');
# Restart and verify the data survived.
$node->wait_for_log("loaded 2 advice stashes and 3 entries");
$result = $node->safe_psql("postgres",
- "SELECT stash_name, num_entries FROM pg_get_advice_stashes() ORDER BY stash_name");
+ "SELECT stash_name, num_entries FROM pg_get_advice_stashes() ORDER BY stash_name"
+);
is($result, "stash_a|2\nstash_b|1", 'stashes survived restart');
# Verify entry contents, including the one with special characters.
$result = $node->safe_psql("postgres",
- "SELECT stash_name, query_id, advice_string FROM pg_get_advice_stash_contents(NULL) ORDER BY stash_name, query_id");
-is($result,
+ "SELECT stash_name, query_id, advice_string FROM pg_get_advice_stash_contents(NULL) ORDER BY stash_name, query_id"
+);
+is( $result,
"stash_a|1001|IndexScan(t)\nstash_a|1002|line1\nline2\ttab\\backslash\nstash_b|2001|SeqScan(t)",
'entry contents survived restart with special characters intact');
# Add a third stash with 0 entries.
-$node->safe_psql("postgres", qq{
+$node->safe_psql(
+ "postgres", qq{
SELECT pg_create_advice_stash('stash_c');
});
$node->wait_for_log("loaded 3 advice stashes and 3 entries");
$result = $node->safe_psql("postgres",
- "SELECT stash_name, num_entries FROM pg_get_advice_stashes() ORDER BY stash_name");
-is($result, "stash_a|2\nstash_b|1\nstash_c|0", 'all three stashes survived second restart');
+ "SELECT stash_name, num_entries FROM pg_get_advice_stashes() ORDER BY stash_name"
+);
+is( $result,
+ "stash_a|2\nstash_b|1\nstash_c|0",
+ 'all three stashes survived second restart');
# Drop all stashes and verify the dump file is removed after restart.
-$node->safe_psql("postgres", qq{
+$node->safe_psql(
+ "postgres", qq{
SELECT pg_drop_advice_stash('stash_a');
SELECT pg_drop_advice_stash('stash_b');
SELECT pg_drop_advice_stash('stash_c');
"SELECT count(*) FROM pg_get_advice_stashes()");
is($result, "0", 'no stashes after dropping all and restarting');
-ok(!-f $node->data_dir . '/pg_stash_advice.tsv',
+ok( !-f $node->data_dir . '/pg_stash_advice.tsv',
'dump file removed after all stashes dropped');
$node->stop;
die "unable to parse lwlocklist.h line \"$_\"";
}
-die
- "$wait_event_lwlocks[$lwlock_count] defined in wait_event_names.txt but "
+die "$wait_event_lwlocks[$lwlock_count] defined in wait_event_names.txt but "
. " missing from lwlocklist.h"
if $lwlock_count < scalar @wait_event_lwlocks;
# Verify expected length after truncation.
$t_blocks = $primary->safe_psql('postgres',
"SELECT pg_relation_size('t') / current_setting('block_size')::int;");
-is($t_blocks, $rows_after_truncation, 'post-truncation row count as expected');
+is($t_blocks, $rows_after_truncation,
+ 'post-truncation row count as expected');
cmp_ok($t_blocks, '>', $target_blocks,
'post-truncation block count as expected');
# truncation limit. We can't just check whether the restored VM fork is
# the right size on disk, because it's so small that the incremental backup
# code will send the entire file.
-my $relfilenode = $primary->safe_psql('postgres',
- "SELECT pg_relation_filenode('t');");
-my $vm_limits = $primary->safe_psql('postgres',
+my $relfilenode =
+ $primary->safe_psql('postgres', "SELECT pg_relation_filenode('t');");
+my $vm_limits = $primary->safe_psql(
+ 'postgres',
"SELECT string_agg(relblocknumber::text, ',')
FROM pg_available_wal_summaries() s,
pg_wal_summary_contents(s.tli, s.start_lsn, s.end_lsn) c
WHERE c.relfilenode = $relfilenode
AND c.relforknumber = 2
AND c.is_limit_block;");
-is($vm_limits, '1',
- 'WAL summary has correct VM fork truncation limit');
+is($vm_limits, '1', 'WAL summary has correct VM fork truncation limit');
# Combine full and incremental backups. Before the fix, this failed because
# the INCREMENTAL file header contained an incorrect truncation_block_length
ok(check_mode_recursive("$tempdir/data", 0750, 0640));
}
-command_ok([ 'pg_ctl', 'restart', '--pgdata' => "$tempdir/data", '--log' => $logFileName ],
+command_ok(
+ [
+ 'pg_ctl', 'restart',
+ '--pgdata' => "$tempdir/data",
+ '--log' => $logFileName
+ ],
'pg_ctl restart with server running');
system_or_bail 'pg_ctl', 'stop', '--pgdata' => "$tempdir/data";
command_fails_like(
[ 'pg_dumpall', '-c', '-a' ],
qr/\Qpg_dumpall: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
- 'pg_dumpall: options -c/--clean and -a/--data-only cannot be used together');
+ 'pg_dumpall: options -c/--clean and -a/--data-only cannot be used together'
+);
command_fails_like(
[ 'pg_restore', '-c', '-a', '-f -' ],
#
# Either "all_runs" should be set or there should be a "like" list,
# even if it is empty. (This makes the test more self-documenting.)
- if (!defined($tests{$test}->{all_runs})
+ if ( !defined($tests{$test}->{all_runs})
&& !defined($tests{$test}->{like}))
{
die "missing \"like\" in test \"$test\"";
'postgres'
],
qr/unsupported filter object type: "table-data"/,
- "invalid syntax: invalid object type specified"
-);
+ "invalid syntax: invalid object type specified");
# Test missing object identifier pattern
open $inputfile, '>', "$tempdir/inputfile.txt"
slurp_file($slots_filename),
qr/The slot \"test_slot2\" has not consumed the WAL yet/m,
'the previous test failed due to unconsumed WALs');
-unlike(
- slurp_file($slots_filename),
- qr/test_slot3/m,
- 'caught-up slot is not reported');
+unlike(slurp_file($slots_filename),
+ qr/test_slot3/m, 'caught-up slot is not reported');
# ------------------------------
# The conflict detection slot should be created
$result = $new_sub->safe_psql('postgres',
- "SELECT xmin IS NOT NULL from pg_replication_slots WHERE slot_name = 'pg_conflict_detection'");
+ "SELECT xmin IS NOT NULL from pg_replication_slots WHERE slot_name = 'pg_conflict_detection'"
+);
is($result, qq(t), "conflict detection slot exists");
# Resume the initial sync and wait until all tables of subscription
# allow_in_place_tablespaces is available as far back as v10.
if ($old->pg_version >= 10)
{
- $new->append_conf('postgresql.conf', "allow_in_place_tablespaces = true");
- $old->append_conf('postgresql.conf', "allow_in_place_tablespaces = true");
+ $new->append_conf('postgresql.conf',
+ "allow_in_place_tablespaces = true");
+ $old->append_conf('postgresql.conf',
+ "allow_in_place_tablespaces = true");
}
# We can only test security labels if both the old and new installations
$old->safe_psql('postgres',
"CREATE DATABASE testdb3 TABLESPACE inplc_tblspc");
$old->safe_psql('postgres',
- "CREATE TABLE test5 TABLESPACE inplc_tblspc AS SELECT generate_series(503, 606)");
+ "CREATE TABLE test5 TABLESPACE inplc_tblspc AS SELECT generate_series(503, 606)"
+ );
$old->safe_psql('testdb3',
"CREATE TABLE test6 AS SELECT generate_series(607, 711)");
}
# While we are here, test handling of large objects.
- $old->safe_psql('postgres', q|
+ $old->safe_psql(
+ 'postgres', q|
CREATE ROLE regress_lo_1;
CREATE ROLE regress_lo_2;
if ($test_seclabel)
{
- $old->safe_psql('postgres', q|
+ $old->safe_psql(
+ 'postgres', q|
CREATE EXTENSION dummy_seclabel;
SELECT lo_from_bytea(4534, '\x00ffffff');
# Tests for in-place tablespaces.
if ($old->pg_version >= 10)
{
- $result = $new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
+ $result =
+ $new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
is($result, '104', "test5 data after pg_upgrade $mode");
- $result = $new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
+ $result =
+ $new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
is($result, '105', "test6 data after pg_upgrade $mode");
}
$result = $new->safe_psql('postgres', "SELECT lo_get(4533)");
is($result, '\x0f0f0f0f', "LO contents after upgrade");
$result = $new->safe_psql('postgres',
- "SELECT lomowner::regrole FROM pg_largeobject_metadata WHERE oid = 4533");
+ "SELECT lomowner::regrole FROM pg_largeobject_metadata WHERE oid = 4533"
+ );
is($result, 'regress_lo_1', "LO owner after upgrade");
$result = $new->safe_psql('postgres',
"SELECT lomacl FROM pg_largeobject_metadata WHERE oid = 4533");
- is($result, '{regress_lo_1=rw/regress_lo_1,regress_lo_2=r/regress_lo_1}',
+ is( $result,
+ '{regress_lo_1=rw/regress_lo_1,regress_lo_2=r/regress_lo_1}',
"LO ACL after upgrade");
if ($test_seclabel)
{
$result = $new->safe_psql('postgres', "SELECT lo_get(4534)");
is($result, '\x00ffffff', "LO contents after upgrade");
- $result = $new->safe_psql('postgres', q|
+ $result = $new->safe_psql(
+ 'postgres', q|
SELECT label FROM pg_seclabel WHERE objoid = 4534
AND classoid = 'pg_largeobject'::regclass
|);
'--checkpoint' => 'fast'
],
"tar backup with separate pg_wal.tar");
-command_ok(
- [ 'pg_verifybackup', $backup_path3 ],
+command_ok([ 'pg_verifybackup', $backup_path3 ],
'WAL verification succeeds with separate pg_wal.tar');
done_testing();
# Verify tar backup.
$primary->command_ok(
- [
- 'pg_verifybackup', '--exit-on-error', $backup_path,
- ],
+ [ 'pg_verifybackup', '--exit-on-error', $backup_path, ],
"verify backup, compression $method");
# Cleanup.
# Verify tar backup.
$primary->command_ok(
- [
- 'pg_verifybackup', '--exit-on-error', $backup_path,
- ],
+ [ 'pg_verifybackup', '--exit-on-error', $backup_path, ],
"verify backup, compression $method");
# Cleanup.
$$;
});
-my $contrecord_lsn = $node->safe_psql('postgres',
- 'SELECT pg_current_wal_insert_lsn()');
+my $contrecord_lsn =
+ $node->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn()');
# Generate contrecord record
$node->safe_psql('postgres',
qq{SELECT pg_logical_emit_message(true, 'test 026', repeat('xyzxz', 123456))}
'runs with start and end segment specified');
command_like(
[
- 'pg_waldump', '--quiet', '--path',
- $node->data_dir . '/pg_wal/', $start_walfile
+ 'pg_waldump', '--quiet',
+ '--path', $node->data_dir . '/pg_wal/',
+ $start_walfile
],
qr/^$/,
'no output with --quiet option');
my @files;
opendir my $dh, $directory or die "opendir: $!";
- while (my $entry = readdir $dh) {
+ while (my $entry = readdir $dh)
+ {
# Skip '.' and '..'
next if $entry eq '.' || $entry eq '..';
push @files, $entry;
{
my $path = $scenario->{'path'};
- SKIP:
+ SKIP:
{
skip "tar command is not available", 56
if (!defined $tar || $tar eq '') && $scenario->{'is_archive'};
- skip "$scenario->{'compression_method'} compression not supported by this build", 56
+ skip
+ "$scenario->{'compression_method'} compression not supported by this build",
+ 56
if !$scenario->{'enabled'} && $scenario->{'is_archive'};
- # create pg_wal archive
- if ($scenario->{'is_archive'})
- {
- generate_archive($path,
- $node->data_dir . '/pg_wal',
- $scenario->{'compression_flags'});
- }
+ # create pg_wal archive
+ if ($scenario->{'is_archive'})
+ {
+ generate_archive(
+ $path,
+ $node->data_dir . '/pg_wal',
+ $scenario->{'compression_flags'});
+ }
command_fails_like(
[ 'pg_waldump', '--path' => $path ],
like($lines[0], qr/WAL statistics/, "statistics on stdout");
is(grep(/^rmgr:/, @lines), 0, 'no rmgr lines output');
- @lines = test_pg_waldump($path, $start_lsn, $end_lsn, '--stats=record');
+ @lines =
+ test_pg_waldump($path, $start_lsn, $end_lsn, '--stats=record');
like($lines[0], qr/WAL statistics/, "statistics on stdout");
is(grep(/^rmgr:/, @lines), 0, 'no rmgr lines output');
- @lines = test_pg_waldump($path, $start_lsn, $end_lsn, '--rmgr' => 'Btree');
+ @lines =
+ test_pg_waldump($path, $start_lsn, $end_lsn, '--rmgr' => 'Btree');
is(grep(!/^rmgr: Btree/, @lines), 0, 'only Btree lines');
- @lines = test_pg_waldump($path, $start_lsn, $end_lsn, '--fork' => 'init');
+ @lines =
+ test_pg_waldump($path, $start_lsn, $end_lsn, '--fork' => 'init');
is(grep(!/fork init/, @lines), 0, 'only init fork lines');
@lines = test_pg_waldump($path, $start_lsn, $end_lsn,
'--relation' => "$default_ts_oid/$postgres_db_oid/$rel_t1_oid");
- is(grep(!/rel $default_ts_oid\/$postgres_db_oid\/$rel_t1_oid/, @lines),
- 0, 'only lines for selected relation');
+ is( grep(!/rel $default_ts_oid\/$postgres_db_oid\/$rel_t1_oid/,
+ @lines),
+ 0,
+ 'only lines for selected relation');
- @lines = test_pg_waldump($path, $start_lsn, $end_lsn,
+ @lines = test_pg_waldump(
+ $path, $start_lsn, $end_lsn,
'--relation' => "$default_ts_oid/$postgres_db_oid/$rel_i1a_oid",
'--block' => 1);
is(grep(!/\bblk 1\b/, @lines), 0, 'only lines for selected block');
# Test copy in pgbench
$node->pgbench(
- '-t 10',
- 2,
+ '-t 10', 2,
[],
- [ qr{COPY is not supported in pgbench, aborting} ],
+ [qr{COPY is not supported in pgbench, aborting}],
'Test copy in script',
{
'001_copy' => q{ COPY pgbench_accounts FROM stdin }
$node->safe_psql('postgres', 'DROP TABLE counter;');
# Test --continue-on-error
-$node->safe_psql('postgres',
- 'CREATE TABLE unique_table(i int unique);');
+$node->safe_psql('postgres', 'CREATE TABLE unique_table(i int unique);');
$node->pgbench(
'-n -t 10 --continue-on-error --failures-detailed',
0,
- [
- qr{processed: 1/10\b},
- qr{other failures: 9\b}
- ],
+ [ qr{processed: 1/10\b}, qr{other failures: 9\b} ],
[],
'test --continue-on-error',
{
is($ret, 2, 'server crash: psql exit code');
like($out, qr/before/, 'server crash: output before crash');
unlike($out, qr/AFTER/, 'server crash: no output after crash');
-like( $err, qr/psql:<stdin>:2: FATAL: terminating connection due to administrator command
+like(
+ $err,
+ qr/psql:<stdin>:2: FATAL: terminating connection due to administrator command
psql:<stdin>:2: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
'fails for invalid locale provider');
$node->command_fails_like(
- [ 'createdb', "invalid \n dbname" ],
- qr(contains a newline or carriage return character),
- 'fails if database name contains a newline character in name'
-);
+ [ 'createdb', "invalid \n dbname" ],
+ qr(contains a newline or carriage return character),
+ 'fails if database name contains a newline character in name');
$node->command_fails_like(
- [ 'createdb', "invalid \r dbname" ],
- qr(contains a newline or carriage return character),
- 'fails if database name contains a carriage return character in name'
-);
+ [ 'createdb', "invalid \r dbname" ],
+ qr(contains a newline or carriage return character),
+ 'fails if database name contains a carriage return character in name');
# Check use of templates with shared dependencies copied from the template.
my ($ret, $stdout, $stderr) = $node->psql(
qr/cannot vacuum all databases and a specific one at the same time/,
'cannot use option --all and a dbname as argument at the same time');
-$node->safe_psql('postgres', q|
+$node->safe_psql(
+ 'postgres', q|
CREATE TABLE regression_vacuumdb_test AS select generate_series(1, 10) a, generate_series(2, 11) b;
ALTER TABLE regression_vacuumdb_test ADD COLUMN c INT GENERATED ALWAYS AS (a + b);
|);
$node->issues_sql_unlike(
[
- 'vacuumdb', '--analyze-only', '--dry-run',
- '--missing-stats-only', '-t',
- 'regression_vacuumdb_test', 'postgres'
+ 'vacuumdb', '--analyze-only',
+ '--dry-run', '--missing-stats-only',
+ '-t', 'regression_vacuumdb_test',
+ 'postgres'
],
qr/statement:\ ANALYZE/sx,
'--missing-stats-only --dry-run');
'--missing-stats-only with no missing partition stats');
$node->safe_psql('postgres',
- "CREATE TABLE parent_table (a INT) PARTITION BY LIST (a);\n"
+ "CREATE TABLE parent_table (a INT) PARTITION BY LIST (a);\n"
. "CREATE TABLE child_table PARTITION OF parent_table FOR VALUES IN (1);\n"
. "INSERT INTO parent_table VALUES (1);\n");
$node->issues_sql_like(
- [
- 'vacuumdb', '--analyze-only', 'postgres'
- ],
+ [ 'vacuumdb', '--analyze-only', 'postgres' ],
qr/statement: ANALYZE public.parent_table/s,
'--analyze-only updates statistics for partitioned tables');
$node->issues_sql_unlike(
- [
- 'vacuumdb', '--analyze-only', 'postgres'
- ],
+ [ 'vacuumdb', '--analyze-only', 'postgres' ],
qr/statement:\ VACUUM/sx,
'--analyze-only does not run vacuum');
my $srvfile_nested_2 = "$td/pg_service_nested_2.conf";
copy($srvfile_valid, $srvfile_nested_2)
or die "Could not copy $srvfile_valid to $srvfile_nested_2: $!";
-append_to_file($srvfile_nested_2,
- 'servicefile=' . $srvfile_default . "\n");
+append_to_file($srvfile_nested_2, 'servicefile=' . $srvfile_default . "\n");
# Set the fallback directory lookup of the service file to the temporary
# directory of this test. PGSYSCONFDIR is used if the service file
$node->append_conf('postgresql.conf', "log_connections = on\n");
# Needed to allow connect_fails to inspect postmaster log:
$node->append_conf('postgresql.conf', "log_min_messages = debug2");
-$node->append_conf('postgresql.conf', "password_expiration_warning_threshold = '1100d'");
+$node->append_conf('postgresql.conf',
+ "password_expiration_warning_threshold = '1100d'");
$node->start;
# Set up roles for password_expiration_warning_threshold test
my $current_year = 1900 + ${ [ localtime(time) ] }[5];
my $expire_year = $current_year - 1;
-$node->safe_psql(
- 'postgres',
- "CREATE ROLE expired LOGIN VALID UNTIL '$expire_year-01-01' PASSWORD 'pass'");
+$node->safe_psql('postgres',
+ "CREATE ROLE expired LOGIN VALID UNTIL '$expire_year-01-01' PASSWORD 'pass'"
+);
$expire_year = $current_year + 2;
-$node->safe_psql(
- 'postgres',
- "CREATE ROLE expiration_warnings LOGIN VALID UNTIL '$expire_year-01-01' PASSWORD 'pass'");
+$node->safe_psql('postgres',
+ "CREATE ROLE expiration_warnings LOGIN VALID UNTIL '$expire_year-01-01' PASSWORD 'pass'"
+);
$expire_year = $current_year + 5;
-$node->safe_psql(
- 'postgres',
- "CREATE ROLE no_warnings LOGIN VALID UNTIL '$expire_year-01-01' PASSWORD 'pass'");
+$node->safe_psql('postgres',
+ "CREATE ROLE no_warnings LOGIN VALID UNTIL '$expire_year-01-01' PASSWORD 'pass'"
+);
# Test behavior of log_connections GUC
#
SKIP:
{
skip "MD5 not supported" unless $md5_works;
- test_conn($node, 'user=md5_role', 'md5', 0,
- expected_stderr =>
- qr/authenticated with an MD5-encrypted password/,
+ test_conn(
+ $node, 'user=md5_role', 'md5', 0,
+ expected_stderr => qr/authenticated with an MD5-encrypted password/,
log_like =>
[qr/connection authenticated: identity="md5_role" method=md5/]);
}
$node->connect_fails(
"user=expired dbname=postgres",
"connection fails due to expired password",
- expected_stderr =>
- qr/password authentication failed for user "expired"/
-);
+ expected_stderr => qr/password authentication failed for user "expired"/);
$node->connect_ok(
"user=expiration_warnings dbname=postgres",
"connection succeeds with password expiration warning",
- expected_stderr =>
- qr/role password will expire soon/
-);
-$node->connect_ok(
- "user=no_warnings dbname=postgres",
- "connection succeeds with no password expiration warning"
-);
+ expected_stderr => qr/role password will expire soon/);
+$node->connect_ok("user=no_warnings dbname=postgres",
+ "connection succeeds with no password expiration warning");
# Test SYSTEM_USER <> NULL with parallel workers.
$node->safe_psql(
# Execute the test using the latest protocol version.
$node->command_ok(
[
- 'libpq_pipeline', @extraargs,
- $testname,
+ 'libpq_pipeline', @extraargs, $testname,
$node->connstr('postgres') . " max_protocol_version=latest"
],
"libpq_pipeline $testname");
qr/WARNING.*SNI is enabled; installed TLS init hook will be ignored/,
"server warns that init hook and SNI are incompatible");
# Ensure that the warning was printed once and not once per host line
- my $count =()= $log_contents =~ m/installed TLS init hook will be ignored/;
+ my $count = () =
+ $log_contents =~ m/installed TLS init hook will be ignored/;
is($count, 1, 'Only one WARNING');
}
{
my $node = shift;
- my $prev_worker_count = $node->safe_psql('postgres', 'SHOW io_min_workers');
+ my $prev_worker_count =
+ $node->safe_psql('postgres', 'SHOW io_min_workers');
# Verify that worker count can't be set to 0
change_number_of_io_workers($node, 0, $prev_worker_count, 1);
my ($result, $stdout, $stderr);
($result, $stdout, $stderr) =
- $node->psql('postgres', "ALTER SYSTEM SET io_min_workers = $worker_count");
+ $node->psql('postgres',
+ "ALTER SYSTEM SET io_min_workers = $worker_count");
$node->safe_psql('postgres', 'SELECT pg_reload_conf()');
if ($expect_failure)
like(
$stderr,
qr/$worker_count is outside the valid range for parameter "io_min_workers"/,
- "updating io_min_workers to $worker_count failed, as expected"
- );
+ "updating io_min_workers to $worker_count failed, as expected");
return $prev_worker_count;
}
note("Using test program: $test_prog");
my ($stdout, $stderr);
-my $result = run [ $test_prog ], '>', \$stdout, '2>', \$stderr;
+my $result = run [$test_prog], '>', \$stdout, '2>', \$stderr;
note("Test program output:");
note($stdout) if $stdout;
}
ok($result && $stdout =~ /SUCCESS.*O_CLOEXEC behavior verified/s,
- "O_CLOEXEC prevents handle inheritance");
+ "O_CLOEXEC prevents handle inheritance");
done_testing();
my $ecp = $node->safe_psql('postgres', 'show extension_control_path;');
-is($ecp, "\$system$sep$ext_dir$sep$ext_dir2",
+is( $ecp,
+ "\$system$sep$ext_dir$sep$ext_dir2",
"custom extension control directory path configured");
$node->safe_psql('postgres', "CREATE EXTENSION $ext_name");
# Test that a non-superuser is not able to read the extension location in
# pg_available_extensions
-$ret = $node->safe_psql('postgres',
+$ret = $node->safe_psql(
+ 'postgres',
"select location from pg_available_extensions where name = '$ext_name2'",
connstr => "user=$user");
is( $ret,
"<insufficient privilege>",
- "extension location is hidden in pg_available_extensions for users with insufficient privilege");
+ "extension location is hidden in pg_available_extensions for users with insufficient privilege"
+);
# Test that a non-superuser is not able to read the extension location in
# pg_available_extension_versions
-$ret = $node->safe_psql('postgres',
+$ret = $node->safe_psql(
+ 'postgres',
"select location from pg_available_extension_versions where name = '$ext_name2'",
connstr => "user=$user");
is( $ret,
"<insufficient privilege>",
- "extension location is hidden in pg_available_extension_versions for users with insufficient privilege");
+ "extension location is hidden in pg_available_extension_versions for users with insufficient privilege"
+);
# Ensure that extensions installed in $system are still visible when used with
# custom extension control path.
is(scalar(@sample_intersect),
0, "no parameters marked as NOT_IN_SAMPLE in postgresql.conf.sample");
-is(scalar(@lines_with_tabs), 0, "no lines with tabs in postgresql.conf.sample");
+is(scalar(@lines_with_tabs),
+ 0, "no lines with tabs in postgresql.conf.sample");
# These would log some information only on errors.
foreach my $param (@missing_from_file)
$node->safe_psql('postgres', 'TRUNCATE TABLE test.tblparted');
############################################################################
-note('Test: REINDEX on partitioned table, cache inval between two get_partition_ancestors');
+note(
+ 'Test: REINDEX on partitioned table, cache inval between two get_partition_ancestors'
+);
$s1 = $node->background_psql('postgres', on_error_stop => 0);
$s2 = $node->background_psql('postgres', on_error_stop => 0);
$node->safe_psql('postgres', 'CREATE ROLE regress_role_ddl_test1');
my $result = $node->safe_psql('postgres',
q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_test1')});
-like($result,
+like(
+ $result,
qr/CREATE ROLE regress_role_ddl_test1 .* NOLOGIN/,
'basic role DDL');
# Role with multiple privileges
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
CREATE ROLE regress_role_ddl_test2
LOGIN SUPERUSER CREATEDB CREATEROLE
CONNECTION LIMIT 5
like($result, qr/VALID UNTIL '2030-12-31/, 'role with VALID UNTIL');
# Role with configuration parameters
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
ALTER ROLE regress_role_ddl_test1 SET work_mem TO '256MB';
ALTER ROLE regress_role_ddl_test1 SET search_path TO myschema, public});
$result = $node->safe_psql('postgres',
like($result, qr/SET search_path TO/, 'role with search_path setting');
# Role with database-specific configuration (needs a real database)
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
CREATE DATABASE regression_ddlutils_test
TEMPLATE template0 ENCODING 'UTF8' LC_COLLATE 'C' LC_CTYPE 'C';
ALTER ROLE regress_role_ddl_test2
IN DATABASE regression_ddlutils_test SET work_mem TO '128MB'});
$result = $node->safe_psql('postgres',
q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_test2')});
-like($result,
+like(
+ $result,
qr/IN DATABASE regression_ddlutils_test SET work_mem TO '128MB'/,
'role with database-specific setting');
$node->safe_psql('postgres', q{CREATE ROLE "regress_role-with-dash"});
$result = $node->safe_psql('postgres',
q{SELECT * FROM pg_get_role_ddl('regress_role-with-dash')});
-like($result, qr/"regress_role-with-dash"/,
- 'role name requiring quoting');
+like($result, qr/"regress_role-with-dash"/, 'role name requiring quoting');
# Pretty-printed output
$result = $node->safe_psql('postgres',
- q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_test2', 'pretty', 'true')});
+ q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_test2', 'pretty', 'true')}
+);
like($result, qr/\n\s+SUPERUSER/, 'role pretty-print indents attributes');
# Role with memberships
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
CREATE ROLE regress_role_ddl_grantor CREATEROLE;
CREATE ROLE regress_role_ddl_group1;
CREATE ROLE regress_role_ddl_group2;
RESET ROLE});
$result = $node->safe_psql('postgres',
q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_member')});
-like($result, qr/GRANT regress_role_ddl_group1 TO regress_role_ddl_member/,
+like(
+ $result,
+ qr/GRANT regress_role_ddl_group1 TO regress_role_ddl_member/,
'role with memberships includes GRANT');
like($result, qr/SET FALSE/, 'membership includes SET FALSE');
like($result, qr/ADMIN TRUE/, 'membership includes ADMIN TRUE');
# Memberships suppressed
$result = $node->safe_psql('postgres',
- q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_member', 'memberships', 'false')});
+ q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_member', 'memberships', 'false')}
+);
unlike($result, qr/GRANT/, 'memberships suppressed');
# Non-existent role (should error)
-my ($ret, $stdout, $stderr) = $node->psql('postgres',
- q{SELECT * FROM pg_get_role_ddl(9999999::oid)});
+my ($ret, $stdout, $stderr) =
+ $node->psql('postgres', q{SELECT * FROM pg_get_role_ddl(9999999::oid)});
isnt($ret, 0, 'non-existent role errors');
like($stderr, qr/does not exist/, 'non-existent role error message');
# NULL input (should return no rows)
-$result = $node->safe_psql('postgres',
- q{SELECT count(*) FROM pg_get_role_ddl(NULL)});
+$result =
+ $node->safe_psql('postgres', q{SELECT count(*) FROM pg_get_role_ddl(NULL)});
is($result, '0', 'NULL role returns no rows');
# Permission check: revoke SELECT on pg_authid
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
CREATE ROLE regress_role_ddl_noaccess;
REVOKE SELECT ON pg_authid FROM PUBLIC});
-($ret, $stdout, $stderr) = $node->psql('postgres',
+($ret, $stdout, $stderr) = $node->psql(
+ 'postgres',
q{SET ROLE regress_role_ddl_noaccess;
SELECT * FROM pg_get_role_ddl('regress_role_ddl_test1')});
isnt($ret, 0, 'role DDL denied without pg_authid access');
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
GRANT SELECT ON pg_authid TO PUBLIC});
########################################################################
# Set up: the test database was already created above for role tests.
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
ALTER DATABASE regression_ddlutils_test OWNER TO regress_role_ddl_test2;
ALTER DATABASE regression_ddlutils_test CONNECTION LIMIT 123;
ALTER DATABASE regression_ddlutils_test SET random_page_cost = 2.0;
# Invalid option
($ret, $stdout, $stderr) = $node->psql('postgres',
- q{SELECT * FROM pg_get_database_ddl('regression_ddlutils_test', 'owner', 'invalid')});
+ q{SELECT * FROM pg_get_database_ddl('regression_ddlutils_test', 'owner', 'invalid')}
+);
isnt($ret, 0, 'invalid boolean option errors');
like($stderr, qr/invalid value/, 'invalid option error message');
# Duplicate option
-($ret, $stdout, $stderr) = $node->psql('postgres',
+($ret, $stdout, $stderr) = $node->psql(
+ 'postgres',
q{SELECT * FROM pg_get_database_ddl('regression_ddlutils_test',
'owner', 'false', 'owner', 'true')});
isnt($ret, 0, 'duplicate option errors');
# Basic output (without locale details)
-$result = ddl_filter($node->safe_psql('postgres',
- q{SELECT pg_get_database_ddl
+$result = ddl_filter(
+ $node->safe_psql(
+ 'postgres',
+ q{SELECT pg_get_database_ddl
FROM pg_get_database_ddl('regression_ddlutils_test')}));
-like($result, qr/CREATE DATABASE regression_ddlutils_test/,
+like(
+ $result,
+ qr/CREATE DATABASE regression_ddlutils_test/,
'database DDL includes CREATE');
like($result, qr/TEMPLATE = template0/, 'database DDL includes TEMPLATE');
like($result, qr/ENCODING = 'UTF8'/, 'database DDL includes ENCODING');
-like($result, qr/OWNER TO regress_role_ddl_test2/, 'database DDL includes OWNER');
+like(
+ $result,
+ qr/OWNER TO regress_role_ddl_test2/,
+ 'database DDL includes OWNER');
like($result, qr/CONNECTION LIMIT = 123/, 'database DDL includes CONNLIMIT');
-like($result, qr/SET random_page_cost TO '2.0'/,
+like(
+ $result,
+ qr/SET random_page_cost TO '2.0'/,
'database DDL includes GUC setting');
# Pretty-printed output
-$result = ddl_filter($node->safe_psql('postgres',
- q{SELECT pg_get_database_ddl
+$result = ddl_filter(
+ $node->safe_psql(
+ 'postgres',
+ q{SELECT pg_get_database_ddl
FROM pg_get_database_ddl('regression_ddlutils_test',
'pretty', 'true', 'tablespace', 'false')}));
like($result, qr/\n\s+WITH TEMPLATE/, 'database DDL pretty-prints WITH');
# Permission check
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
REVOKE CONNECT ON DATABASE regression_ddlutils_test FROM PUBLIC});
-($ret, $stdout, $stderr) = $node->psql('postgres',
+($ret, $stdout, $stderr) = $node->psql(
+ 'postgres',
q{SET ROLE regress_role_ddl_noaccess;
SELECT * FROM pg_get_database_ddl('regression_ddlutils_test')});
isnt($ret, 0, 'database DDL denied without CONNECT');
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
GRANT CONNECT ON DATABASE regression_ddlutils_test TO PUBLIC});
isnt($ret, 0, 'non-existent tablespace errors');
# Non-existent tablespace by OID
-($ret, $stdout, $stderr) = $node->psql('postgres',
- q{SELECT * FROM pg_get_tablespace_ddl(0::oid)});
+($ret, $stdout, $stderr) =
+ $node->psql('postgres', q{SELECT * FROM pg_get_tablespace_ddl(0::oid)});
isnt($ret, 0, 'non-existent tablespace OID errors');
# NULL input (name and OID variants)
is($result, '0', 'NULL tablespace OID returns no rows');
# Tablespace name requiring quoting
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
SET allow_in_place_tablespaces = true;
CREATE TABLESPACE "regress_ tblsp" OWNER regress_role_ddl_test1
LOCATION ''});
like($result, qr/"regress_ tblsp"/, 'tablespace name is quoted');
# Rename and add options; reuse this tablespace for the remaining tests
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
ALTER TABLESPACE "regress_ tblsp" RENAME TO regress_allopt_tblsp;
ALTER TABLESPACE regress_allopt_tblsp
SET (seq_page_cost = '1.5', random_page_cost = '1.1234567890',
# Tablespace with multiple options
$result = $node->safe_psql('postgres',
q{SELECT * FROM pg_get_tablespace_ddl('regress_allopt_tblsp')});
-like($result, qr/CREATE TABLESPACE regress_allopt_tblsp/,
+like(
+ $result,
+ qr/CREATE TABLESPACE regress_allopt_tblsp/,
'tablespace DDL includes CREATE');
-like($result, qr/OWNER regress_role_ddl_test1/,
+like(
+ $result,
+ qr/OWNER regress_role_ddl_test1/,
'tablespace DDL includes OWNER');
like($result, qr/seq_page_cost='1.5'/, 'tablespace DDL includes options');
# Pretty-printed output
-$result = $node->safe_psql('postgres',
+$result = $node->safe_psql(
+ 'postgres',
q{SELECT * FROM pg_get_tablespace_ddl('regress_allopt_tblsp',
'pretty', 'true')});
like($result, qr/\n\s+OWNER/, 'tablespace DDL pretty-prints OWNER');
# Owner suppressed
-$result = $node->safe_psql('postgres',
+$result = $node->safe_psql(
+ 'postgres',
q{SELECT * FROM pg_get_tablespace_ddl('regress_allopt_tblsp',
'owner', 'false')});
unlike($result, qr/OWNER/, 'tablespace DDL owner suppressed');
# Lookup by OID
-$result = $node->safe_psql('postgres', q{
+$result = $node->safe_psql(
+ 'postgres', q{
SELECT pg_get_tablespace_ddl
FROM pg_get_tablespace_ddl(
(SELECT oid FROM pg_tablespace
WHERE spcname = 'regress_allopt_tblsp'))});
-like($result, qr/CREATE TABLESPACE regress_allopt_tblsp/,
+like(
+ $result,
+ qr/CREATE TABLESPACE regress_allopt_tblsp/,
'tablespace DDL by OID');
# Permission check
-$node->safe_psql('postgres',
- q{REVOKE SELECT ON pg_tablespace FROM PUBLIC});
-($ret, $stdout, $stderr) = $node->psql('postgres',
+$node->safe_psql('postgres', q{REVOKE SELECT ON pg_tablespace FROM PUBLIC});
+($ret, $stdout, $stderr) = $node->psql(
+ 'postgres',
q{SET ROLE regress_role_ddl_noaccess;
SELECT * FROM pg_get_tablespace_ddl('regress_allopt_tblsp')});
isnt($ret, 0, 'tablespace DDL denied without pg_tablespace access');
-$node->safe_psql('postgres', q{
+$node->safe_psql(
+ 'postgres', q{
GRANT SELECT ON pg_tablespace TO PUBLIC});
$node->stop;
system($ENV{PG_REGRESS} . " "
. "--bindir= "
. "--dlpath=\"$dlpath\" "
- . "--host=" . $node->host . " "
- . "--port=" . $node->port . " "
+ . "--host="
+ . $node->host . " "
+ . "--port="
+ . $node->port . " "
. "--schedule=$srcdir/src/test/regress/parallel_schedule "
. "--max-concurrent-tests=20 "
. "--inputdir=\"$inputdir\" "
$node->safe_psql("postgres", "CREATE EXTENSION test_shmem;");
# Check that the attach counter is incremented on a new connection
-my $attach_count1 = $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
-my $attach_count2 = $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
-cmp_ok($attach_count2, '>', $attach_count1, "attach callback is called in each backend");
+my $attach_count1 =
+ $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
+my $attach_count2 =
+ $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
+cmp_ok($attach_count2, '>', $attach_count1,
+ "attach callback is called in each backend");
$node->stop;
###
# Test that loading via shared_preload_libraries also works
###
-$node->append_conf('postgresql.conf', "shared_preload_libraries = 'test_shmem'");
+$node->append_conf('postgresql.conf',
+ "shared_preload_libraries = 'test_shmem'");
$node->start;
# When loaded via shared_preload_libraries, the attach callback is
# called or not, depending on whether this is an EXEC_BACKEND build.
-my $exec_backend = $node->safe_psql("postgres", "SHOW debug_exec_backend;") eq 'on';
-$attach_count1 = $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
-$attach_count2 = $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
+my $exec_backend =
+ $node->safe_psql("postgres", "SHOW debug_exec_backend;") eq 'on';
+$attach_count1 =
+ $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
+$attach_count2 =
+ $node->safe_psql("postgres", "SELECT get_test_shmem_attach_count();");
if ($exec_backend)
{
- cmp_ok($attach_count2, '>', $attach_count1, "attach callback is called in each backend when loaded via shared_preload_libraries");
+ cmp_ok($attach_count2, '>', $attach_count1,
+ "attach callback is called in each backend when loaded via shared_preload_libraries"
+ );
}
else
{
- ok($attach_count1 == 0 && $attach_count2 == 0, "attach callback is not called when loaded via shared_preload_libraries");
+ ok( $attach_count1 == 0 && $attach_count2 == 0,
+ "attach callback is not called when loaded via shared_preload_libraries"
+ );
}
$node->stop;
{
if ($dbnames{"contrib_regression_btree_gist"})
{
- _add_st($result, 'contrib_regression_btree_gist',
+ _add_st(
+ $result,
+ 'contrib_regression_btree_gist',
"drop index if exists public.inettmp_a_a1_idx");
- _add_st($result, 'contrib_regression_btree_gist',
+ _add_st(
+ $result,
+ 'contrib_regression_btree_gist',
"drop index if exists public.inetidx");
- _add_st($result, 'contrib_regression_btree_gist',
+ _add_st(
+ $result,
+ 'contrib_regression_btree_gist',
"drop index public.cidridx");
}
if ($dbnames{"regression_btree_gist"})
local $Test::Builder::Level = $Test::Builder::Level + 1;
- note "issuing query $query_cnt via background psql: $query" unless !$params{verbose};
+ note "issuing query $query_cnt via background psql: $query"
+ unless !$params{verbose};
$self->{timeout}->start() if (defined($self->{query_timer_restart}));
explain {
stdout => $self->{stdout},
stderr => $self->{stderr},
- } unless !$params{verbose};
+ }
+ unless !$params{verbose};
die "psql query timed out" if $self->{timeout}->is_expired;
my $log =
PostgreSQL::Test::Utils::slurp_file($self->logfile, $log_location);
unlike($log, $params{log_unlike}, "unexpected fragment found in log")
- if defined $params{log_unlike};
+ if defined $params{log_unlike};
like($log, $params{log_like}, "expected fragment not found in log")
- if defined $params{log_like};
+ if defined $params{log_like};
}
if ($ret != 0)
my $exc_save = $@;
# we need a dummy $stderr from hereon, if we didn't collect it
- if (! defined $stderr)
+ if (!defined $stderr)
{
my $errtxt = "<not collected>";
$stderr = \$errtxt;
),
't',
"last inactive time for slot $slot_name is valid on node $name")
- or croak "could not validate captured inactive_since for slot $slot_name";
+ or croak
+ "could not validate captured inactive_since for slot $slot_name";
return $inactive_since;
}
diag(join(" ", @$cmd));
- for my $channel (['stdout', $stdout], ['stderr', $stderr])
+ for my $channel ([ 'stdout', $stdout ], [ 'stderr', $stderr ])
{
my ($name, $output) = @$channel;
next unless $output;
my @lines = split /\n/, $output;
if (@lines > 60)
{
- diag(join("\n", @lines[0 .. 29]));
+ diag(join("\n", @lines[ 0 .. 29 ]));
diag("... " . (@lines - 60) . " lines omitted ...");
- diag(join("\n", @lines[-30 .. -1]));
+ diag(join("\n", @lines[ -30 .. -1 ]));
}
else
{
# before even looking up the user. Hence you now get "sorry, too many
# clients already" instead of "role does not exist" error. Test that
# to ensure that we have used up all the slots.
-$node->connect_fails("dbname=postgres user=invalid_user",
+$node->connect_fails(
+ "dbname=postgres user=invalid_user",
"connection is rejected when all slots are in use",
expected_stderr => qr/FATAL: sorry, too many clients already/);
if ($reply ne 'N')
{
$sock->close();
- plan skip_all =>
- "server accepted SSL; test requires SSL to be rejected";
+ plan skip_all => "server accepted SSL; test requires SSL to be rejected";
}
# Send GSSENCRequest, reject or bypass test.
if ($reply ne 'N')
{
$sock->close();
- plan skip_all =>
- "server accepted GSS; test requires GSS to be rejected";
+ plan skip_all => "server accepted GSS; test requires GSS to be rejected";
}
my $log_offset = -s $node->logfile;
$sock->close();
$node->wait_for_log(qr/FATAL: .* unsupported frontend protocol 1234.5679/,
- $log_offset);
+ $log_offset);
# Check extra connection with a simple query.
my $result = $node->safe_psql('postgres', 'select 1;');
# Confirm that the logical replication launcher, a background worker
# without the never-restart flag, has also restarted successfully.
-is($node->poll_query_until('postgres',
- "SELECT count(*) = 1 FROM pg_stat_activity WHERE backend_type = 'logical replication launcher'"),
+is( $node->poll_query_until(
+ 'postgres',
+ "SELECT count(*) = 1 FROM pg_stat_activity WHERE backend_type = 'logical replication launcher'"
+ ),
'1',
'logical replication launcher restarted after crash');
# message should not be issued
ok( !$node_standby->log_contains(
- "invalidating obsolete replication slot \"no_conflict_inactiveslot\"", $logstart),
+ "invalidating obsolete replication slot \"no_conflict_inactiveslot\"",
+ $logstart),
'inactiveslot slot invalidation is not logged with vacuum on conflict_test'
);
ok( !$node_standby->log_contains(
- "invalidating obsolete replication slot \"no_conflict_activeslot\"", $logstart),
+ "invalidating obsolete replication slot \"no_conflict_activeslot\"",
+ $logstart),
'activeslot slot invalidation is not logged with vacuum on conflict_test'
);
##################################################
# Recreate the slot by creating a subscription on the subscriber, keep it disabled.
-$subscriber1->safe_psql('postgres', qq[
+$subscriber1->safe_psql(
+ 'postgres', qq[
CREATE TABLE push_wal (a int);
- CREATE SUBSCRIPTION regress_mysub1 CONNECTION '$publisher_connstr' PUBLICATION regress_mypub WITH (slot_name = lsub1_slot, failover = true, enabled = false);]);
+ CREATE SUBSCRIPTION regress_mysub1 CONNECTION '$publisher_connstr' PUBLICATION regress_mypub WITH (slot_name = lsub1_slot, failover = true, enabled = false);]
+);
# Create some DDL on the primary so that the slot lags behind the standby
$primary->safe_psql('postgres', "CREATE TABLE push_wal (a int);");
# further calls, call the API in a background process.
my $h = $standby2->background_psql('postgres', on_error_stop => 0);
-$h->query_until(qr/start/, q(
+$h->query_until(
+ qr/start/, q(
\echo start
SELECT pg_sync_replication_slots();
));
$primary->reload;
# Enable the Subscription, so that the remote slot catches up
-$subscriber1->safe_psql('postgres', "ALTER SUBSCRIPTION regress_mysub1 ENABLE");
+$subscriber1->safe_psql('postgres',
+ "ALTER SUBSCRIPTION regress_mysub1 ENABLE");
$subscriber1->wait_for_subscription_sync;
# Create xl_running_xacts on the primary to speed up restart_lsn advancement.
# Confirm from the log that the slot is sync-ready now.
$standby2->wait_for_log(
- qr/newly created replication slot \"lsub1_slot\" is sync-ready now/,
- $log_offset);
+ qr/newly created replication slot \"lsub1_slot\" is sync-ready now/,
+ $log_offset);
$h->quit;
# Create a standby
my $standby = PostgreSQL::Test::Cluster->new('standby');
-$standby->init_from_backup(
- $primary, $backup_name,
- has_streaming => 1);
+$standby->init_from_backup($primary, $backup_name, has_streaming => 1);
my $connstr_1 = $primary->connstr;
$standby->append_conf(
primary_conninfo = '$connstr_1 dbname=postgres'
));
-$primary->safe_psql('postgres',
+$primary->safe_psql(
+ 'postgres',
q{SELECT pg_create_logical_replication_slot('failover_slot', 'test_decoding', false, false, true);
SELECT pg_create_physical_replication_slot('phys_slot');}
);
# Wait until the checkpoint stops right before invalidating slots
note('waiting for injection_point');
-$standby->wait_for_event('checkpointer', 'restartpoint-before-slot-invalidation');
+$standby->wait_for_event('checkpointer',
+ 'restartpoint-before-slot-invalidation');
note('injection_point is reached');
# Enable slot sync worker to synchronize the failover slot to the standby
$standby->reload;
# Wait for the slot to be synced
-$standby->poll_query_until(
- 'postgres',
- "SELECT COUNT(*) > 0 FROM pg_replication_slots WHERE slot_name = 'failover_slot'");
+$standby->poll_query_until('postgres',
+ "SELECT COUNT(*) > 0 FROM pg_replication_slots WHERE slot_name = 'failover_slot'"
+);
# Release the checkpointer
-$standby->safe_psql('postgres',
+$standby->safe_psql(
+ 'postgres',
q{select injection_points_wakeup('restartpoint-before-slot-invalidation');
select injection_points_detach('restartpoint-before-slot-invalidation')});
'--log' => $primary->logfile,
'start',
],
- "cannot start server with wal_level='minimal' as there is in-use logical slot");
+ "cannot start server with wal_level='minimal' as there is in-use logical slot"
+);
my $logfile = slurp_file($primary->logfile());
like(
$node->append_conf('sslconfig.conf', 'ssl=on');
$node->append_conf('sslconfig.conf', $backend->set_server_cert(\%params));
# use lists of ECDH curves and cipher suites for syntax testing
- $node->append_conf('sslconfig.conf',
- 'ssl_groups=prime256v1:secp521r1');
+ $node->append_conf('sslconfig.conf', 'ssl_groups=prime256v1:secp521r1');
$node->append_conf('sslconfig.conf',
'ssl_tls13_ciphers=TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256');
# Confirm the ERROR is reported because max_prepared_transactions is zero
$node_subscriber->wait_for_log(
- qr/ERROR: ( [A-Z0-9]+:)? prepared transactions are disabled/,
- $offset);
+ qr/ERROR: ( [A-Z0-9]+:)? prepared transactions are disabled/, $offset);
# Confirm that the parallel apply worker has encountered an error. The check
# focuses on the worker type as a keyword, since the error message content may
# differ based on whether the leader initially detected the parallel apply
# worker's failure or received a signal from it.
$node_subscriber->wait_for_log(
- qr/ERROR: .*logical replication parallel apply worker.*/,
- $offset);
+ qr/ERROR: .*logical replication parallel apply worker.*/, $offset);
# Set max_prepared_transactions to correct value to resume the replication
$node_subscriber->append_conf('postgresql.conf',
$node_A->wait_for_catchup($subname_BA);
my $result = $node_B->safe_psql('postgres', "SELECT * FROM tab;");
-is($result, qq(1|1
+is( $result, qq(1|1
2|2), 'check replicated insert on node B');
# Disable the logical replication from node B to node A
$node_B->safe_psql('postgres', "UPDATE tab SET b = 3 WHERE a = 1;");
$node_A->safe_psql('postgres', "DELETE FROM tab WHERE a = 1;");
-($cmdret, $stdout, $stderr) = $node_A->psql(
- 'postgres', qq(VACUUM (verbose) public.tab;)
-);
+($cmdret, $stdout, $stderr) =
+ $node_A->psql('postgres', qq(VACUUM (verbose) public.tab;));
like(
$stderr,
$log_location = -s $node_A->logfile;
-$node_A->safe_psql(
- 'postgres', "ALTER SUBSCRIPTION $subname_AB ENABLE;");
+$node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB ENABLE;");
$node_B->wait_for_catchup($subname_AB);
$logfile = slurp_file($node_A->logfile(), $log_location);
$log_location = -s $node_A->logfile;
-$node_A->safe_psql(
- 'postgres', "ALTER SUBSCRIPTION $subname_AB ENABLE;");
+$node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB ENABLE;");
$node_B->wait_for_catchup($subname_AB);
$logfile = slurp_file($node_A->logfile(), $log_location);
$node_B->safe_psql('postgres', "ALTER PUBLICATION tap_pub_B ADD TABLE tab");
$node_A->safe_psql('postgres',
- "ALTER SUBSCRIPTION $subname_AB REFRESH PUBLICATION WITH (copy_data = false)");
+ "ALTER SUBSCRIPTION $subname_AB REFRESH PUBLICATION WITH (copy_data = false)"
+);
###############################################################################
# Test that publisher's transactions marked with DELAY_CHKPT_IN_COMMIT prevent
# commit after marking DELAY_CHKPT_IN_COMMIT flag.
if ($injection_points_supported != 0)
{
- $node_B->append_conf('postgresql.conf',
+ $node_B->append_conf(
+ 'postgresql.conf',
"shared_preload_libraries = 'injection_points'
max_prepared_transactions = 1");
$node_B->restart;
);
# Wait until the backend enters the injection point
- $node_B->wait_for_event('client backend', 'commit-after-delay-checkpoint');
+ $node_B->wait_for_event('client backend',
+ 'commit-after-delay-checkpoint');
# Confirm the update is suspended
- $result =
- $node_B->safe_psql('postgres', 'SELECT * FROM tab WHERE a = 1');
+ $result = $node_B->safe_psql('postgres', 'SELECT * FROM tab WHERE a = 1');
is($result, qq(1|1), 'publisher sees the old row');
# Delete the row on the subscriber. The deleted row should be retained due to a
# Confirm that the apply worker keeps requesting publisher status, while
# awaiting the prepared transaction to commit. Thus, the request log should
# appear more than once.
- $node_A->wait_for_log(
- qr/sending publisher status request message/,
+ $node_A->wait_for_log(qr/sending publisher status request message/,
$log_location);
$log_location = -s $node_A->logfile;
- $node_A->wait_for_log(
- qr/sending publisher status request message/,
+ $node_A->wait_for_log(qr/sending publisher status request message/,
$log_location);
# Confirm that the dead tuple cannot be removed
ok($pub_session->quit, "close publisher session");
# Confirm that the transaction committed
- $result =
- $node_B->safe_psql('postgres', 'SELECT * FROM tab WHERE a = 1');
+ $result = $node_B->safe_psql('postgres', 'SELECT * FROM tab WHERE a = 1');
is($result, qq(1|2), 'publisher sees the new row');
# Ensure the UPDATE is replayed on subscriber
'update target row was deleted in tab');
# Remember the next transaction ID to be assigned
- $next_xid =
- $node_A->safe_psql('postgres', "SELECT txid_current() + 1;");
+ $next_xid = $node_A->safe_psql('postgres', "SELECT txid_current() + 1;");
# Confirm that the xmin value is advanced to the latest nextXid after the
# prepared transaction on the publisher has been committed.
# Enable failover to activate the synchronized_standby_slots setting
$node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB DISABLE;");
-$node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB SET (failover = true);");
+$node_A->safe_psql('postgres',
+ "ALTER SUBSCRIPTION $subname_AB SET (failover = true);");
$node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB ENABLE;");
# Insert a record
"the xmin value of slot 'pg_conflict_detection' is invalid on Node A");
$result = $node_A->safe_psql('postgres',
- "SELECT subretentionactive FROM pg_subscription WHERE subname='$subname_AB';");
+ "SELECT subretentionactive FROM pg_subscription WHERE subname='$subname_AB';"
+);
is($result, qq(f), 'retention is inactive');
###############################################################################
"the xmin value of slot 'pg_conflict_detection' is valid on Node A");
$result = $node_A->safe_psql('postgres',
- "SELECT subretentionactive FROM pg_subscription WHERE subname='$subname_AB';");
+ "SELECT subretentionactive FROM pg_subscription WHERE subname='$subname_AB';"
+);
is($result, qq(t), 'retention is active');
###############################################################################
# removing all the subscriptions.
###############################################################################
-$node_B->safe_psql(
- 'postgres', "DROP SUBSCRIPTION $subname_BA");
+$node_B->safe_psql('postgres', "DROP SUBSCRIPTION $subname_BA");
ok( $node_B->poll_query_until(
'postgres',
),
"the slot 'pg_conflict_detection' has been dropped on Node B");
-$node_A->safe_psql(
- 'postgres', "DROP SUBSCRIPTION $subname_AB");
+$node_A->safe_psql('postgres', "DROP SUBSCRIPTION $subname_AB");
ok( $node_A->poll_query_until(
'postgres',
$node_publisher->connstr . ' dbname=postgres user=regress_seq_repl';
$log_offset = -s $node_subscriber->logfile;
-$node_subscriber->safe_psql(
- 'postgres',
+$node_subscriber->safe_psql('postgres',
"ALTER SUBSCRIPTION regress_seq_sub CONNECTION '$publisher_limited_connstr'"
);
-$node_subscriber->safe_psql(
- 'postgres',
- "ALTER SUBSCRIPTION regress_seq_sub REFRESH SEQUENCES"
-);
+$node_subscriber->safe_psql('postgres',
+ "ALTER SUBSCRIPTION regress_seq_sub REFRESH SEQUENCES");
$node_subscriber->wait_for_log(
qr/WARNING: ( [A-Z0-9]+:)? missing sequence on publisher \("public.regress_s2"\)/,
$file =~ m/-(\d+)\./;
my $major_version = $1;
die "file name $file is not in the expected format\n"
- unless defined $major_version;
+ unless defined $major_version;
open(my $fh, '<', $file) || die "could not open file $file: $!\n";
open(my $tfh, '>', $tmpfile) || die "could not open file $tmpfile: $!\n";