diff options
author | Tom Lane | 2024-05-14 20:34:50 +0000 |
---|---|---|
committer | Tom Lane | 2024-05-14 20:34:50 +0000 |
commit | da256a4a7fdcca35fe7ca808686ad3de6ee22306 (patch) | |
tree | 863d6a21cd148b40add73ae45bdedcf0acc001ee /src/bin | |
parent | 3ddbac368c205fce1f293de1fe60c1b479800746 (diff) |
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files.
The pgindent part of this is pretty small, consisting mainly of
fixing up self-inflicted formatting damage from patches that
hadn't bothered to add their new typedefs to typedefs.list.
In order to keep it from making anything worse, I manually added
a dozen or so typedefs that appeared in the existing typedefs.list
but not in the buildfarm's list. Perhaps we should formalize that,
or better find a way to get those typedefs into the automatic list.
pgperltidy is as opinionated as always, and reformat-dat-files too.
Diffstat (limited to 'src/bin')
25 files changed, 464 insertions, 325 deletions
diff --git a/src/bin/pg_amcheck/t/002_nonesuch.pl b/src/bin/pg_amcheck/t/002_nonesuch.pl index 5e7980e5bdb..67d700ea07a 100644 --- a/src/bin/pg_amcheck/t/002_nonesuch.pl +++ b/src/bin/pg_amcheck/t/002_nonesuch.pl @@ -302,9 +302,7 @@ $node->safe_psql( )); $node->command_checks_all( - [ - 'pg_amcheck', '-d', 'regression_invalid' - ], + [ 'pg_amcheck', '-d', 'regression_invalid' ], 1, [qr/^$/], [ @@ -314,8 +312,7 @@ $node->command_checks_all( $node->command_checks_all( [ - 'pg_amcheck', '-d', 'postgres', - '-t', 'regression_invalid.public.foo', + 'pg_amcheck', '-d', 'postgres', '-t', 'regression_invalid.public.foo', ], 1, [qr/^$/], diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 31c369688e0..2d4b75a6fe5 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -411,7 +411,9 @@ SKIP: $tblspc_tars[0] =~ m|/([0-9]*)\.tar$|; my $tblspcoid = $1; my $realRepTsDir = "$real_sys_tempdir/tblspc1replica"; - $node2->init_from_backup($node, 'tarbackup2', tar_program => $tar, + $node2->init_from_backup( + $node, 'tarbackup2', + tar_program => $tar, 'tablespace_map' => { $tblspcoid => $realRepTsDir }); $node2->start; @@ -776,10 +778,8 @@ $node->command_ok( 'stream', '-d', "dbname=db1", '-R', ], 'pg_basebackup with dbname and -R runs'); -like( - slurp_file("$tempdir/backup_dbname_R/postgresql.auto.conf"), - qr/dbname=db1/m, - 'recovery conf file sets dbname'); +like(slurp_file("$tempdir/backup_dbname_R/postgresql.auto.conf"), + qr/dbname=db1/m, 'recovery conf file sets dbname'); rmtree("$tempdir/backup_dbname_R"); @@ -976,8 +976,11 @@ $node2->append_conf('postgresql.conf', 'summarize_wal = on'); $node2->start; $node2->command_fails_like( - [ @pg_basebackup_defs, '-D', "$tempdir" . '/diff_sysid', - '--incremental', "$backupdir" . '/backup_manifest' ], + [ + @pg_basebackup_defs, '-D', + "$tempdir" . '/diff_sysid', '--incremental', + "$backupdir" . '/backup_manifest' + ], qr/manifest system identifier is .*, but database system identifier is/, "pg_basebackup fails with different database system manifest"); diff --git a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl index 63ae6fdfc67..2b883e69104 100644 --- a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl +++ b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl @@ -140,11 +140,11 @@ command_fails( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_t->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_t->host, - '--subscriber-port', $node_t->port, - '--database', 'pg1', - '--database', 'pg2' + $node_p->connstr('pg1'), '--socket-directory', + $node_t->host, '--subscriber-port', + $node_t->port, '--database', + 'pg1', '--database', + 'pg2' ], 'target server is not in recovery'); @@ -154,11 +154,11 @@ command_fails( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_s->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_s->host, - '--subscriber-port', $node_s->port, - '--database', 'pg1', - '--database', 'pg2' + $node_p->connstr('pg1'), '--socket-directory', + $node_s->host, '--subscriber-port', + $node_s->port, '--database', + 'pg1', '--database', + 'pg2' ], 'standby is up and running'); @@ -188,11 +188,11 @@ command_fails( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_c->data_dir, '--publisher-server', - $node_s->connstr('pg1'), - '--socket-directory', $node_c->host, - '--subscriber-port', $node_c->port, - '--database', 'pg1', - '--database', 'pg2' + $node_s->connstr('pg1'), '--socket-directory', + $node_c->host, '--subscriber-port', + $node_c->port, '--database', + 'pg1', '--database', + 'pg2' ], 'primary server is in recovery'); @@ -201,7 +201,8 @@ $node_p->safe_psql('pg1', "INSERT INTO tbl1 VALUES('second row')"); $node_p->wait_for_replay_catchup($node_s); # Check some unmet conditions on node P -$node_p->append_conf('postgresql.conf', q{ +$node_p->append_conf( + 'postgresql.conf', q{ wal_level = replica max_replication_slots = 1 max_wal_senders = 1 @@ -214,16 +215,17 @@ command_fails( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_s->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_s->host, - '--subscriber-port', $node_s->port, - '--database', 'pg1', - '--database', 'pg2' + $node_p->connstr('pg1'), '--socket-directory', + $node_s->host, '--subscriber-port', + $node_s->port, '--database', + 'pg1', '--database', + 'pg2' ], 'primary contains unmet conditions on node P'); # Restore default settings here but only apply it after testing standby. Some # standby settings should not be a lower setting than on the primary. -$node_p->append_conf('postgresql.conf', q{ +$node_p->append_conf( + 'postgresql.conf', q{ wal_level = logical max_replication_slots = 10 max_wal_senders = 10 @@ -231,7 +233,8 @@ max_worker_processes = 8 }); # Check some unmet conditions on node S -$node_s->append_conf('postgresql.conf', q{ +$node_s->append_conf( + 'postgresql.conf', q{ max_replication_slots = 1 max_logical_replication_workers = 1 max_worker_processes = 2 @@ -241,14 +244,15 @@ command_fails( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_s->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_s->host, - '--subscriber-port', $node_s->port, - '--database', 'pg1', - '--database', 'pg2' + $node_p->connstr('pg1'), '--socket-directory', + $node_s->host, '--subscriber-port', + $node_s->port, '--database', + 'pg1', '--database', + 'pg2' ], 'standby contains unmet conditions on node S'); -$node_s->append_conf('postgresql.conf', q{ +$node_s->append_conf( + 'postgresql.conf', q{ max_replication_slots = 10 max_logical_replication_workers = 4 max_worker_processes = 8 @@ -262,15 +266,15 @@ command_ok( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_s->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_s->host, - '--subscriber-port', $node_s->port, - '--publication', 'pub1', - '--publication', 'pub2', - '--subscription', 'sub1', - '--subscription', 'sub2', - '--database', 'pg1', - '--database', 'pg2' + $node_p->connstr('pg1'), '--socket-directory', + $node_s->host, '--subscriber-port', + $node_s->port, '--publication', + 'pub1', '--publication', + 'pub2', '--subscription', + 'sub1', '--subscription', + 'sub2', '--database', + 'pg1', '--database', + 'pg2' ], 'run pg_createsubscriber --dry-run on node S'); @@ -286,10 +290,10 @@ command_ok( 'pg_createsubscriber', '--verbose', '--dry-run', '--pgdata', $node_s->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_s->host, - '--subscriber-port', $node_s->port, - '--replication-slot', 'replslot1' + $node_p->connstr('pg1'), '--socket-directory', + $node_s->host, '--subscriber-port', + $node_s->port, '--replication-slot', + 'replslot1' ], 'run pg_createsubscriber without --databases'); @@ -299,15 +303,15 @@ command_ok( 'pg_createsubscriber', '--verbose', '--verbose', '--pgdata', $node_s->data_dir, '--publisher-server', - $node_p->connstr('pg1'), - '--socket-directory', $node_s->host, - '--subscriber-port', $node_s->port, - '--publication', 'pub1', - '--publication', 'Pub2', - '--replication-slot', 'replslot1', - '--replication-slot', 'replslot2', - '--database', 'pg1', - '--database', 'pg2' + $node_p->connstr('pg1'), '--socket-directory', + $node_s->host, '--subscriber-port', + $node_s->port, '--publication', + 'pub1', '--publication', + 'Pub2', '--replication-slot', + 'replslot1', '--replication-slot', + 'replslot2', '--database', + 'pg1', '--database', + 'pg2' ], 'run pg_createsubscriber on node S'); diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index 2faf2f45907..33e7fb53c5e 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -119,7 +119,7 @@ append_to_file "$pgdata/global/pg_internal.init.123", "foo"; # Only perform this test on non-macOS systems though as creating incorrect # system files may have side effects on macOS. append_to_file "$pgdata/global/.DS_Store", "foo" - unless ($Config{osname} eq 'darwin'); + unless ($Config{osname} eq 'darwin'); # Enable checksums. command_ok([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ], diff --git a/src/bin/pg_combinebackup/t/002_compare_backups.pl b/src/bin/pg_combinebackup/t/002_compare_backups.pl index 31342579cf0..f032959ef5c 100644 --- a/src/bin/pg_combinebackup/t/002_compare_backups.pl +++ b/src/bin/pg_combinebackup/t/002_compare_backups.pl @@ -44,7 +44,7 @@ EOM # Read list of tablespace OIDs. There should be just one. my @tsoids = grep { /^\d+/ } slurp_dir($primary->data_dir . '/pg_tblspc'); -is(0+@tsoids, 1, "exactly one user-defined tablespace"); +is(0 + @tsoids, 1, "exactly one user-defined tablespace"); my $tsoid = $tsoids[0]; # Take a full backup. @@ -52,8 +52,12 @@ my $backup1path = $primary->backup_dir . '/backup1'; my $tsbackup1path = $tempdir . '/ts1backup'; mkdir($tsbackup1path) || die "mkdir $tsbackup1path: $!"; $primary->command_ok( - [ 'pg_basebackup', '-D', $backup1path, '--no-sync', '-cfast', - "-T${tsprimary}=${tsbackup1path}" ], "full backup"); + [ + 'pg_basebackup', '-D', + $backup1path, '--no-sync', + '-cfast', "-T${tsprimary}=${tsbackup1path}" + ], + "full backup"); # Now make some database changes. $primary->safe_psql('postgres', <<EOM); @@ -79,9 +83,12 @@ my $backup2path = $primary->backup_dir . '/backup2'; my $tsbackup2path = $tempdir . '/tsbackup2'; mkdir($tsbackup2path) || die "mkdir $tsbackup2path: $!"; $primary->command_ok( - [ 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', - "-T${tsprimary}=${tsbackup2path}", - '--incremental', $backup1path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', + $backup2path, '--no-sync', + '-cfast', "-T${tsprimary}=${tsbackup2path}", + '--incremental', $backup1path . '/backup_manifest' + ], "incremental backup"); # Find an LSN to which either backup can be recovered. @@ -105,10 +112,13 @@ $primary->poll_query_until('postgres', $archive_wait_query) # choose the same timeline. my $tspitr1path = $tempdir . '/tspitr1'; my $pitr1 = PostgreSQL::Test::Cluster->new('pitr1'); -$pitr1->init_from_backup($primary, 'backup1', - standby => 1, has_restoring => 1, - tablespace_map => { $tsoid => $tspitr1path }); -$pitr1->append_conf('postgresql.conf', qq{ +$pitr1->init_from_backup( + $primary, 'backup1', + standby => 1, + has_restoring => 1, + tablespace_map => { $tsoid => $tspitr1path }); +$pitr1->append_conf( + 'postgresql.conf', qq{ recovery_target_lsn = '$lsn' recovery_target_action = 'promote' archive_mode = 'off' @@ -119,11 +129,14 @@ $pitr1->start(); # basic configuration as before. my $tspitr2path = $tempdir . '/tspitr2'; my $pitr2 = PostgreSQL::Test::Cluster->new('pitr2'); -$pitr2->init_from_backup($primary, 'backup2', - standby => 1, has_restoring => 1, - combine_with_prior => [ 'backup1' ], - tablespace_map => { $tsbackup2path => $tspitr2path }); -$pitr2->append_conf('postgresql.conf', qq{ +$pitr2->init_from_backup( + $primary, 'backup2', + standby => 1, + has_restoring => 1, + combine_with_prior => ['backup1'], + tablespace_map => { $tsbackup2path => $tspitr2path }); +$pitr2->append_conf( + 'postgresql.conf', qq{ recovery_target_lsn = '$lsn' recovery_target_action = 'promote' archive_mode = 'off' @@ -131,11 +144,9 @@ archive_mode = 'off' $pitr2->start(); # Wait until both servers exit recovery. -$pitr1->poll_query_until('postgres', - "SELECT NOT pg_is_in_recovery();") +$pitr1->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery();") or die "Timed out while waiting apply to reach LSN $lsn"; -$pitr2->poll_query_until('postgres', - "SELECT NOT pg_is_in_recovery();") +$pitr2->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery();") or die "Timed out while waiting apply to reach LSN $lsn"; # Perform a logical dump of each server, and check that they match. @@ -150,14 +161,20 @@ $pitr2->poll_query_until('postgres', my $backupdir = $primary->backup_dir; my $dump1 = $backupdir . '/pitr1.dump'; my $dump2 = $backupdir . '/pitr2.dump'; -$pitr1->command_ok([ - 'pg_dumpall', '-f', $dump1, '--no-sync', '--no-unlogged-table-data', - '-d', $pitr1->connstr('postgres'), +$pitr1->command_ok( + [ + 'pg_dumpall', '-f', + $dump1, '--no-sync', + '--no-unlogged-table-data', '-d', + $pitr1->connstr('postgres'), ], 'dump from PITR 1'); -$pitr1->command_ok([ - 'pg_dumpall', '-f', $dump2, '--no-sync', '--no-unlogged-table-data', - '-d', $pitr1->connstr('postgres'), +$pitr1->command_ok( + [ + 'pg_dumpall', '-f', + $dump2, '--no-sync', + '--no-unlogged-table-data', '-d', + $pitr1->connstr('postgres'), ], 'dump from PITR 2'); @@ -171,7 +188,7 @@ is($compare_res, 0, "dumps are identical"); if ($compare_res != 0) { my ($stdout, $stderr) = - run_command([ 'diff', '-u', $dump1, $dump2 ]); + run_command([ 'diff', '-u', $dump1, $dump2 ]); print "=== diff of $dump1 and $dump2\n"; print "=== stdout ===\n"; print $stdout; diff --git a/src/bin/pg_combinebackup/t/003_timeline.pl b/src/bin/pg_combinebackup/t/003_timeline.pl index 82bd886c87d..52eb642a392 100644 --- a/src/bin/pg_combinebackup/t/003_timeline.pl +++ b/src/bin/pg_combinebackup/t/003_timeline.pl @@ -36,14 +36,16 @@ EOM # Now take an incremental backup. my $backup2path = $node1->backup_dir . '/backup2'; $node1->command_ok( - [ 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', - '--incremental', $backup1path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', + '--incremental', $backup1path . '/backup_manifest' + ], "incremental backup from node1"); # Restore the incremental backup and use it to create a new node. my $node2 = PostgreSQL::Test::Cluster->new('node2'); $node2->init_from_backup($node1, 'backup2', - combine_with_prior => [ 'backup1' ]); + combine_with_prior => ['backup1']); $node2->start(); # Insert rows on both nodes. @@ -57,14 +59,16 @@ EOM # Take another incremental backup, from node2, based on backup2 from node1. my $backup3path = $node1->backup_dir . '/backup3'; $node2->command_ok( - [ 'pg_basebackup', '-D', $backup3path, '--no-sync', '-cfast', - '--incremental', $backup2path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', $backup3path, '--no-sync', '-cfast', + '--incremental', $backup2path . '/backup_manifest' + ], "incremental backup from node2"); # Restore the incremental backup and use it to create a new node. my $node3 = PostgreSQL::Test::Cluster->new('node3'); $node3->init_from_backup($node1, 'backup3', - combine_with_prior => [ 'backup1', 'backup2' ]); + combine_with_prior => [ 'backup1', 'backup2' ]); $node3->start(); # Let's insert one more row. diff --git a/src/bin/pg_combinebackup/t/004_manifest.pl b/src/bin/pg_combinebackup/t/004_manifest.pl index 352b376b9b6..0df9fed73a8 100644 --- a/src/bin/pg_combinebackup/t/004_manifest.pl +++ b/src/bin/pg_combinebackup/t/004_manifest.pl @@ -33,40 +33,40 @@ sub combine_and_test_one_backup my ($backup_name, $failure_pattern, @extra_options) = @_; my $revised_backup_path = $node->backup_dir . '/' . $backup_name; $node->command_ok( - [ 'pg_combinebackup', $original_backup_path, '-o', $revised_backup_path, - '--no-sync', @extra_options ], + [ + 'pg_combinebackup', $original_backup_path, + '-o', $revised_backup_path, + '--no-sync', @extra_options + ], "pg_combinebackup with @extra_options"); if (defined $failure_pattern) { - $node->command_fails_like( - [ 'pg_verifybackup', $revised_backup_path ], - $failure_pattern, - "unable to verify backup $backup_name"); + $node->command_fails_like([ 'pg_verifybackup', $revised_backup_path ], + $failure_pattern, "unable to verify backup $backup_name"); } else { - $node->command_ok( - [ 'pg_verifybackup', $revised_backup_path ], + $node->command_ok([ 'pg_verifybackup', $revised_backup_path ], "verify backup $backup_name"); } } combine_and_test_one_backup('nomanifest', - qr/could not open file.*backup_manifest/, '--no-manifest'); -combine_and_test_one_backup('csum_none', - undef, '--manifest-checksums=NONE'); + qr/could not open file.*backup_manifest/, + '--no-manifest'); +combine_and_test_one_backup('csum_none', undef, '--manifest-checksums=NONE'); combine_and_test_one_backup('csum_sha224', undef, '--manifest-checksums=SHA224'); # Verify that SHA224 is mentioned in the SHA224 manifest lots of times. my $sha224_manifest = - slurp_file($node->backup_dir . '/csum_sha224/backup_manifest'); + slurp_file($node->backup_dir . '/csum_sha224/backup_manifest'); my $sha224_count = (() = $sha224_manifest =~ /SHA224/mig); cmp_ok($sha224_count, '>', 100, "SHA224 is mentioned many times in SHA224 manifest"); # Verify that SHA224 is mentioned in the SHA224 manifest lots of times. my $nocsum_manifest = - slurp_file($node->backup_dir . '/csum_none/backup_manifest'); + slurp_file($node->backup_dir . '/csum_none/backup_manifest'); my $nocsum_count = (() = $nocsum_manifest =~ /Checksum-Algorithm/mig); is($nocsum_count, 0, "Checksum-Algorithm is not mentioned in no-checksum manifest"); diff --git a/src/bin/pg_combinebackup/t/005_integrity.pl b/src/bin/pg_combinebackup/t/005_integrity.pl index 08b6d7da1d7..636c3cc1b14 100644 --- a/src/bin/pg_combinebackup/t/005_integrity.pl +++ b/src/bin/pg_combinebackup/t/005_integrity.pl @@ -25,7 +25,7 @@ $node1->start; # cause anything to fail. my $strangely_named_config_file = $node1->data_dir . '/INCREMENTAL.config'; open(my $icfg, '>', $strangely_named_config_file) - || die "$strangely_named_config_file: $!"; + || die "$strangely_named_config_file: $!"; close($icfg); # Set up another new database instance. force_initdb is used because @@ -44,15 +44,19 @@ $node1->command_ok( # Now take an incremental backup. my $backup2path = $node1->backup_dir . '/backup2'; $node1->command_ok( - [ 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', - '--incremental', $backup1path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', + '--incremental', $backup1path . '/backup_manifest' + ], "incremental backup from node1"); # Now take another incremental backup. my $backup3path = $node1->backup_dir . '/backup3'; $node1->command_ok( - [ 'pg_basebackup', '-D', $backup3path, '--no-sync', '-cfast', - '--incremental', $backup2path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', $backup3path, '--no-sync', '-cfast', + '--incremental', $backup2path . '/backup_manifest' + ], "another incremental backup from node1"); # Take a full backup from node2. @@ -64,8 +68,10 @@ $node2->command_ok( # Take an incremental backup from node2. my $backupother2path = $node1->backup_dir . '/backupother2'; $node2->command_ok( - [ 'pg_basebackup', '-D', $backupother2path, '--no-sync', '-cfast', - '--incremental', $backupother1path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', $backupother2path, '--no-sync', '-cfast', + '--incremental', $backupother1path . '/backup_manifest' + ], "incremental backup from node2"); # Result directory. @@ -85,7 +91,10 @@ $node1->command_fails_like( # Can't combine full backup with an incremental backup from a different system. $node1->command_fails_like( - [ 'pg_combinebackup', $backup1path, $backupother2path, '-o', $resultpath ], + [ + 'pg_combinebackup', $backup1path, $backupother2path, '-o', + $resultpath + ], qr/expected system identifier.*but found/, "can't combine backups from different nodes"); @@ -95,7 +104,10 @@ rename("$backup2path/backup_manifest", "$backup2path/backup_manifest.orig") copy("$backupother2path/backup_manifest", "$backup2path/backup_manifest") or die "could not copy $backupother2path/backup_manifest"; $node1->command_fails_like( - [ 'pg_combinebackup', $backup1path, $backup2path, $backup3path, '-o', $resultpath ], + [ + 'pg_combinebackup', $backup1path, $backup2path, $backup3path, + '-o', $resultpath + ], qr/ manifest system identifier is .*, but control file has /, "can't combine backups with different manifest system identifier "); # Restore the backup state @@ -110,20 +122,29 @@ $node1->command_fails_like( # Can't combine backups in the wrong order. $node1->command_fails_like( - [ 'pg_combinebackup', $backup1path, $backup3path, $backup2path, '-o', $resultpath ], + [ + 'pg_combinebackup', $backup1path, $backup3path, $backup2path, + '-o', $resultpath + ], qr/starts at LSN.*but expected/, "can't combine backups in the wrong order"); # Can combine 3 backups that match up properly. $node1->command_ok( - [ 'pg_combinebackup', $backup1path, $backup2path, $backup3path, '-o', $resultpath ], + [ + 'pg_combinebackup', $backup1path, $backup2path, $backup3path, + '-o', $resultpath + ], "can combine 3 matching backups"); rmtree($resultpath); # Can combine full backup with first incremental. my $synthetic12path = $node1->backup_dir . '/synthetic12'; $node1->command_ok( - [ 'pg_combinebackup', $backup1path, $backup2path, '-o', $synthetic12path ], + [ + 'pg_combinebackup', $backup1path, $backup2path, '-o', + $synthetic12path + ], "can combine 2 matching backups"); # Can combine result of previous step with second incremental. diff --git a/src/bin/pg_combinebackup/t/006_db_file_copy.pl b/src/bin/pg_combinebackup/t/006_db_file_copy.pl index 24f55449c63..d57b550af21 100644 --- a/src/bin/pg_combinebackup/t/006_db_file_copy.pl +++ b/src/bin/pg_combinebackup/t/006_db_file_copy.pl @@ -36,23 +36,29 @@ EOM # Take an incremental backup. my $backup2path = $primary->backup_dir . '/backup2'; $primary->command_ok( - [ 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', - '--incremental', $backup1path . '/backup_manifest' ], + [ + 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast', + '--incremental', $backup1path . '/backup_manifest' + ], "incremental backup"); # Recover the incremental backup. my $restore = PostgreSQL::Test::Cluster->new('restore'); $restore->init_from_backup($primary, 'backup2', - combine_with_prior => [ 'backup1' ]); + combine_with_prior => ['backup1']); $restore->start(); # Query the DB. my $stdout; my $stderr; -$restore->psql('lakh', 'SELECT * FROM t1', - stdout => \$stdout, stderr => \$stderr); +$restore->psql( + 'lakh', 'SELECT * FROM t1', + stdout => \$stdout, + stderr => \$stderr); is($stdout, '', 'SELECT * FROM t1: no stdout'); -like($stderr, qr/relation "t1" does not exist/, - 'SELECT * FROM t1: stderr missing table'); +like( + $stderr, + qr/relation "t1" does not exist/, + 'SELECT * FROM t1: stderr missing table'); done_testing(); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 770139153fa..beed8db4d10 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -3855,9 +3855,7 @@ my %tests = ( \QCREATE INDEX measurement_city_id_logdate_idx ON ONLY dump_test.measurement USING\E /xm, like => { - %full_runs, - %dump_test_schema_runs, - section_post_data => 1, + %full_runs, %dump_test_schema_runs, section_post_data => 1, }, unlike => { exclude_dump_test_schema => 1, @@ -4783,10 +4781,8 @@ $node->command_fails_like( ############################################################## # Test dumping pg_catalog (for research -- cannot be reloaded) -$node->command_ok( - [ 'pg_dump', '-p', "$port", '-n', 'pg_catalog' ], - 'pg_dump: option -n pg_catalog' -); +$node->command_ok([ 'pg_dump', '-p', "$port", '-n', 'pg_catalog' ], + 'pg_dump: option -n pg_catalog'); ######################################### # Test valid database exclusion patterns @@ -4953,8 +4949,8 @@ foreach my $run (sort keys %pgdump_runs) } # Check for useless entries in "unlike" list. Runs that are # not listed in "like" don't need to be excluded in "unlike". - if ($tests{$test}->{unlike}->{$test_key} && - !defined($tests{$test}->{like}->{$test_key})) + if ($tests{$test}->{unlike}->{$test_key} + && !defined($tests{$test}->{like}->{$test_key})) { die "useless \"unlike\" entry \"$test_key\" in test \"$test\""; } diff --git a/src/bin/pg_rewind/t/003_extrafiles.pl b/src/bin/pg_rewind/t/003_extrafiles.pl index 94ac55d5f05..5ddc61aa5a0 100644 --- a/src/bin/pg_rewind/t/003_extrafiles.pl +++ b/src/bin/pg_rewind/t/003_extrafiles.pl @@ -56,8 +56,8 @@ sub run_test "in standby4"; # Skip testing .DS_Store files on macOS to avoid risk of side effects append_to_file - "$test_standby_datadir/tst_standby_dir/.DS_Store", - "macOS system file" unless ($Config{osname} eq 'darwin'); + "$test_standby_datadir/tst_standby_dir/.DS_Store", "macOS system file" + unless ($Config{osname} eq 'darwin'); mkdir "$test_primary_datadir/tst_primary_dir"; append_to_file "$test_primary_datadir/tst_primary_dir/primary_file1", diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 11e705e8ec8..259b1109b86 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -51,7 +51,7 @@ typedef struct int threshold_version; /* A function pointer for determining if the check applies */ DataTypesUsageVersionCheck version_hook; -} DataTypesUsageChecks; +} DataTypesUsageChecks; /* * Special values for threshold_version for indicating that a check applies to @@ -109,17 +109,17 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for system-defined composite types in user tables"), - .report_filename = "tables_using_composite.txt", - .base_query = - "SELECT t.oid FROM pg_catalog.pg_type t " - "LEFT JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid " - " WHERE typtype = 'c' AND (t.oid < 16384 OR nspname = 'information_schema')", - .report_text = - gettext_noop("Your installation contains system-defined composite types in user tables.\n" - "These type OIDs are not stable across PostgreSQL versions,\n" - "so this cluster cannot currently be upgraded. You can drop the\n" - "problem columns and restart the upgrade.\n"), - .threshold_version = ALL_VERSIONS + .report_filename = "tables_using_composite.txt", + .base_query = + "SELECT t.oid FROM pg_catalog.pg_type t " + "LEFT JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid " + " WHERE typtype = 'c' AND (t.oid < 16384 OR nspname = 'information_schema')", + .report_text = + gettext_noop("Your installation contains system-defined composite types in user tables.\n" + "These type OIDs are not stable across PostgreSQL versions,\n" + "so this cluster cannot currently be upgraded. You can drop the\n" + "problem columns and restart the upgrade.\n"), + .threshold_version = ALL_VERSIONS }, /* @@ -130,16 +130,16 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for incompatible \"line\" data type"), - .report_filename = "tables_using_line.txt", - .base_query = - "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"line\" data type in user tables.\n" - "This data type changed its internal and input/output format\n" - "between your old and new versions so this\n" - "cluster cannot currently be upgraded. You can\n" - "drop the problem columns and restart the upgrade.\n"), - .threshold_version = 903 + .report_filename = "tables_using_line.txt", + .base_query = + "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"line\" data type in user tables.\n" + "This data type changed its internal and input/output format\n" + "between your old and new versions so this\n" + "cluster cannot currently be upgraded. You can\n" + "drop the problem columns and restart the upgrade.\n"), + .threshold_version = 903 }, /* @@ -152,37 +152,37 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for reg* data types in user tables"), - .report_filename = "tables_using_reg.txt", + .report_filename = "tables_using_reg.txt", /* * Note: older servers will not have all of these reg* types, so we * have to write the query like this rather than depending on casts to * regtype. */ - .base_query = - "SELECT oid FROM pg_catalog.pg_type t " - "WHERE t.typnamespace = " - " (SELECT oid FROM pg_catalog.pg_namespace " - " WHERE nspname = 'pg_catalog') " - " AND t.typname IN ( " + .base_query = + "SELECT oid FROM pg_catalog.pg_type t " + "WHERE t.typnamespace = " + " (SELECT oid FROM pg_catalog.pg_namespace " + " WHERE nspname = 'pg_catalog') " + " AND t.typname IN ( " /* pg_class.oid is preserved, so 'regclass' is OK */ - " 'regcollation', " - " 'regconfig', " - " 'regdictionary', " - " 'regnamespace', " - " 'regoper', " - " 'regoperator', " - " 'regproc', " - " 'regprocedure' " + " 'regcollation', " + " 'regconfig', " + " 'regdictionary', " + " 'regnamespace', " + " 'regoper', " + " 'regoperator', " + " 'regproc', " + " 'regprocedure' " /* pg_authid.oid is preserved, so 'regrole' is OK */ /* pg_type.oid is (mostly) preserved, so 'regtype' is OK */ - " )", - .report_text = - gettext_noop("Your installation contains one of the reg* data types in user tables.\n" - "These data types reference system OIDs that are not preserved by\n" - "pg_upgrade, so this cluster cannot currently be upgraded. You can\n" - "drop the problem columns and restart the upgrade.\n"), - .threshold_version = ALL_VERSIONS + " )", + .report_text = + gettext_noop("Your installation contains one of the reg* data types in user tables.\n" + "These data types reference system OIDs that are not preserved by\n" + "pg_upgrade, so this cluster cannot currently be upgraded. You can\n" + "drop the problem columns and restart the upgrade.\n"), + .threshold_version = ALL_VERSIONS }, /* @@ -191,15 +191,15 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for incompatible \"aclitem\" data type"), - .report_filename = "tables_using_aclitem.txt", - .base_query = - "SELECT 'pg_catalog.aclitem'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"aclitem\" data type in user tables.\n" - "The internal format of \"aclitem\" changed in PostgreSQL version 16\n" - "so this cluster cannot currently be upgraded. You can drop the\n" - "problem columns and restart the upgrade.\n"), - .threshold_version = 1500 + .report_filename = "tables_using_aclitem.txt", + .base_query = + "SELECT 'pg_catalog.aclitem'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"aclitem\" data type in user tables.\n" + "The internal format of \"aclitem\" changed in PostgreSQL version 16\n" + "so this cluster cannot currently be upgraded. You can drop the\n" + "problem columns and restart the upgrade.\n"), + .threshold_version = 1500 }, /* @@ -215,15 +215,15 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for invalid \"unknown\" user columns"), - .report_filename = "tables_using_unknown.txt", - .base_query = - "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n" - "This data type is no longer allowed in tables, so this cluster\n" - "cannot currently be upgraded. You can drop the problem columns\n" - "and restart the upgrade.\n"), - .threshold_version = 906 + .report_filename = "tables_using_unknown.txt", + .base_query = + "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n" + "This data type is no longer allowed in tables, so this cluster\n" + "cannot currently be upgraded. You can drop the problem columns\n" + "and restart the upgrade.\n"), + .threshold_version = 906 }, /* @@ -237,15 +237,15 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for invalid \"sql_identifier\" user columns"), - .report_filename = "tables_using_sql_identifier.txt", - .base_query = - "SELECT 'information_schema.sql_identifier'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"sql_identifier\" data type in user tables.\n" - "The on-disk format for this data type has changed, so this\n" - "cluster cannot currently be upgraded. You can drop the problem\n" - "columns and restart the upgrade.\n"), - .threshold_version = 1100 + .report_filename = "tables_using_sql_identifier.txt", + .base_query = + "SELECT 'information_schema.sql_identifier'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"sql_identifier\" data type in user tables.\n" + "The on-disk format for this data type has changed, so this\n" + "cluster cannot currently be upgraded. You can drop the problem\n" + "columns and restart the upgrade.\n"), + .threshold_version = 1100 }, /* @@ -253,16 +253,16 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"), - .report_filename = "tables_using_jsonb.txt", - .base_query = - "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n" - "The internal format of \"jsonb\" changed during 9.4 beta so this\n" - "cluster cannot currently be upgraded. You can drop the problem \n" - "columns and restart the upgrade.\n"), - .threshold_version = MANUAL_CHECK, - .version_hook = jsonb_9_4_check_applicable + .report_filename = "tables_using_jsonb.txt", + .base_query = + "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n" + "The internal format of \"jsonb\" changed during 9.4 beta so this\n" + "cluster cannot currently be upgraded. You can drop the problem \n" + "columns and restart the upgrade.\n"), + .threshold_version = MANUAL_CHECK, + .version_hook = jsonb_9_4_check_applicable }, /* @@ -270,42 +270,42 @@ static DataTypesUsageChecks data_types_usage_checks[] = */ { .status = gettext_noop("Checking for removed \"abstime\" data type in user tables"), - .report_filename = "tables_using_abstime.txt", - .base_query = - "SELECT 'pg_catalog.abstime'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"abstime\" data type in user tables.\n" - "The \"abstime\" type has been removed in PostgreSQL version 12,\n" - "so this cluster cannot currently be upgraded. You can drop the\n" - "problem columns, or change them to another data type, and restart\n" - "the upgrade.\n"), - .threshold_version = 1100 + .report_filename = "tables_using_abstime.txt", + .base_query = + "SELECT 'pg_catalog.abstime'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"abstime\" data type in user tables.\n" + "The \"abstime\" type has been removed in PostgreSQL version 12,\n" + "so this cluster cannot currently be upgraded. You can drop the\n" + "problem columns, or change them to another data type, and restart\n" + "the upgrade.\n"), + .threshold_version = 1100 }, { .status = gettext_noop("Checking for removed \"reltime\" data type in user tables"), - .report_filename = "tables_using_reltime.txt", - .base_query = - "SELECT 'pg_catalog.reltime'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"reltime\" data type in user tables.\n" - "The \"reltime\" type has been removed in PostgreSQL version 12,\n" - "so this cluster cannot currently be upgraded. You can drop the\n" - "problem columns, or change them to another data type, and restart\n" - "the upgrade.\n"), - .threshold_version = 1100 + .report_filename = "tables_using_reltime.txt", + .base_query = + "SELECT 'pg_catalog.reltime'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"reltime\" data type in user tables.\n" + "The \"reltime\" type has been removed in PostgreSQL version 12,\n" + "so this cluster cannot currently be upgraded. You can drop the\n" + "problem columns, or change them to another data type, and restart\n" + "the upgrade.\n"), + .threshold_version = 1100 }, { .status = gettext_noop("Checking for removed \"tinterval\" data type in user tables"), - .report_filename = "tables_using_tinterval.txt", - .base_query = - "SELECT 'pg_catalog.tinterval'::pg_catalog.regtype AS oid", - .report_text = - gettext_noop("Your installation contains the \"tinterval\" data type in user tables.\n" - "The \"tinterval\" type has been removed in PostgreSQL version 12,\n" - "so this cluster cannot currently be upgraded. You can drop the\n" - "problem columns, or change them to another data type, and restart\n" - "the upgrade.\n"), - .threshold_version = 1100 + .report_filename = "tables_using_tinterval.txt", + .base_query = + "SELECT 'pg_catalog.tinterval'::pg_catalog.regtype AS oid", + .report_text = + gettext_noop("Your installation contains the \"tinterval\" data type in user tables.\n" + "The \"tinterval\" type has been removed in PostgreSQL version 12,\n" + "so this cluster cannot currently be upgraded. You can drop the\n" + "problem columns, or change them to another data type, and restart\n" + "the upgrade.\n"), + .threshold_version = 1100 }, /* End of checks marker, must remain last */ @@ -334,7 +334,7 @@ static DataTypesUsageChecks data_types_usage_checks[] = * there's no storage involved in a view. */ static void -check_for_data_types_usage(ClusterInfo *cluster, DataTypesUsageChecks * checks) +check_for_data_types_usage(ClusterInfo *cluster, DataTypesUsageChecks *checks) { bool found = false; bool *results; diff --git a/src/bin/pg_upgrade/t/003_logical_slots.pl b/src/bin/pg_upgrade/t/003_logical_slots.pl index 83d71c3084b..f9394f97b1f 100644 --- a/src/bin/pg_upgrade/t/003_logical_slots.pl +++ b/src/bin/pg_upgrade/t/003_logical_slots.pl @@ -31,7 +31,8 @@ $newpub->init(allows_streaming => 'logical'); # completely till it is open. The probability of seeing this behavior is # higher in this test because we use wal_level as logical via # allows_streaming => 'logical' which in turn set shared_buffers as 1MB. -$newpub->append_conf('postgresql.conf', q{ +$newpub->append_conf( + 'postgresql.conf', q{ bgwriter_lru_maxpages = 0 checkpoint_timeout = 1h }); @@ -81,7 +82,7 @@ command_checks_all( [qr//], 'run of pg_upgrade where the new cluster has insufficient max_replication_slots' ); -ok( -d $newpub->data_dir . "/pg_upgrade_output.d", +ok(-d $newpub->data_dir . "/pg_upgrade_output.d", "pg_upgrade_output.d/ not removed after pg_upgrade failure"); # Set 'max_replication_slots' to match the number of slots (2) present on the diff --git a/src/bin/pg_upgrade/t/004_subscription.pl b/src/bin/pg_upgrade/t/004_subscription.pl index a038928fe72..ba782c3bd99 100644 --- a/src/bin/pg_upgrade/t/004_subscription.pl +++ b/src/bin/pg_upgrade/t/004_subscription.pl @@ -291,8 +291,7 @@ regress_sub5|f|f), # Subscription relations should be preserved $result = $new_sub->safe_psql('postgres', - "SELECT srrelid, srsubstate FROM pg_subscription_rel ORDER BY srrelid" -); + "SELECT srrelid, srsubstate FROM pg_subscription_rel ORDER BY srrelid"); is( $result, qq($tab_upgraded1_oid|r $tab_upgraded2_oid|i), "there should be 2 rows in pg_subscription_rel(representing tab_upgraded1 and tab_upgraded2)" diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl index 36d032288fe..f0b0f1f7e5b 100644 --- a/src/bin/pg_verifybackup/t/003_corruption.pl +++ b/src/bin/pg_verifybackup/t/003_corruption.pl @@ -72,7 +72,8 @@ my @scenario = ( { 'name' => 'system_identifier', 'mutilate' => \&mutilate_system_identifier, - 'fails_like' => qr/manifest system identifier is .*, but control file has/ + 'fails_like' => + qr/manifest system identifier is .*, but control file has/ }, { 'name' => 'bad_manifest', @@ -254,8 +255,9 @@ sub mutilate_system_identifier $node->init(force_initdb => 1, allows_streaming => 1); $node->start; $node->backup('backup2'); - move($node->backup_dir.'/backup2/backup_manifest', $backup_path.'/backup_manifest') - or BAIL_OUT "could not copy manifest to $backup_path"; + move($node->backup_dir . '/backup2/backup_manifest', + $backup_path . '/backup_manifest') + or BAIL_OUT "could not copy manifest to $backup_path"; $node->teardown_node(fail_ok => 1); return; } diff --git a/src/bin/pg_verifybackup/t/005_bad_manifest.pl b/src/bin/pg_verifybackup/t/005_bad_manifest.pl index 2068babac5a..c4ed64b62d5 100644 --- a/src/bin/pg_verifybackup/t/005_bad_manifest.pl +++ b/src/bin/pg_verifybackup/t/005_bad_manifest.pl @@ -12,7 +12,8 @@ use Test::More; my $tempdir = PostgreSQL::Test::Utils::tempdir; -test_bad_manifest('input string ended unexpectedly', +test_bad_manifest( + 'input string ended unexpectedly', qr/could not parse backup manifest: The input string ended unexpectedly/, <<EOM); { diff --git a/src/bin/pg_waldump/t/001_basic.pl b/src/bin/pg_waldump/t/001_basic.pl index 082cb8a5893..578e4731394 100644 --- a/src/bin/pg_waldump/t/001_basic.pl +++ b/src/bin/pg_waldump/t/001_basic.pl @@ -12,21 +12,47 @@ program_version_ok('pg_waldump'); program_options_handling_ok('pg_waldump'); # wrong number of arguments -command_fails_like([ 'pg_waldump', ], qr/error: no arguments/, 'no arguments'); -command_fails_like([ 'pg_waldump', 'foo', 'bar', 'baz' ], qr/error: too many command-line arguments/, 'too many arguments'); +command_fails_like([ 'pg_waldump', ], qr/error: no arguments/, + 'no arguments'); +command_fails_like( + [ 'pg_waldump', 'foo', 'bar', 'baz' ], + qr/error: too many command-line arguments/, + 'too many arguments'); # invalid option arguments -command_fails_like([ 'pg_waldump', '--block', 'bad' ], qr/error: invalid block number/, 'invalid block number'); -command_fails_like([ 'pg_waldump', '--fork', 'bad' ], qr/error: invalid fork name/, 'invalid fork name'); -command_fails_like([ 'pg_waldump', '--limit', 'bad' ], qr/error: invalid value/, 'invalid limit'); -command_fails_like([ 'pg_waldump', '--relation', 'bad' ], qr/error: invalid relation/, 'invalid relation specification'); -command_fails_like([ 'pg_waldump', '--rmgr', 'bad' ], qr/error: resource manager .* does not exist/, 'invalid rmgr name'); -command_fails_like([ 'pg_waldump', '--start', 'bad' ], qr/error: invalid WAL location/, 'invalid start LSN'); -command_fails_like([ 'pg_waldump', '--end', 'bad' ], qr/error: invalid WAL location/, 'invalid end LSN'); +command_fails_like( + [ 'pg_waldump', '--block', 'bad' ], + qr/error: invalid block number/, + 'invalid block number'); +command_fails_like( + [ 'pg_waldump', '--fork', 'bad' ], + qr/error: invalid fork name/, + 'invalid fork name'); +command_fails_like( + [ 'pg_waldump', '--limit', 'bad' ], + qr/error: invalid value/, + 'invalid limit'); +command_fails_like( + [ 'pg_waldump', '--relation', 'bad' ], + qr/error: invalid relation/, + 'invalid relation specification'); +command_fails_like( + [ 'pg_waldump', '--rmgr', 'bad' ], + qr/error: resource manager .* does not exist/, + 'invalid rmgr name'); +command_fails_like( + [ 'pg_waldump', '--start', 'bad' ], + qr/error: invalid WAL location/, + 'invalid start LSN'); +command_fails_like( + [ 'pg_waldump', '--end', 'bad' ], + qr/error: invalid WAL location/, + 'invalid end LSN'); # rmgr list: If you add one to the list, consider also adding a test # case exercising the new rmgr below. -command_like([ 'pg_waldump', '--rmgr=list'], qr/^XLOG +command_like( + [ 'pg_waldump', '--rmgr=list' ], qr/^XLOG Transaction Storage CLOG @@ -53,7 +79,8 @@ LogicalMessage$/, my $node = PostgreSQL::Test::Cluster->new('main'); $node->init; -$node->append_conf('postgresql.conf', q{ +$node->append_conf( + 'postgresql.conf', q{ autovacuum = off checkpoint_timeout = 1h @@ -66,9 +93,13 @@ wal_level=logical }); $node->start; -my ($start_lsn, $start_walfile) = split /\|/, $node->safe_psql('postgres', q{SELECT pg_current_wal_insert_lsn(), pg_walfile_name(pg_current_wal_insert_lsn())}); +my ($start_lsn, $start_walfile) = split /\|/, + $node->safe_psql('postgres', + q{SELECT pg_current_wal_insert_lsn(), pg_walfile_name(pg_current_wal_insert_lsn())} + ); -$node->safe_psql('postgres', q{ +$node->safe_psql( + 'postgres', q{ -- heap, btree, hash, sequence CREATE TABLE t1 (a int GENERATED ALWAYS AS IDENTITY, b text); CREATE INDEX i1a ON t1 USING btree (a); @@ -125,32 +156,75 @@ DROP DATABASE d1; my $tblspc_path = PostgreSQL::Test::Utils::tempdir_short(); -$node->safe_psql('postgres', qq{ +$node->safe_psql( + 'postgres', qq{ CREATE TABLESPACE ts1 LOCATION '$tblspc_path'; DROP TABLESPACE ts1; }); -my ($end_lsn, $end_walfile) = split /\|/, $node->safe_psql('postgres', q{SELECT pg_current_wal_insert_lsn(), pg_walfile_name(pg_current_wal_insert_lsn())}); +my ($end_lsn, $end_walfile) = split /\|/, + $node->safe_psql('postgres', + q{SELECT pg_current_wal_insert_lsn(), pg_walfile_name(pg_current_wal_insert_lsn())} + ); -my $default_ts_oid = $node->safe_psql('postgres', q{SELECT oid FROM pg_tablespace WHERE spcname = 'pg_default'}); -my $postgres_db_oid = $node->safe_psql('postgres', q{SELECT oid FROM pg_database WHERE datname = 'postgres'}); -my $rel_t1_oid = $node->safe_psql('postgres', q{SELECT oid FROM pg_class WHERE relname = 't1'}); -my $rel_i1a_oid = $node->safe_psql('postgres', q{SELECT oid FROM pg_class WHERE relname = 'i1a'}); +my $default_ts_oid = $node->safe_psql('postgres', + q{SELECT oid FROM pg_tablespace WHERE spcname = 'pg_default'}); +my $postgres_db_oid = $node->safe_psql('postgres', + q{SELECT oid FROM pg_database WHERE datname = 'postgres'}); +my $rel_t1_oid = $node->safe_psql('postgres', + q{SELECT oid FROM pg_class WHERE relname = 't1'}); +my $rel_i1a_oid = $node->safe_psql('postgres', + q{SELECT oid FROM pg_class WHERE relname = 'i1a'}); $node->stop; # various ways of specifying WAL range -command_fails_like([ 'pg_waldump', 'foo', 'bar' ], qr/error: could not locate WAL file "foo"/, 'start file not found'); -command_like([ 'pg_waldump', $node->data_dir . '/pg_wal/' . $start_walfile ], qr/./, 'runs with start segment specified'); -command_fails_like([ 'pg_waldump', $node->data_dir . '/pg_wal/' . $start_walfile, 'bar' ], qr/error: could not open file "bar"/, 'end file not found'); -command_like([ 'pg_waldump', $node->data_dir . '/pg_wal/' . $start_walfile, $node->data_dir . '/pg_wal/' . $end_walfile ], qr/./, 'runs with start and end segment specified'); -command_fails_like([ 'pg_waldump', '-p', $node->data_dir ], qr/error: no start WAL location given/, 'path option requires start location'); -command_like([ 'pg_waldump', '-p', $node->data_dir, '--start', $start_lsn, '--end', $end_lsn ], qr/./, 'runs with path option and start and end locations'); -command_fails_like([ 'pg_waldump', '-p', $node->data_dir, '--start', $start_lsn ], qr/error: error in WAL record at/, 'falling off the end of the WAL results in an error'); - -command_like([ 'pg_waldump', '--quiet', $node->data_dir . '/pg_wal/' . $start_walfile ], qr/^$/, 'no output with --quiet option'); -command_fails_like([ 'pg_waldump', '--quiet', '-p', $node->data_dir, '--start', $start_lsn ], qr/error: error in WAL record at/, 'errors are shown with --quiet'); +command_fails_like( + [ 'pg_waldump', 'foo', 'bar' ], + qr/error: could not locate WAL file "foo"/, + 'start file not found'); +command_like([ 'pg_waldump', $node->data_dir . '/pg_wal/' . $start_walfile ], + qr/./, 'runs with start segment specified'); +command_fails_like( + [ 'pg_waldump', $node->data_dir . '/pg_wal/' . $start_walfile, 'bar' ], + qr/error: could not open file "bar"/, + 'end file not found'); +command_like( + [ + 'pg_waldump', + $node->data_dir . '/pg_wal/' . $start_walfile, + $node->data_dir . '/pg_wal/' . $end_walfile + ], + qr/./, + 'runs with start and end segment specified'); +command_fails_like( + [ 'pg_waldump', '-p', $node->data_dir ], + qr/error: no start WAL location given/, + 'path option requires start location'); +command_like( + [ + 'pg_waldump', '-p', $node->data_dir, '--start', + $start_lsn, '--end', $end_lsn + ], + qr/./, + 'runs with path option and start and end locations'); +command_fails_like( + [ 'pg_waldump', '-p', $node->data_dir, '--start', $start_lsn ], + qr/error: error in WAL record at/, + 'falling off the end of the WAL results in an error'); + +command_like( + [ + 'pg_waldump', '--quiet', + $node->data_dir . '/pg_wal/' . $start_walfile + ], + qr/^$/, + 'no output with --quiet option'); +command_fails_like( + [ 'pg_waldump', '--quiet', '-p', $node->data_dir, '--start', $start_lsn ], + qr/error: error in WAL record at/, + 'errors are shown with --quiet'); # Test for: Display a message that we're skipping data if `from` @@ -165,7 +239,9 @@ command_fails_like([ 'pg_waldump', '--quiet', '-p', $node->data_dir, '--start', my (@cmd, $stdout, $stderr, $result); - @cmd = ( 'pg_waldump', '--start', $new_start, $node->data_dir . '/pg_wal/' . $start_walfile ); + @cmd = ( + 'pg_waldump', '--start', $new_start, + $node->data_dir . '/pg_wal/' . $start_walfile); $result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr; ok($result, "runs with start segment and start LSN specified"); like($stderr, qr/first record is after/, 'info message printed'); @@ -181,7 +257,9 @@ sub test_pg_waldump my (@cmd, $stdout, $stderr, $result, @lines); - @cmd = ('pg_waldump', '-p', $node->data_dir, '--start', $start_lsn, '--end', $end_lsn); + @cmd = ( + 'pg_waldump', '-p', $node->data_dir, '--start', $start_lsn, '--end', + $end_lsn); push @cmd, @opts; $result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr; ok($result, "pg_waldump @opts: runs ok"); @@ -216,10 +294,15 @@ is(grep(!/^rmgr: Btree/, @lines), 0, 'only Btree lines'); @lines = test_pg_waldump('--fork', 'init'); is(grep(!/fork init/, @lines), 0, 'only init fork lines'); -@lines = test_pg_waldump('--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'); +@lines = test_pg_waldump('--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'); -@lines = test_pg_waldump('--relation', "$default_ts_oid/$postgres_db_oid/$rel_i1a_oid", '--block', 1); +@lines = + test_pg_waldump('--relation', + "$default_ts_oid/$postgres_db_oid/$rel_i1a_oid", + '--block', 1); is(grep(!/\bblk 1\b/, @lines), 0, 'only lines for selected block'); diff --git a/src/bin/pg_walsummary/t/002_blocks.pl b/src/bin/pg_walsummary/t/002_blocks.pl index 52d3bd8840b..a3e3aebd320 100644 --- a/src/bin/pg_walsummary/t/002_blocks.pl +++ b/src/bin/pg_walsummary/t/002_blocks.pl @@ -74,15 +74,15 @@ SELECT tli, start_lsn, end_lsn from pg_available_wal_summaries() WHERE end_lsn > '$summarized_lsn' EOM my @lines = split(/\n/, $details); -is(0+@lines, 1, "got exactly one new WAL summary"); +is(0 + @lines, 1, "got exactly one new WAL summary"); my ($tli, $start_lsn, $end_lsn) = split(/\|/, $lines[0]); note("examining summary for TLI $tli from $start_lsn to $end_lsn"); # Reconstruct the full pathname for the WAL summary file. my $filename = sprintf "%s/pg_wal/summaries/%08s%08s%08s%08s%08s.summary", - $node1->data_dir, $tli, - split(m@/@, $start_lsn), - split(m@/@, $end_lsn); + $node1->data_dir, $tli, + split(m@/@, $start_lsn), + split(m@/@, $end_lsn); ok(-f $filename, "WAL summary file exists"); # Run pg_walsummary on it. We expect exactly two blocks to be modified, @@ -92,6 +92,6 @@ note($stdout); @lines = split(/\n/, $stdout); like($stdout, qr/FORK main: block 0$/m, "stdout shows block 0 modified"); is($stderr, '', 'stderr is empty'); -is(0+@lines, 2, "UPDATE modified 2 blocks"); +is(0 + @lines, 2, "UPDATE modified 2 blocks"); done_testing(); diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index d0a86a280cd..59ea5387ed9 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -1541,18 +1541,13 @@ $node->safe_psql('postgres', 'DROP TABLE first_client_table, xy;'); # Test --exit-on-abort $node->safe_psql('postgres', - 'CREATE TABLE counter(i int); '. - 'INSERT INTO counter VALUES (0);' -); + 'CREATE TABLE counter(i int); ' . 'INSERT INTO counter VALUES (0);'); $node->pgbench( '-t 10 -c 2 -j 2 --exit-on-abort', 2, [], - [ - qr{division by zero}, - qr{Run was aborted due to an error in thread} - ], + [ qr{division by zero}, qr{Run was aborted due to an error in thread} ], 'test --exit-on-abort', { '001_exit_on_abort' => q{ diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index b5fedbc091c..5f2f4541af0 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -370,7 +370,8 @@ psql_fails_like( psql_like( $node, - sprintf(q{with x as ( + sprintf( + q{with x as ( select now()-backend_start AS howlong from pg_stat_activity where pid = pg_backend_pid() @@ -416,20 +417,23 @@ psql_like($node, "SELECT 'one' \\g | $pipe_cmd", qr//, "one command \\g"); my $c1 = slurp_file($g_file); like($c1, qr/one/); -psql_like($node, "SELECT 'two' \\; SELECT 'three' \\g | $pipe_cmd", qr//, "two commands \\g"); +psql_like($node, "SELECT 'two' \\; SELECT 'three' \\g | $pipe_cmd", + qr//, "two commands \\g"); my $c2 = slurp_file($g_file); like($c2, qr/two.*three/s); -psql_like($node, "\\set SHOW_ALL_RESULTS 0\nSELECT 'four' \\; SELECT 'five' \\g | $pipe_cmd", qr//, - "two commands \\g with only last result"); +psql_like( + $node, + "\\set SHOW_ALL_RESULTS 0\nSELECT 'four' \\; SELECT 'five' \\g | $pipe_cmd", + qr//, + "two commands \\g with only last result"); my $c3 = slurp_file($g_file); like($c3, qr/five/); unlike($c3, qr/four/); psql_like($node, "copy (values ('foo'),('bar')) to stdout \\g | $pipe_cmd", - qr//, - "copy output passed to \\g pipe"); + qr//, "copy output passed to \\g pipe"); my $c4 = slurp_file($g_file); like($c4, qr/foo.*bar/s); diff --git a/src/bin/scripts/t/011_clusterdb_all.pl b/src/bin/scripts/t/011_clusterdb_all.pl index 3415e1d4f49..e0fd2201e54 100644 --- a/src/bin/scripts/t/011_clusterdb_all.pl +++ b/src/bin/scripts/t/011_clusterdb_all.pl @@ -25,13 +25,14 @@ $node->safe_psql( UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); $node->command_ok([ 'clusterdb', '-a' ], - 'invalid database not targeted by clusterdb -a'); + 'invalid database not targeted by clusterdb -a'); # Doesn't quite belong here, but don't want to waste time by creating an # invalid database in 010_clusterdb.pl as well. -$node->command_fails_like([ 'clusterdb', '-d', 'regression_invalid'], - qr/FATAL: cannot connect to invalid database "regression_invalid"/, - 'clusterdb cannot target invalid database'); +$node->command_fails_like( + [ 'clusterdb', '-d', 'regression_invalid' ], + qr/FATAL: cannot connect to invalid database "regression_invalid"/, + 'clusterdb cannot target invalid database'); $node->safe_psql('postgres', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x' diff --git a/src/bin/scripts/t/050_dropdb.pl b/src/bin/scripts/t/050_dropdb.pl index 93bdad3a7f4..2cfd18ba1e5 100644 --- a/src/bin/scripts/t/050_dropdb.pl +++ b/src/bin/scripts/t/050_dropdb.pl @@ -38,6 +38,6 @@ $node->safe_psql( UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); $node->command_ok([ 'dropdb', 'regression_invalid' ], - 'invalid database can be dropped'); + 'invalid database can be dropped'); done_testing(); diff --git a/src/bin/scripts/t/091_reindexdb_all.pl b/src/bin/scripts/t/091_reindexdb_all.pl index 8061883f7f1..7f5068667e3 100644 --- a/src/bin/scripts/t/091_reindexdb_all.pl +++ b/src/bin/scripts/t/091_reindexdb_all.pl @@ -44,12 +44,13 @@ $node->safe_psql( UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); $node->command_ok([ 'reindexdb', '-a' ], - 'invalid database not targeted by reindexdb -a'); + 'invalid database not targeted by reindexdb -a'); # Doesn't quite belong here, but don't want to waste time by creating an # invalid database in 090_reindexdb.pl as well. -$node->command_fails_like([ 'reindexdb', '-d', 'regression_invalid'], - qr/FATAL: cannot connect to invalid database "regression_invalid"/, - 'reindexdb cannot target invalid database'); +$node->command_fails_like( + [ 'reindexdb', '-d', 'regression_invalid' ], + qr/FATAL: cannot connect to invalid database "regression_invalid"/, + 'reindexdb cannot target invalid database'); done_testing(); diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl index 1d8558c780c..1a2bcb49591 100644 --- a/src/bin/scripts/t/100_vacuumdb.pl +++ b/src/bin/scripts/t/100_vacuumdb.pl @@ -168,7 +168,10 @@ $node->issues_sql_like( qr/^(?!.*VACUUM \(SKIP_DATABASE_STATS\) "Foo".bar).*$/s, 'vacuumdb --exclude-schema'); $node->issues_sql_like( - [ 'vacuumdb', '--exclude-schema', '"Foo"', '--exclude-schema', '"Bar"', 'postgres' ], + [ + 'vacuumdb', '--exclude-schema', '"Foo"', '--exclude-schema', + '"Bar"', 'postgres' + ], qr/^(?!.*VACUUM\ \(SKIP_DATABASE_STATS\)\ "Foo".bar | VACUUM\ \(SKIP_DATABASE_STATS\)\ "Bar".baz).*$/sx, 'vacuumdb multiple --exclude-schema switches'); diff --git a/src/bin/scripts/t/101_vacuumdb_all.pl b/src/bin/scripts/t/101_vacuumdb_all.pl index b1d37112b90..9862f0c2082 100644 --- a/src/bin/scripts/t/101_vacuumdb_all.pl +++ b/src/bin/scripts/t/101_vacuumdb_all.pl @@ -22,12 +22,13 @@ $node->safe_psql( UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); $node->command_ok([ 'vacuumdb', '-a' ], - 'invalid database not targeted by vacuumdb -a'); + 'invalid database not targeted by vacuumdb -a'); # Doesn't quite belong here, but don't want to waste time by creating an # invalid database in 010_vacuumdb.pl as well. -$node->command_fails_like([ 'vacuumdb', '-d', 'regression_invalid'], - qr/FATAL: cannot connect to invalid database "regression_invalid"/, - 'vacuumdb cannot target invalid database'); +$node->command_fails_like( + [ 'vacuumdb', '-d', 'regression_invalid' ], + qr/FATAL: cannot connect to invalid database "regression_invalid"/, + 'vacuumdb cannot target invalid database'); done_testing(); |