summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorTom Lane2021-05-12 17:14:10 +0000
committerTom Lane2021-05-12 17:14:10 +0000
commitdef5b065ff22a16a80084587613599fe15627213 (patch)
tree13f424449b7fb90c85659071b6adf4e27ae6d272 /src/bin
parente6ccd1ce1644d1b40b7981f8bc172394de524f99 (diff)
Initial pgindent and pgperltidy run for v14.
Also "make reformat-dat-files". The only change worthy of note is that pgindent messed up the formatting of launcher.c's struct LogicalRepWorkerId, which led me to notice that that struct wasn't used at all anymore, so I just took it out.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_amcheck/pg_amcheck.c4
-rw-r--r--src/bin/pg_amcheck/t/002_nonesuch.pl236
-rw-r--r--src/bin/pg_amcheck/t/003_check.pl143
-rw-r--r--src/bin/pg_amcheck/t/004_verify_heapam.pl240
-rw-r--r--src/bin/pg_amcheck/t/005_opclass_damage.pl10
-rw-r--r--src/bin/pg_basebackup/t/010_pg_basebackup.pl2
-rw-r--r--src/bin/pg_dump/common.c2
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.h5
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c2
-rw-r--r--src/bin/pg_dump/t/010_dump_connstr.pl2
-rw-r--r--src/bin/pg_rewind/t/001_basic.pl5
-rw-r--r--src/bin/pg_rewind/t/003_extrafiles.pl9
-rw-r--r--src/bin/pg_rewind/t/008_min_recovery_point.pl41
-rw-r--r--src/bin/pg_rewind/t/RewindTest.pm6
-rw-r--r--src/bin/pg_test_fsync/pg_test_fsync.c1
-rw-r--r--src/bin/pg_upgrade/check.c8
-rw-r--r--src/bin/pg_upgrade/exec.c10
-rw-r--r--src/bin/pgbench/pgbench.c4
-rw-r--r--src/bin/pgbench/t/001_pgbench_with_server.pl8
-rw-r--r--src/bin/psql/tab-complete.c4
20 files changed, 387 insertions, 355 deletions
diff --git a/src/bin/pg_amcheck/pg_amcheck.c b/src/bin/pg_amcheck/pg_amcheck.c
index 09ebb4929a7..58a45b47b26 100644
--- a/src/bin/pg_amcheck/pg_amcheck.c
+++ b/src/bin/pg_amcheck/pg_amcheck.c
@@ -564,8 +564,8 @@ main(int argc, char *argv[])
*/
if (opts.install_missing)
{
- char *schema;
- char *install_sql;
+ char *schema;
+ char *install_sql;
/*
* Must re-escape the schema name for each database, as the
diff --git a/src/bin/pg_amcheck/t/002_nonesuch.pl b/src/bin/pg_amcheck/t/002_nonesuch.pl
index 7c446064ab6..5f712ee32ac 100644
--- a/src/bin/pg_amcheck/t/002_nonesuch.pl
+++ b/src/bin/pg_amcheck/t/002_nonesuch.pl
@@ -24,25 +24,26 @@ $node->safe_psql('postgres', q(CREATE EXTENSION amcheck));
# Failing to connect to the initial database is an error.
$node->command_checks_all(
[ 'pg_amcheck', 'qqq' ],
- 1,
- [ qr/^$/ ],
- [ qr/FATAL: database "qqq" does not exist/ ],
+ 1, [qr/^$/],
+ [qr/FATAL: database "qqq" does not exist/],
'checking a non-existent database');
# Failing to resolve a database pattern is an error by default.
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'qqq', '-d', 'postgres' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: error: no connectable databases to check matching "qqq"/ ],
+ [qr/^$/],
+ [qr/pg_amcheck: error: no connectable databases to check matching "qqq"/],
'checking an unresolvable database pattern');
# But only a warning under --no-strict-names
$node->command_checks_all(
[ 'pg_amcheck', '--no-strict-names', '-d', 'qqq', '-d', 'postgres' ],
0,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: no connectable databases to check matching "qqq"/ ],
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: no connectable databases to check matching "qqq"/
+ ],
'checking an unresolvable database pattern under --no-strict-names');
# Check that a substring of an existent database name does not get interpreted
@@ -50,29 +51,31 @@ $node->command_checks_all(
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'post', '-d', 'postgres' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: error: no connectable databases to check matching "post"/ ],
- 'checking an unresolvable database pattern (substring of existent database)');
+ [qr/^$/],
+ [
+ qr/pg_amcheck: error: no connectable databases to check matching "post"/
+ ],
+ 'checking an unresolvable database pattern (substring of existent database)'
+);
# Check that a superstring of an existent database name does not get interpreted
# as a matching pattern.
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgresql', '-d', 'postgres' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: error: no connectable databases to check matching "postgresql"/ ],
- 'checking an unresolvable database pattern (superstring of existent database)');
+ [qr/^$/],
+ [
+ qr/pg_amcheck: error: no connectable databases to check matching "postgresql"/
+ ],
+ 'checking an unresolvable database pattern (superstring of existent database)'
+);
#########################################
# Test connecting with a non-existent user
# Failing to connect to the initial database due to bad username is an error.
-$node->command_checks_all(
- [ 'pg_amcheck', '-U', 'no_such_user', 'postgres' ],
- 1,
- [ qr/^$/ ],
- [ ],
- 'checking with a non-existent user');
+$node->command_checks_all([ 'pg_amcheck', '-U', 'no_such_user', 'postgres' ],
+ 1, [qr/^$/], [], 'checking with a non-existent user');
#########################################
# Test checking databases without amcheck installed
@@ -83,26 +86,35 @@ $node->command_checks_all(
$node->command_checks_all(
[ 'pg_amcheck', 'template1' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
- qr/pg_amcheck: error: no relations to check/ ],
- 'checking a database by name without amcheck installed, no other databases');
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
+ qr/pg_amcheck: error: no relations to check/
+ ],
+ 'checking a database by name without amcheck installed, no other databases'
+);
# Again, but this time with another database to check, so no error is raised.
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'template1', '-d', 'postgres' ],
0,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/ ],
- 'checking a database by name without amcheck installed, with other databases');
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/
+ ],
+ 'checking a database by name without amcheck installed, with other databases'
+);
# Again, but by way of checking all databases
$node->command_checks_all(
[ 'pg_amcheck', '--all' ],
0,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/ ],
- 'checking a database by pattern without amcheck installed, with other databases');
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/
+ ],
+ 'checking a database by pattern without amcheck installed, with other databases'
+);
#########################################
# Test unreasonable patterns
@@ -111,24 +123,28 @@ $node->command_checks_all(
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgres', '-t', '..' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: error: no connectable databases to check matching "\.\."/ ],
+ [qr/^$/],
+ [
+ qr/pg_amcheck: error: no connectable databases to check matching "\.\."/
+ ],
'checking table pattern ".."');
# Again, but with non-trivial schema and relation parts
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgres', '-t', '.foo.bar' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: error: no connectable databases to check matching "\.foo\.bar"/ ],
+ [qr/^$/],
+ [
+ qr/pg_amcheck: error: no connectable databases to check matching "\.foo\.bar"/
+ ],
'checking table pattern ".foo.bar"');
# Check two-part unreasonable pattern that has zero-length names
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgres', '-t', '.' ],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: error: no heap tables to check matching "\."/ ],
+ [qr/^$/],
+ [qr/pg_amcheck: error: no heap tables to check matching "\."/],
'checking table pattern "."');
#########################################
@@ -137,73 +153,80 @@ $node->command_checks_all(
# Use --no-strict-names and a single existent table so we only get warnings
# about the failed pattern matches
$node->command_checks_all(
- [ 'pg_amcheck', '--no-strict-names',
- '-t', 'no_such_table',
- '-t', 'no*such*table',
- '-i', 'no_such_index',
- '-i', 'no*such*index',
- '-r', 'no_such_relation',
- '-r', 'no*such*relation',
- '-d', 'no_such_database',
- '-d', 'no*such*database',
- '-r', 'none.none',
- '-r', 'none.none.none',
- '-r', 'this.is.a.really.long.dotted.string',
- '-r', 'postgres.none.none',
- '-r', 'postgres.long.dotted.string',
- '-r', 'postgres.pg_catalog.none',
- '-r', 'postgres.none.pg_class',
- '-t', 'postgres.pg_catalog.pg_class', # This exists
+ [
+ 'pg_amcheck', '--no-strict-names',
+ '-t', 'no_such_table',
+ '-t', 'no*such*table',
+ '-i', 'no_such_index',
+ '-i', 'no*such*index',
+ '-r', 'no_such_relation',
+ '-r', 'no*such*relation',
+ '-d', 'no_such_database',
+ '-d', 'no*such*database',
+ '-r', 'none.none',
+ '-r', 'none.none.none',
+ '-r', 'this.is.a.really.long.dotted.string',
+ '-r', 'postgres.none.none',
+ '-r', 'postgres.long.dotted.string',
+ '-r', 'postgres.pg_catalog.none',
+ '-r', 'postgres.none.pg_class',
+ '-t', 'postgres.pg_catalog.pg_class', # This exists
],
0,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: no heap tables to check matching "no_such_table"/,
- qr/pg_amcheck: warning: no heap tables to check matching "no\*such\*table"/,
- qr/pg_amcheck: warning: no btree indexes to check matching "no_such_index"/,
- qr/pg_amcheck: warning: no btree indexes to check matching "no\*such\*index"/,
- qr/pg_amcheck: warning: no relations to check matching "no_such_relation"/,
- qr/pg_amcheck: warning: no relations to check matching "no\*such\*relation"/,
- qr/pg_amcheck: warning: no heap tables to check matching "no\*such\*table"/,
- qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database"/,
- qr/pg_amcheck: warning: no connectable databases to check matching "no\*such\*database"/,
- qr/pg_amcheck: warning: no relations to check matching "none\.none"/,
- qr/pg_amcheck: warning: no connectable databases to check matching "none\.none\.none"/,
- qr/pg_amcheck: warning: no connectable databases to check matching "this\.is\.a\.really\.long\.dotted\.string"/,
- qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.none"/,
- qr/pg_amcheck: warning: no relations to check matching "postgres\.long\.dotted\.string"/,
- qr/pg_amcheck: warning: no relations to check matching "postgres\.pg_catalog\.none"/,
- qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.pg_class"/,
- ],
- 'many unmatched patterns and one matched pattern under --no-strict-names');
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: no heap tables to check matching "no_such_table"/,
+ qr/pg_amcheck: warning: no heap tables to check matching "no\*such\*table"/,
+ qr/pg_amcheck: warning: no btree indexes to check matching "no_such_index"/,
+ qr/pg_amcheck: warning: no btree indexes to check matching "no\*such\*index"/,
+ qr/pg_amcheck: warning: no relations to check matching "no_such_relation"/,
+ qr/pg_amcheck: warning: no relations to check matching "no\*such\*relation"/,
+ qr/pg_amcheck: warning: no heap tables to check matching "no\*such\*table"/,
+ qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database"/,
+ qr/pg_amcheck: warning: no connectable databases to check matching "no\*such\*database"/,
+ qr/pg_amcheck: warning: no relations to check matching "none\.none"/,
+ qr/pg_amcheck: warning: no connectable databases to check matching "none\.none\.none"/,
+ qr/pg_amcheck: warning: no connectable databases to check matching "this\.is\.a\.really\.long\.dotted\.string"/,
+ qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.none"/,
+ qr/pg_amcheck: warning: no relations to check matching "postgres\.long\.dotted\.string"/,
+ qr/pg_amcheck: warning: no relations to check matching "postgres\.pg_catalog\.none"/,
+ qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.pg_class"/,
+ ],
+ 'many unmatched patterns and one matched pattern under --no-strict-names'
+);
#########################################
# Test checking otherwise existent objects but in databases where they do not exist
-$node->safe_psql('postgres', q(
+$node->safe_psql(
+ 'postgres', q(
CREATE TABLE public.foo (f integer);
CREATE INDEX foo_idx ON foo(f);
));
$node->safe_psql('postgres', q(CREATE DATABASE another_db));
$node->command_checks_all(
- [ 'pg_amcheck', '-d', 'postgres', '--no-strict-names',
- '-t', 'template1.public.foo',
- '-t', 'another_db.public.foo',
- '-t', 'no_such_database.public.foo',
- '-i', 'template1.public.foo_idx',
- '-i', 'another_db.public.foo_idx',
- '-i', 'no_such_database.public.foo_idx',
+ [
+ 'pg_amcheck', '-d',
+ 'postgres', '--no-strict-names',
+ '-t', 'template1.public.foo',
+ '-t', 'another_db.public.foo',
+ '-t', 'no_such_database.public.foo',
+ '-i', 'template1.public.foo_idx',
+ '-i', 'another_db.public.foo_idx',
+ '-i', 'no_such_database.public.foo_idx',
],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
- qr/pg_amcheck: warning: no heap tables to check matching "template1\.public\.foo"/,
- qr/pg_amcheck: warning: no heap tables to check matching "another_db\.public\.foo"/,
- qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database\.public\.foo"/,
- qr/pg_amcheck: warning: no btree indexes to check matching "template1\.public\.foo_idx"/,
- qr/pg_amcheck: warning: no btree indexes to check matching "another_db\.public\.foo_idx"/,
- qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database\.public\.foo_idx"/,
- qr/pg_amcheck: error: no relations to check/,
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
+ qr/pg_amcheck: warning: no heap tables to check matching "template1\.public\.foo"/,
+ qr/pg_amcheck: warning: no heap tables to check matching "another_db\.public\.foo"/,
+ qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database\.public\.foo"/,
+ qr/pg_amcheck: warning: no btree indexes to check matching "template1\.public\.foo_idx"/,
+ qr/pg_amcheck: warning: no btree indexes to check matching "another_db\.public\.foo_idx"/,
+ qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database\.public\.foo_idx"/,
+ qr/pg_amcheck: error: no relations to check/,
],
'checking otherwise existent objets in the wrong databases');
@@ -213,30 +236,31 @@ $node->command_checks_all(
# Check with only schema exclusion patterns
$node->command_checks_all(
- [ 'pg_amcheck', '--all', '--no-strict-names',
- '-S', 'public',
- '-S', 'pg_catalog',
- '-S', 'pg_toast',
- '-S', 'information_schema',
+ [
+ 'pg_amcheck', '--all', '--no-strict-names', '-S',
+ 'public', '-S', 'pg_catalog', '-S',
+ 'pg_toast', '-S', 'information_schema',
],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
- qr/pg_amcheck: error: no relations to check/ ],
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
+ qr/pg_amcheck: error: no relations to check/
+ ],
'schema exclusion patterns exclude all relations');
# Check with schema exclusion patterns overriding relation and schema inclusion patterns
$node->command_checks_all(
- [ 'pg_amcheck', '--all', '--no-strict-names',
- '-s', 'public',
- '-s', 'pg_catalog',
- '-s', 'pg_toast',
- '-s', 'information_schema',
- '-t', 'pg_catalog.pg_class',
- '-S*'
+ [
+ 'pg_amcheck', '--all', '--no-strict-names', '-s',
+ 'public', '-s', 'pg_catalog', '-s',
+ 'pg_toast', '-s', 'information_schema', '-t',
+ 'pg_catalog.pg_class', '-S*'
],
1,
- [ qr/^$/ ],
- [ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
- qr/pg_amcheck: error: no relations to check/ ],
+ [qr/^$/],
+ [
+ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
+ qr/pg_amcheck: error: no relations to check/
+ ],
'schema exclusion pattern overrides all inclusion patterns');
diff --git a/src/bin/pg_amcheck/t/003_check.pl b/src/bin/pg_amcheck/t/003_check.pl
index 659fd15983e..817eb4e1160 100644
--- a/src/bin/pg_amcheck/t/003_check.pl
+++ b/src/bin/pg_amcheck/t/003_check.pl
@@ -20,8 +20,8 @@ sub relation_filepath
my ($dbname, $relname) = @_;
my $pgdata = $node->data_dir;
- my $rel = $node->safe_psql($dbname,
- qq(SELECT pg_relation_filepath('$relname')));
+ my $rel =
+ $node->safe_psql($dbname, qq(SELECT pg_relation_filepath('$relname')));
die "path not found for relation $relname" unless defined $rel;
return "$pgdata/$rel";
}
@@ -33,7 +33,8 @@ sub relation_toast
{
my ($dbname, $relname) = @_;
- my $rel = $node->safe_psql($dbname, qq(
+ my $rel = $node->safe_psql(
+ $dbname, qq(
SELECT c.reltoastrelid::regclass
FROM pg_catalog.pg_class c
WHERE c.oid = '$relname'::regclass
@@ -83,23 +84,22 @@ sub corrupt_first_page
my $fh;
open($fh, '+<', $relpath)
- or BAIL_OUT("open failed: $!");
+ or BAIL_OUT("open failed: $!");
binmode $fh;
# Corrupt some line pointers. The values are chosen to hit the
# various line-pointer-corruption checks in verify_heapam.c
# on both little-endian and big-endian architectures.
seek($fh, 32, SEEK_SET)
- or BAIL_OUT("seek failed: $!");
+ or BAIL_OUT("seek failed: $!");
syswrite(
$fh,
pack("L*",
- 0xAAA15550, 0xAAA0D550, 0x00010000,
- 0x00008000, 0x0000800F, 0x001e8000,
- 0xFFFFFFFF)
+ 0xAAA15550, 0xAAA0D550, 0x00010000, 0x00008000,
+ 0x0000800F, 0x001e8000, 0xFFFFFFFF)
) or BAIL_OUT("syswrite failed: $!");
close($fh)
- or BAIL_OUT("close failed: $!");
+ or BAIL_OUT("close failed: $!");
}
# Stops the node, performs all the corruptions previously planned, and
@@ -137,7 +137,8 @@ for my $dbname (qw(db1 db2 db3))
# check that pg_amcheck does not get confused by them. Create functions in
# schema public that look like amcheck functions to check that pg_amcheck
# does not use them.
- $node->safe_psql($dbname, q(
+ $node->safe_psql(
+ $dbname, q(
CREATE SCHEMA amcheck_schema;
CREATE EXTENSION amcheck WITH SCHEMA amcheck_schema;
CREATE TABLE amcheck_schema.pg_database (junk text);
@@ -187,7 +188,8 @@ for my $dbname (qw(db1 db2 db3))
#
for my $schema (qw(s1 s2 s3 s4 s5))
{
- $node->safe_psql($dbname, qq(
+ $node->safe_psql(
+ $dbname, qq(
CREATE SCHEMA $schema;
CREATE SEQUENCE $schema.seq1;
CREATE SEQUENCE $schema.seq2;
@@ -318,21 +320,18 @@ plan_to_remove_relation_file('db2', 's1.t1_btree');
my @cmd = ('pg_amcheck', '--quiet', '-p', $port);
# Regular expressions to match various expected output
-my $no_output_re = qr/^$/;
+my $no_output_re = qr/^$/;
my $line_pointer_corruption_re = qr/line pointer/;
my $missing_file_re = qr/could not open file ".*": No such file or directory/;
-my $index_missing_relation_fork_re = qr/index ".*" lacks a main relation fork/;
+my $index_missing_relation_fork_re =
+ qr/index ".*" lacks a main relation fork/;
# We have created test databases with tables populated with data, but have not
# yet corrupted anything. As such, we expect no corruption and verify that
# none is reported
#
-$node->command_checks_all(
- [ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
- 0,
- [ $no_output_re ],
- [ $no_output_re ],
- 'pg_amcheck prior to corruption');
+$node->command_checks_all([ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
+ 0, [$no_output_re], [$no_output_re], 'pg_amcheck prior to corruption');
# Perform the corruptions we planned above using only a single database restart.
#
@@ -347,22 +346,23 @@ perform_all_corruptions();
$node->command_checks_all(
[ @cmd, 'db1' ],
2,
- [ $index_missing_relation_fork_re,
- $line_pointer_corruption_re,
- $missing_file_re,
+ [
+ $index_missing_relation_fork_re, $line_pointer_corruption_re,
+ $missing_file_re,
],
- [ $no_output_re ],
+ [$no_output_re],
'pg_amcheck all schemas, tables and indexes in database db1');
$node->command_checks_all(
[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
2,
- [ $index_missing_relation_fork_re,
- $line_pointer_corruption_re,
- $missing_file_re,
+ [
+ $index_missing_relation_fork_re, $line_pointer_corruption_re,
+ $missing_file_re,
],
- [ $no_output_re ],
- 'pg_amcheck all schemas, tables and indexes in databases db1, db2, and db3');
+ [$no_output_re],
+ 'pg_amcheck all schemas, tables and indexes in databases db1, db2, and db3'
+);
# Scans of indexes in s1 should detect the specific corruption that we created
# above. For missing relation forks, we know what the error message looks
@@ -376,15 +376,17 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '--all', '-s', 's1', '-i', 't1_btree' ],
2,
- [ $index_missing_relation_fork_re ],
- [ qr/pg_amcheck: warning: skipping database "postgres": amcheck is not installed/ ],
+ [$index_missing_relation_fork_re],
+ [
+ qr/pg_amcheck: warning: skipping database "postgres": amcheck is not installed/
+ ],
'pg_amcheck index s1.t1_btree reports missing main relation fork');
$node->command_checks_all(
[ @cmd, '-d', 'db1', '-s', 's1', '-i', 't2_btree' ],
2,
- [ qr/.+/ ], # Any non-empty error message is acceptable
- [ $no_output_re ],
+ [qr/.+/], # Any non-empty error message is acceptable
+ [$no_output_re],
'pg_amcheck index s1.s2 reports index corruption');
# Checking db1.s1 with indexes excluded should show no corruptions because we
@@ -393,18 +395,14 @@ $node->command_checks_all(
#
$node->command_checks_all(
[ @cmd, '-t', 's1.*', '--no-dependent-indexes', 'db1' ],
- 0,
- [ $no_output_re ],
- [ $no_output_re ],
+ 0, [$no_output_re], [$no_output_re],
'pg_amcheck of db1.s1 excluding indexes');
# Checking db2.s1 should show table corruptions if indexes are excluded
#
$node->command_checks_all(
[ @cmd, '-t', 's1.*', '--no-dependent-indexes', 'db2' ],
- 2,
- [ $missing_file_re ],
- [ $no_output_re ],
+ 2, [$missing_file_re], [$no_output_re],
'pg_amcheck of db2.s1 excluding indexes');
# In schema db1.s3, the tables and indexes are both corrupt. We should see
@@ -413,36 +411,33 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-s', 's3', 'db1' ],
2,
- [ $index_missing_relation_fork_re,
- $line_pointer_corruption_re,
- $missing_file_re,
+ [
+ $index_missing_relation_fork_re, $line_pointer_corruption_re,
+ $missing_file_re,
],
- [ $no_output_re ],
+ [$no_output_re],
'pg_amcheck schema s3 reports table and index errors');
# In schema db1.s4, only toast tables are corrupt. Check that under default
# options the toast corruption is reported, but when excluding toast we get no
# error reports.
-$node->command_checks_all(
- [ @cmd, '-s', 's4', 'db1' ],
- 2,
- [ $missing_file_re ],
- [ $no_output_re ],
+$node->command_checks_all([ @cmd, '-s', 's4', 'db1' ],
+ 2, [$missing_file_re], [$no_output_re],
'pg_amcheck in schema s4 reports toast corruption');
$node->command_checks_all(
- [ @cmd, '--no-dependent-toast', '--exclude-toast-pointers', '-s', 's4', 'db1' ],
+ [
+ @cmd, '--no-dependent-toast', '--exclude-toast-pointers', '-s', 's4',
+ 'db1'
+ ],
0,
- [ $no_output_re ],
- [ $no_output_re ],
+ [$no_output_re],
+ [$no_output_re],
'pg_amcheck in schema s4 excluding toast reports no corruption');
# Check that no corruption is reported in schema db1.s5
-$node->command_checks_all(
- [ @cmd, '-s', 's5', 'db1' ],
- 0,
- [ $no_output_re ],
- [ $no_output_re ],
+$node->command_checks_all([ @cmd, '-s', 's5', 'db1' ],
+ 0, [$no_output_re], [$no_output_re],
'pg_amcheck over schema s5 reports no corruption');
# In schema db1.s1, only indexes are corrupt. Verify that when we exclude
@@ -451,9 +446,10 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-s', 's1', '-I', 't1_btree', '-I', 't2_btree', 'db1' ],
0,
- [ $no_output_re ],
- [ $no_output_re ],
- 'pg_amcheck over schema s1 with corrupt indexes excluded reports no corruption');
+ [$no_output_re],
+ [$no_output_re],
+ 'pg_amcheck over schema s1 with corrupt indexes excluded reports no corruption'
+);
# In schema db1.s1, only indexes are corrupt. Verify that when we provide only
# table inclusions, and disable index expansion, no corruption is reported
@@ -462,9 +458,10 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-t', 's1.*', '--no-dependent-indexes', 'db1' ],
0,
- [ $no_output_re ],
- [ $no_output_re ],
- 'pg_amcheck over schema s1 with all indexes excluded reports no corruption');
+ [$no_output_re],
+ [$no_output_re],
+ 'pg_amcheck over schema s1 with all indexes excluded reports no corruption'
+);
# In schema db1.s2, only tables are corrupt. Verify that when we exclude those
# tables that no corruption is reported.
@@ -472,9 +469,10 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-s', 's2', '-T', 't1', '-T', 't2', 'db1' ],
0,
- [ $no_output_re ],
- [ $no_output_re ],
- 'pg_amcheck over schema s2 with corrupt tables excluded reports no corruption');
+ [$no_output_re],
+ [$no_output_re],
+ 'pg_amcheck over schema s2 with corrupt tables excluded reports no corruption'
+);
# Check errors about bad block range command line arguments. We use schema s5
# to avoid getting messages about corrupt tables or indexes.
@@ -501,20 +499,21 @@ command_fails_like(
$node->command_checks_all(
[ @cmd, '-s', 's1', '-i', 't1_btree', '--parent-check', 'db1' ],
2,
- [ $index_missing_relation_fork_re ],
- [ $no_output_re ],
+ [$index_missing_relation_fork_re],
+ [$no_output_re],
'pg_amcheck smoke test --parent-check');
$node->command_checks_all(
- [ @cmd, '-s', 's1', '-i', 't1_btree', '--heapallindexed', '--rootdescend', 'db1' ],
+ [
+ @cmd, '-s', 's1', '-i', 't1_btree', '--heapallindexed',
+ '--rootdescend', 'db1'
+ ],
2,
- [ $index_missing_relation_fork_re ],
- [ $no_output_re ],
+ [$index_missing_relation_fork_re],
+ [$no_output_re],
'pg_amcheck smoke test --heapallindexed --rootdescend');
$node->command_checks_all(
[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3', '-S', 's*' ],
- 0,
- [ $no_output_re ],
- [ $no_output_re ],
+ 0, [$no_output_re], [$no_output_re],
'pg_amcheck excluding all corrupt schemas');
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index fa4059172ec..b3a96e80169 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -85,7 +85,7 @@ use Test::More;
# constants here, where they can be compared easily against the layout.
use constant HEAPTUPLE_PACK_CODE => 'LLLSSSSSCCLLCCCCCCCCCCllLL';
-use constant HEAPTUPLE_PACK_LENGTH => 58; # Total size
+use constant HEAPTUPLE_PACK_LENGTH => 58; # Total size
# Read a tuple of our table from a heap page.
#
@@ -100,39 +100,40 @@ sub read_tuple
my ($fh, $offset) = @_;
my ($buffer, %tup);
seek($fh, $offset, SEEK_SET)
- or BAIL_OUT("seek failed: $!");
+ or BAIL_OUT("seek failed: $!");
defined(sysread($fh, $buffer, HEAPTUPLE_PACK_LENGTH))
- or BAIL_OUT("sysread failed: $!");
+ or BAIL_OUT("sysread failed: $!");
@_ = unpack(HEAPTUPLE_PACK_CODE, $buffer);
- %tup = (t_xmin => shift,
- t_xmax => shift,
- t_field3 => shift,
- bi_hi => shift,
- bi_lo => shift,
- ip_posid => shift,
- t_infomask2 => shift,
- t_infomask => shift,
- t_hoff => shift,
- t_bits => shift,
- a_1 => shift,
- a_2 => shift,
- b_header => shift,
- b_body1 => shift,
- b_body2 => shift,
- b_body3 => shift,
- b_body4 => shift,
- b_body5 => shift,
- b_body6 => shift,
- b_body7 => shift,
- c_va_header => shift,
- c_va_vartag => shift,
- c_va_rawsize => shift,
- c_va_extinfo => shift,
- c_va_valueid => shift,
- c_va_toastrelid => shift);
+ %tup = (
+ t_xmin => shift,
+ t_xmax => shift,
+ t_field3 => shift,
+ bi_hi => shift,
+ bi_lo => shift,
+ ip_posid => shift,
+ t_infomask2 => shift,
+ t_infomask => shift,
+ t_hoff => shift,
+ t_bits => shift,
+ a_1 => shift,
+ a_2 => shift,
+ b_header => shift,
+ b_body1 => shift,
+ b_body2 => shift,
+ b_body3 => shift,
+ b_body4 => shift,
+ b_body5 => shift,
+ b_body6 => shift,
+ b_body7 => shift,
+ c_va_header => shift,
+ c_va_vartag => shift,
+ c_va_rawsize => shift,
+ c_va_extinfo => shift,
+ c_va_valueid => shift,
+ c_va_toastrelid => shift);
# Stitch together the text for column 'b'
- $tup{b} = join('', map { chr($tup{"b_body$_"}) } (1..7));
+ $tup{b} = join('', map { chr($tup{"b_body$_"}) } (1 .. 7));
return \%tup;
}
@@ -149,37 +150,25 @@ sub read_tuple
sub write_tuple
{
my ($fh, $offset, $tup) = @_;
- my $buffer = pack(HEAPTUPLE_PACK_CODE,
- $tup->{t_xmin},
- $tup->{t_xmax},
- $tup->{t_field3},
- $tup->{bi_hi},
- $tup->{bi_lo},
- $tup->{ip_posid},
- $tup->{t_infomask2},
- $tup->{t_infomask},
- $tup->{t_hoff},
- $tup->{t_bits},
- $tup->{a_1},
- $tup->{a_2},
- $tup->{b_header},
- $tup->{b_body1},
- $tup->{b_body2},
- $tup->{b_body3},
- $tup->{b_body4},
- $tup->{b_body5},
- $tup->{b_body6},
- $tup->{b_body7},
- $tup->{c_va_header},
- $tup->{c_va_vartag},
- $tup->{c_va_rawsize},
- $tup->{c_va_extinfo},
- $tup->{c_va_valueid},
- $tup->{c_va_toastrelid});
+ my $buffer = pack(
+ HEAPTUPLE_PACK_CODE,
+ $tup->{t_xmin}, $tup->{t_xmax},
+ $tup->{t_field3}, $tup->{bi_hi},
+ $tup->{bi_lo}, $tup->{ip_posid},
+ $tup->{t_infomask2}, $tup->{t_infomask},
+ $tup->{t_hoff}, $tup->{t_bits},
+ $tup->{a_1}, $tup->{a_2},
+ $tup->{b_header}, $tup->{b_body1},
+ $tup->{b_body2}, $tup->{b_body3},
+ $tup->{b_body4}, $tup->{b_body5},
+ $tup->{b_body6}, $tup->{b_body7},
+ $tup->{c_va_header}, $tup->{c_va_vartag},
+ $tup->{c_va_rawsize}, $tup->{c_va_extinfo},
+ $tup->{c_va_valueid}, $tup->{c_va_toastrelid});
seek($fh, $offset, SEEK_SET)
- or BAIL_OUT("seek failed: $!");
+ or BAIL_OUT("seek failed: $!");
defined(syswrite($fh, $buffer, HEAPTUPLE_PACK_LENGTH))
- or BAIL_OUT("syswrite failed: $!");
+ or BAIL_OUT("syswrite failed: $!");
return;
}
@@ -196,7 +185,7 @@ $node->append_conf('postgresql.conf', 'autovacuum=off');
# Start the node and load the extensions. We depend on both
# amcheck and pageinspect for this test.
$node->start;
-my $port = $node->port;
+my $port = $node->port;
my $pgdata = $node->data_dir;
$node->safe_psql('postgres', "CREATE EXTENSION amcheck");
$node->safe_psql('postgres', "CREATE EXTENSION pageinspect");
@@ -224,12 +213,14 @@ $node->safe_psql(
VACUUM FREEZE public.junk
));
-my $rel = $node->safe_psql('postgres', qq(SELECT pg_relation_filepath('public.test')));
+my $rel = $node->safe_psql('postgres',
+ qq(SELECT pg_relation_filepath('public.test')));
my $relpath = "$pgdata/$rel";
# Insert data and freeze public.test
use constant ROWCOUNT => 16;
-$node->safe_psql('postgres', qq(
+$node->safe_psql(
+ 'postgres', qq(
INSERT INTO public.test (a, b, c)
VALUES (
x'DEADF9F9DEADF9F9'::bigint,
@@ -237,7 +228,7 @@ $node->safe_psql('postgres', qq(
repeat('w', 10000)
);
VACUUM FREEZE public.test
- )) for (1..ROWCOUNT);
+ )) for (1 .. ROWCOUNT);
my $relfrozenxid = $node->safe_psql('postgres',
q(select relfrozenxid from pg_class where relname = 'test'));
@@ -250,15 +241,19 @@ my $datfrozenxid = $node->safe_psql('postgres',
if ($datfrozenxid <= 3 || $datfrozenxid >= $relfrozenxid)
{
$node->clean_node;
- plan skip_all => "Xid thresholds not as expected: got datfrozenxid = $datfrozenxid, relfrozenxid = $relfrozenxid";
+ plan skip_all =>
+ "Xid thresholds not as expected: got datfrozenxid = $datfrozenxid, relfrozenxid = $relfrozenxid";
exit;
}
# Find where each of the tuples is located on the page.
my @lp_off;
-for my $tup (0..ROWCOUNT-1)
+for my $tup (0 .. ROWCOUNT - 1)
{
- push (@lp_off, $node->safe_psql('postgres', qq(
+ push(
+ @lp_off,
+ $node->safe_psql(
+ 'postgres', qq(
select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
offset $tup limit 1)));
}
@@ -269,26 +264,28 @@ select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
$node->stop;
my $file;
open($file, '+<', $relpath)
- or BAIL_OUT("open failed: $!");
+ or BAIL_OUT("open failed: $!");
binmode $file;
my $ENDIANNESS;
for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
{
- my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
+ my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
my $offset = $lp_off[$tupidx];
my $tup = read_tuple($file, $offset);
# Sanity-check that the data appears on the page where we expect.
my $a_1 = $tup->{a_1};
my $a_2 = $tup->{a_2};
- my $b = $tup->{b};
+ my $b = $tup->{b};
if ($a_1 != 0xDEADF9F9 || $a_2 != 0xDEADF9F9 || $b ne 'abcdefg')
{
- close($file); # ignore errors on close; we're exiting anyway
+ close($file); # ignore errors on close; we're exiting anyway
$node->clean_node;
- plan skip_all => sprintf("Page layout differs from our expectations: expected (%x, %x, \"%s\"), got (%x, %x, \"%s\")",
- 0xDEADF9F9, 0xDEADF9F9, "abcdefg", $a_1, $a_2, $b);
+ plan skip_all =>
+ sprintf(
+ "Page layout differs from our expectations: expected (%x, %x, \"%s\"), got (%x, %x, \"%s\")",
+ 0xDEADF9F9, 0xDEADF9F9, "abcdefg", $a_1, $a_2, $b);
exit;
}
@@ -296,44 +293,47 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$ENDIANNESS = $tup->{b_header} == 0x11 ? "little" : "big";
}
close($file)
- or BAIL_OUT("close failed: $!");
+ or BAIL_OUT("close failed: $!");
$node->start;
# Ok, Xids and page layout look ok. We can run corruption tests.
plan tests => 19;
# Check that pg_amcheck runs against the uncorrupted table without error.
-$node->command_ok(['pg_amcheck', '-p', $port, 'postgres'],
- 'pg_amcheck test table, prior to corruption');
+$node->command_ok(
+ [ 'pg_amcheck', '-p', $port, 'postgres' ],
+ 'pg_amcheck test table, prior to corruption');
# Check that pg_amcheck runs against the uncorrupted table and index without error.
-$node->command_ok(['pg_amcheck', '-p', $port, 'postgres'],
- 'pg_amcheck test table and index, prior to corruption');
+$node->command_ok([ 'pg_amcheck', '-p', $port, 'postgres' ],
+ 'pg_amcheck test table and index, prior to corruption');
$node->stop;
# Some #define constants from access/htup_details.h for use while corrupting.
-use constant HEAP_HASNULL => 0x0001;
-use constant HEAP_XMAX_LOCK_ONLY => 0x0080;
-use constant HEAP_XMIN_COMMITTED => 0x0100;
-use constant HEAP_XMIN_INVALID => 0x0200;
-use constant HEAP_XMAX_COMMITTED => 0x0400;
-use constant HEAP_XMAX_INVALID => 0x0800;
-use constant HEAP_NATTS_MASK => 0x07FF;
-use constant HEAP_XMAX_IS_MULTI => 0x1000;
-use constant HEAP_KEYS_UPDATED => 0x2000;
+use constant HEAP_HASNULL => 0x0001;
+use constant HEAP_XMAX_LOCK_ONLY => 0x0080;
+use constant HEAP_XMIN_COMMITTED => 0x0100;
+use constant HEAP_XMIN_INVALID => 0x0200;
+use constant HEAP_XMAX_COMMITTED => 0x0400;
+use constant HEAP_XMAX_INVALID => 0x0800;
+use constant HEAP_NATTS_MASK => 0x07FF;
+use constant HEAP_XMAX_IS_MULTI => 0x1000;
+use constant HEAP_KEYS_UPDATED => 0x2000;
# Helper function to generate a regular expression matching the header we
# expect verify_heapam() to return given which fields we expect to be non-null.
sub header
{
my ($blkno, $offnum, $attnum) = @_;
- return qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum, attribute $attnum:\s+/ms
- if (defined $attnum);
- return qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum:\s+/ms
- if (defined $offnum);
+ return
+ qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum, attribute $attnum:\s+/ms
+ if (defined $attnum);
+ return
+ qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum:\s+/ms
+ if (defined $offnum);
return qr/heap table "postgres"\."public"\."test", block $blkno:\s+/ms
- if (defined $blkno);
+ if (defined $blkno);
return qr/heap table "postgres"\."public"\."test":\s+/ms;
}
@@ -344,12 +344,12 @@ sub header
#
my @expected;
open($file, '+<', $relpath)
- or BAIL_OUT("open failed: $!");
+ or BAIL_OUT("open failed: $!");
binmode $file;
for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
{
- my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
+ my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
my $offset = $lp_off[$tupidx];
my $tup = read_tuple($file, $offset);
@@ -364,7 +364,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
}
if ($offnum == 2)
{
@@ -375,7 +375,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
}
elsif ($offnum == 3)
{
@@ -387,7 +387,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
}
elsif ($offnum == 4)
{
@@ -396,7 +396,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
}
elsif ($offnum == 5)
{
@@ -404,8 +404,8 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} += 128;
push @expected,
- qr/${$header}data begins at offset 152 beyond the tuple length 58/,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 152 \(3 attributes, no nulls\)/;
+ qr/${$header}data begins at offset 152 beyond the tuple length 58/,
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 152 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 6)
{
@@ -413,7 +413,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} += 3;
push @expected,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 27 \(3 attributes, no nulls\)/;
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 27 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 7)
{
@@ -421,7 +421,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} -= 8;
push @expected,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 16 \(3 attributes, no nulls\)/;
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 16 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 8)
{
@@ -429,7 +429,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} -= 3;
push @expected,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 21 \(3 attributes, no nulls\)/;
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 21 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 9)
{
@@ -437,30 +437,30 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask2} |= HEAP_NATTS_MASK;
push @expected,
- qr/${$header}number of attributes 2047 exceeds maximum expected for table 3/;
+ qr/${$header}number of attributes 2047 exceeds maximum expected for table 3/;
}
elsif ($offnum == 10)
{
# Corrupt the tuple to look like it has lots of attributes, some of
# them null. This falsely creates the impression that the t_bits
# array is longer than just one byte, but t_hoff still says otherwise.
- $tup->{t_infomask} |= HEAP_HASNULL;
+ $tup->{t_infomask} |= HEAP_HASNULL;
$tup->{t_infomask2} |= HEAP_NATTS_MASK;
$tup->{t_bits} = 0xAA;
push @expected,
- qr/${$header}tuple data should begin at byte 280, but actually begins at byte 24 \(2047 attributes, has nulls\)/;
+ qr/${$header}tuple data should begin at byte 280, but actually begins at byte 24 \(2047 attributes, has nulls\)/;
}
elsif ($offnum == 11)
{
# Same as above, but this time t_hoff plays along
- $tup->{t_infomask} |= HEAP_HASNULL;
+ $tup->{t_infomask} |= HEAP_HASNULL;
$tup->{t_infomask2} |= (HEAP_NATTS_MASK & 0x40);
$tup->{t_bits} = 0xAA;
$tup->{t_hoff} = 32;
push @expected,
- qr/${$header}number of attributes 67 exceeds maximum expected for table 3/;
+ qr/${$header}number of attributes 67 exceeds maximum expected for table 3/;
}
elsif ($offnum == 12)
{
@@ -478,13 +478,13 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# bytes with 0xFF using 0x3FFFFFFF.
#
$tup->{b_header} = $ENDIANNESS eq 'little' ? 0xFC : 0x3F;
- $tup->{b_body1} = 0xFF;
- $tup->{b_body2} = 0xFF;
- $tup->{b_body3} = 0xFF;
+ $tup->{b_body1} = 0xFF;
+ $tup->{b_body2} = 0xFF;
+ $tup->{b_body3} = 0xFF;
$header = header(0, $offnum, 1);
push @expected,
- qr/${header}attribute with length \d+ ends at offset \d+ beyond total tuple length \d+/;
+ qr/${header}attribute with length \d+ ends at offset \d+ beyond total tuple length \d+/;
}
elsif ($offnum == 13)
{
@@ -492,8 +492,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{c_va_valueid} = 0xFFFFFFFF;
$header = header(0, $offnum, 2);
- push @expected,
- qr/${header}toast value \d+ not found in toast table/;
+ push @expected, qr/${header}toast value \d+ not found in toast table/;
}
elsif ($offnum == 14)
{
@@ -503,9 +502,9 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_xmax} = 4;
push @expected,
- qr/${header}multitransaction ID 4 equals or exceeds next valid multitransaction ID 1/;
+ qr/${header}multitransaction ID 4 equals or exceeds next valid multitransaction ID 1/;
}
- elsif ($offnum == 15) # Last offnum must equal ROWCOUNT
+ elsif ($offnum == 15) # Last offnum must equal ROWCOUNT
{
# Set both HEAP_XMAX_COMMITTED and HEAP_XMAX_IS_MULTI
$tup->{t_infomask} |= HEAP_XMAX_COMMITTED;
@@ -513,22 +512,19 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_xmax} = 4000000000;
push @expected,
- qr/${header}multitransaction ID 4000000000 precedes relation minimum multitransaction ID threshold 1/;
+ qr/${header}multitransaction ID 4000000000 precedes relation minimum multitransaction ID threshold 1/;
}
write_tuple($file, $offset, $tup);
}
close($file)
- or BAIL_OUT("close failed: $!");
+ or BAIL_OUT("close failed: $!");
$node->start;
# Run pg_amcheck against the corrupt table with epoch=0, comparing actual
# corruption messages against the expected messages
$node->command_checks_all(
- ['pg_amcheck', '--no-dependent-indexes', '-p', $port, 'postgres'],
- 2,
- [ @expected ],
- [ ],
- 'Expected corruption message output');
+ [ 'pg_amcheck', '--no-dependent-indexes', '-p', $port, 'postgres' ],
+ 2, [@expected], [], 'Expected corruption message output');
$node->teardown_node;
$node->clean_node;
diff --git a/src/bin/pg_amcheck/t/005_opclass_damage.pl b/src/bin/pg_amcheck/t/005_opclass_damage.pl
index 062015aa003..b65becae9d8 100644
--- a/src/bin/pg_amcheck/t/005_opclass_damage.pl
+++ b/src/bin/pg_amcheck/t/005_opclass_damage.pl
@@ -15,7 +15,8 @@ $node->init;
$node->start;
# Create a custom operator class and an index which uses it.
-$node->safe_psql('postgres', q(
+$node->safe_psql(
+ 'postgres', q(
CREATE EXTENSION amcheck;
CREATE FUNCTION int4_asc_cmp (a int4, b int4) RETURNS int LANGUAGE sql AS $$
@@ -39,7 +40,8 @@ $node->command_like(
# Change the operator class to use a function which sorts in a different
# order to corrupt the btree index
-$node->safe_psql('postgres', q(
+$node->safe_psql(
+ 'postgres', q(
CREATE FUNCTION int4_desc_cmp (int4, int4) RETURNS int LANGUAGE sql AS $$
SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN -1 ELSE 1 END; $$;
UPDATE pg_catalog.pg_amproc
@@ -51,7 +53,7 @@ $node->safe_psql('postgres', q(
$node->command_checks_all(
[ 'pg_amcheck', '-p', $node->port, 'postgres' ],
2,
- [ qr/item order invariant violated for index "fickleidx"/ ],
- [ ],
+ [qr/item order invariant violated for index "fickleidx"/],
+ [],
'pg_amcheck all schemas, tables and indexes reports fickleidx corruption'
);
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 28949c9caf8..74f8c2c7393 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -554,7 +554,7 @@ my $file_corrupt2 = $node->safe_psql('postgres',
# set page header and block sizes
my $pageheader_size = 24;
-my $block_size = $node->safe_psql('postgres', 'SHOW block_size;');
+my $block_size = $node->safe_psql('postgres', 'SHOW block_size;');
# induce corruption
system_or_bail 'pg_ctl', '-D', $pgdata, 'stop';
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 7fcd2014e73..1f24e796651 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -522,7 +522,7 @@ flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables)
{
bool foundNotNull; /* Attr was NOT NULL in a parent */
bool foundDefault; /* Found a default in a parent */
- bool foundGenerated; /* Found a generated in a parent */
+ bool foundGenerated; /* Found a generated in a parent */
/* no point in examining dropped columns */
if (tbinfo->attisdropped[j])
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 2fdc0d341f3..91060944f1f 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -393,7 +393,8 @@ struct _tocEntry
/* working state while dumping/restoring */
pgoff_t dataLength; /* item's data size; 0 if none or unknown */
- int reqs; /* do we need schema and/or data of object (REQ_* bit mask) */
+ int reqs; /* do we need schema and/or data of object
+ * (REQ_* bit mask) */
bool created; /* set for DATA member if TABLE was created */
/* working state (needed only for parallel restore) */
@@ -443,7 +444,7 @@ extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
-extern int TocIDRequired(ArchiveHandle *AH, DumpId id);
+extern int TocIDRequired(ArchiveHandle *AH, DumpId id);
TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id);
extern bool checkSeek(FILE *fp);
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index b773ed0cb82..65bcb41a2f8 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -1187,7 +1187,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
/* Header doesn't match, so read to next header */
len = th->fileLen;
len += tarPaddingBytesRequired(th->fileLen);
- blks = len / TAR_BLOCK_SIZE; /* # of tar blocks */
+ blks = len / TAR_BLOCK_SIZE; /* # of tar blocks */
for (i = 0; i < blks; i++)
_tarReadRaw(AH, &header[0], TAR_BLOCK_SIZE, NULL, ctx->tarFH);
diff --git a/src/bin/pg_dump/t/010_dump_connstr.pl b/src/bin/pg_dump/t/010_dump_connstr.pl
index 9a61eea060d..6478894160b 100644
--- a/src/bin/pg_dump/t/010_dump_connstr.pl
+++ b/src/bin/pg_dump/t/010_dump_connstr.pl
@@ -30,7 +30,7 @@ $ENV{PGCLIENTENCODING} = 'LATIN1';
# The odds of finding something interesting by testing all ASCII letters
# seem too small to justify the cycles of testing a fifth name.
my $dbname1 =
- 'regression'
+ 'regression'
. generate_ascii_string(1, 9)
. generate_ascii_string(11, 12)
. generate_ascii_string(14, 33)
diff --git a/src/bin/pg_rewind/t/001_basic.pl b/src/bin/pg_rewind/t/001_basic.pl
index 15a6f25adee..d636f35f5e5 100644
--- a/src/bin/pg_rewind/t/001_basic.pl
+++ b/src/bin/pg_rewind/t/001_basic.pl
@@ -74,7 +74,8 @@ sub run_test
primary_psql("VACUUM tail_tbl");
# Drop drop_tbl. pg_rewind should copy it back.
- primary_psql("insert into drop_tbl values ('in primary, after promotion')");
+ primary_psql(
+ "insert into drop_tbl values ('in primary, after promotion')");
primary_psql("DROP TABLE drop_tbl");
# Before running pg_rewind, do a couple of extra tests with several
@@ -83,7 +84,7 @@ sub run_test
# in "local" mode for simplicity's sake.
if ($test_mode eq 'local')
{
- my $primary_pgdata = $node_primary->data_dir;
+ my $primary_pgdata = $node_primary->data_dir;
my $standby_pgdata = $node_standby->data_dir;
# First check that pg_rewind fails if the target cluster is
diff --git a/src/bin/pg_rewind/t/003_extrafiles.pl b/src/bin/pg_rewind/t/003_extrafiles.pl
index 4fc500d4b4c..672c5e586ba 100644
--- a/src/bin/pg_rewind/t/003_extrafiles.pl
+++ b/src/bin/pg_rewind/t/003_extrafiles.pl
@@ -27,10 +27,13 @@ sub run_test
# Create a subdir and files that will be present in both
mkdir "$test_primary_datadir/tst_both_dir";
- append_to_file "$test_primary_datadir/tst_both_dir/both_file1", "in both1";
- append_to_file "$test_primary_datadir/tst_both_dir/both_file2", "in both2";
+ append_to_file "$test_primary_datadir/tst_both_dir/both_file1",
+ "in both1";
+ append_to_file "$test_primary_datadir/tst_both_dir/both_file2",
+ "in both2";
mkdir "$test_primary_datadir/tst_both_dir/both_subdir/";
- append_to_file "$test_primary_datadir/tst_both_dir/both_subdir/both_file3",
+ append_to_file
+ "$test_primary_datadir/tst_both_dir/both_subdir/both_file3",
"in both3";
RewindTest::create_standby($test_mode);
diff --git a/src/bin/pg_rewind/t/008_min_recovery_point.pl b/src/bin/pg_rewind/t/008_min_recovery_point.pl
index 7d9362cc229..9ebcbad0d26 100644
--- a/src/bin/pg_rewind/t/008_min_recovery_point.pl
+++ b/src/bin/pg_rewind/t/008_min_recovery_point.pl
@@ -42,7 +42,8 @@ my $tmp_folder = TestLib::tempdir;
my $node_1 = get_new_node('node_1');
$node_1->init(allows_streaming => 1);
-$node_1->append_conf('postgresql.conf', qq(
+$node_1->append_conf(
+ 'postgresql.conf', qq(
wal_keep_size='100 MB'
));
@@ -60,13 +61,11 @@ my $backup_name = 'my_backup';
$node_1->backup($backup_name);
my $node_2 = get_new_node('node_2');
-$node_2->init_from_backup($node_1, $backup_name,
- has_streaming => 1);
+$node_2->init_from_backup($node_1, $backup_name, has_streaming => 1);
$node_2->start;
my $node_3 = get_new_node('node_3');
-$node_3->init_from_backup($node_1, $backup_name,
- has_streaming => 1);
+$node_3->init_from_backup($node_1, $backup_name, has_streaming => 1);
$node_3->start;
# Wait until node 3 has connected and caught up
@@ -88,14 +87,16 @@ $node_3->safe_psql('postgres', "checkpoint");
# reconfigure node_1 as a standby following node_3
my $node_3_connstr = $node_3->connstr;
-$node_1->append_conf('postgresql.conf', qq(
+$node_1->append_conf(
+ 'postgresql.conf', qq(
primary_conninfo='$node_3_connstr'
));
$node_1->set_standby_mode();
$node_1->start();
# also reconfigure node_2 to follow node_3
-$node_2->append_conf('postgresql.conf', qq(
+$node_2->append_conf(
+ 'postgresql.conf', qq(
primary_conninfo='$node_3_connstr'
));
$node_2->restart();
@@ -117,17 +118,21 @@ $node_1->safe_psql('postgres', "checkpoint");
# demonstratively create a split brain. After the rewind, we should only
# see the insert on 1, as the insert on node 3 is rewound away.
#
-$node_1->safe_psql('postgres', "INSERT INTO public.foo (t) VALUES ('keep this')");
+$node_1->safe_psql('postgres',
+ "INSERT INTO public.foo (t) VALUES ('keep this')");
# 'bar' is unmodified in node 1, so it won't be overwritten by replaying the
# WAL from node 1.
-$node_3->safe_psql('postgres', "INSERT INTO public.bar (t) VALUES ('rewind this')");
+$node_3->safe_psql('postgres',
+ "INSERT INTO public.bar (t) VALUES ('rewind this')");
# Insert more rows in node 1, to bump up the XID counter. Otherwise, if
# rewind doesn't correctly rewind the changes made on the other node,
# we might fail to notice if the inserts are invisible because the XIDs
# are not marked as committed.
-$node_1->safe_psql('postgres', "INSERT INTO public.foo (t) VALUES ('and this')");
-$node_1->safe_psql('postgres', "INSERT INTO public.foo (t) VALUES ('and this too')");
+$node_1->safe_psql('postgres',
+ "INSERT INTO public.foo (t) VALUES ('and this')");
+$node_1->safe_psql('postgres',
+ "INSERT INTO public.foo (t) VALUES ('and this too')");
# Wait for node 2 to catch up
$node_2->poll_query_until('postgres',
@@ -138,7 +143,7 @@ $node_2->poll_query_until('postgres',
$node_2->stop('fast');
$node_3->stop('fast');
-my $node_2_pgdata = $node_2->data_dir;
+my $node_2_pgdata = $node_2->data_dir;
my $node_1_connstr = $node_1->connstr;
# Keep a temporary postgresql.conf or it would be overwritten during the rewind.
@@ -147,12 +152,10 @@ copy(
"$tmp_folder/node_2-postgresql.conf.tmp");
command_ok(
- [
- 'pg_rewind',
- "--source-server=$node_1_connstr",
- "--target-pgdata=$node_2_pgdata",
- "--debug"
- ],
+ [
+ 'pg_rewind', "--source-server=$node_1_connstr",
+ "--target-pgdata=$node_2_pgdata", "--debug"
+ ],
'run pg_rewind');
# Now move back postgresql.conf with old settings
@@ -166,7 +169,7 @@ $node_2->start;
# before rewind should've been overwritten with the data from node 1.
my $result;
$result = $node_2->safe_psql('postgres', 'SELECT * FROM public.foo');
-is($result, qq(keep this
+is( $result, qq(keep this
and this
and this too), 'table foo after rewind');
diff --git a/src/bin/pg_rewind/t/RewindTest.pm b/src/bin/pg_rewind/t/RewindTest.pm
index 55a350af9d6..938c661afc2 100644
--- a/src/bin/pg_rewind/t/RewindTest.pm
+++ b/src/bin/pg_rewind/t/RewindTest.pm
@@ -223,7 +223,7 @@ sub promote_standby
sub run_pg_rewind
{
my $test_mode = shift;
- my $primary_pgdata = $node_primary->data_dir;
+ my $primary_pgdata = $node_primary->data_dir;
my $standby_pgdata = $node_standby->data_dir;
my $standby_connstr = $node_standby->connstr('postgres');
my $tmp_folder = TestLib::tempdir;
@@ -286,8 +286,8 @@ sub run_pg_rewind
# recovery configuration automatically.
command_ok(
[
- 'pg_rewind', "--debug",
- "--source-server", $standby_connstr,
+ 'pg_rewind', "--debug",
+ "--source-server", $standby_connstr,
"--target-pgdata=$primary_pgdata", "--no-sync",
"--write-recovery-conf"
],
diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
index 29ee7c7d6f1..78dab5096c6 100644
--- a/src/bin/pg_test_fsync/pg_test_fsync.c
+++ b/src/bin/pg_test_fsync/pg_test_fsync.c
@@ -401,6 +401,7 @@ test_sync(int writes_per_op)
buf,
XLOG_BLCKSZ,
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+
/*
* This can generate write failures if the filesystem has
* a large block size, e.g. 4k, and there is no support
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 955a1533d05..0c47a6b8cc0 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -486,8 +486,8 @@ check_databases_are_compatible(void)
static void
check_for_new_tablespace_dir(ClusterInfo *new_cluster)
{
- int tblnum;
- char new_tablespace_dir[MAXPGPATH];
+ int tblnum;
+ char new_tablespace_dir[MAXPGPATH];
prep_status("Checking for new cluster tablespace directories");
@@ -496,8 +496,8 @@ check_for_new_tablespace_dir(ClusterInfo *new_cluster)
struct stat statbuf;
snprintf(new_tablespace_dir, MAXPGPATH, "%s%s",
- os_info.old_tablespaces[tblnum],
- new_cluster->tablespace_suffix);
+ os_info.old_tablespaces[tblnum],
+ new_cluster->tablespace_suffix);
if (stat(new_tablespace_dir, &statbuf) == 0 || errno != ENOENT)
pg_fatal("new cluster tablespace directory already exists: \"%s\"\n",
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 9e52846ef8b..19cc06e0c36 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -416,11 +416,11 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
static void
check_exec(const char *dir, const char *program, bool check_version)
{
- char path[MAXPGPATH];
- char line[MAXPGPATH];
- char cmd[MAXPGPATH];
- char versionstr[128];
- int ret;
+ char path[MAXPGPATH];
+ char line[MAXPGPATH];
+ char cmd[MAXPGPATH];
+ char versionstr[128];
+ int ret;
snprintf(path, sizeof(path), "%s/%s", dir, program);
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 08276659977..dc84b7b9b78 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6577,8 +6577,8 @@ threadRun(void *arg)
* GO before proceeding to the "done" path which will cleanup,
* so as to avoid locking the process.
*
- * It is unclear whether it is worth doing anything rather than
- * coldly exiting with an error message.
+ * It is unclear whether it is worth doing anything rather
+ * than coldly exiting with an error message.
*/
THREAD_BARRIER_WAIT(&barrier);
goto done;
diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl
index e1496bb2130..2eaf9ab4c29 100644
--- a/src/bin/pgbench/t/001_pgbench_with_server.pl
+++ b/src/bin/pgbench/t/001_pgbench_with_server.pl
@@ -487,7 +487,7 @@ pgbench(
qr{command=98.: int 5432\b}, # :random_seed
qr{command=99.: int -9223372036854775808\b}, # min int
qr{command=100.: int 9223372036854775807\b}, # max int
- # pseudorandom permutation tests
+ # pseudorandom permutation tests
qr{command=101.: boolean true\b},
qr{command=102.: boolean true\b},
qr{command=103.: boolean true\b},
@@ -1091,8 +1091,10 @@ SELECT LEAST(} . join(', ', (':i') x 256) . q{)}
[qr{malformed variable.*trueXXX}], q{\set b :badtrue or true}
],
[
- 'invalid permute size', 2,
- [qr{permute size parameter must be greater than zero}], q{\set i permute(0, 0)}
+ 'invalid permute size',
+ 2,
+ [qr{permute size parameter must be greater than zero}],
+ q{\set i permute(0, 0)}
],
# GSET
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index d917987fd58..51ae248ed8c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1788,14 +1788,14 @@ psql_completion(const char *text, int start, int end)
/* ALTER INDEX <foo> SET|RESET ( */
else if (Matches("ALTER", "INDEX", MatchAny, "RESET", "("))
COMPLETE_WITH("fillfactor",
- "deduplicate_items", /* BTREE */
+ "deduplicate_items", /* BTREE */
"fastupdate", "gin_pending_list_limit", /* GIN */
"buffering", /* GiST */
"pages_per_range", "autosummarize" /* BRIN */
);
else if (Matches("ALTER", "INDEX", MatchAny, "SET", "("))
COMPLETE_WITH("fillfactor =",
- "deduplicate_items =", /* BTREE */
+ "deduplicate_items =", /* BTREE */
"fastupdate =", "gin_pending_list_limit =", /* GIN */
"buffering =", /* GiST */
"pages_per_range =", "autosummarize =" /* BRIN */