Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit db6e2b4

Browse files
committed
Initial pgperltidy run for v12.
Make all the perl code look nice, too (for some value of "nice").
1 parent 8255c7a commit db6e2b4

38 files changed

+487
-384
lines changed

src/backend/catalog/genbki.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
use File::Basename;
2222
use File::Spec;
23-
BEGIN { use lib File::Spec->rel2abs(dirname(__FILE__)); }
23+
BEGIN { use lib File::Spec->rel2abs(dirname(__FILE__)); }
2424

2525
use Catalog;
2626

@@ -34,7 +34,7 @@
3434
'include-path:s' => \$include_path) || usage();
3535

3636
# Sanity check arguments.
37-
die "No input files.\n" unless @ARGV;
37+
die "No input files.\n" unless @ARGV;
3838
die "--set-version must be specified.\n" unless $major_version;
3939
die "Invalid version string: $major_version\n"
4040
unless $major_version =~ /^\d+$/;
@@ -301,7 +301,7 @@
301301
$typeoids{ $row->{typname} } = $row->{oid};
302302

303303
# for pg_attribute copies of pg_type values
304-
$types{ $row->{typname} } = $row;
304+
$types{ $row->{typname} } = $row;
305305
}
306306

307307
# Encoding identifier lookup. This uses the same replacement machinery
@@ -313,7 +313,7 @@
313313

314314
# We're parsing an enum, so start with 0 and increment
315315
# every time we find an enum member.
316-
my $encid = 0;
316+
my $encid = 0;
317317
my $collect_encodings = 0;
318318
while (<$ef>)
319319
{

src/backend/utils/Gen_fmgrtab.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
$bmap{'f'} = 'false';
204204
my @fmgr_builtin_oid_index;
205205
my $last_builtin_oid = 0;
206-
my $fmgr_count = 0;
206+
my $fmgr_count = 0;
207207
foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
208208
{
209209
print $tfh

src/bin/initdb/t/001_initdb.pl

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@
6060
}
6161

6262
# Control file should tell that data checksums are disabled by default.
63-
command_like(['pg_controldata', $datadir],
64-
qr/Data page checksum version:.*0/,
65-
'checksums are disabled in control file');
63+
command_like(
64+
[ 'pg_controldata', $datadir ],
65+
qr/Data page checksum version:.*0/,
66+
'checksums are disabled in control file');
6667
# pg_checksums fails with checksums disabled by default. This is
6768
# not part of the tests included in pg_checksums to save from
6869
# the creation of an extra instance.
69-
command_fails(
70-
[ 'pg_checksums', '-D', $datadir],
70+
command_fails([ 'pg_checksums', '-D', $datadir ],
7171
"pg_checksums fails with data checksum disabled");
7272

7373
command_ok([ 'initdb', '-S', $datadir ], 'sync only');

src/bin/pg_basebackup/t/010_pg_basebackup.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@
359359
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backupR", '-R' ],
360360
'pg_basebackup -R runs');
361361
ok(-f "$tempdir/backupR/postgresql.auto.conf", 'postgresql.auto.conf exists');
362-
ok(-f "$tempdir/backupR/standby.signal", 'standby.signal was created');
362+
ok(-f "$tempdir/backupR/standby.signal", 'standby.signal was created');
363363
my $recovery_conf = slurp_file "$tempdir/backupR/postgresql.auto.conf";
364364
rmtree("$tempdir/backupR");
365365

src/bin/pg_checksums/t/002_actions.pl

+94-72
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@
1414
# at the end.
1515
sub check_relation_corruption
1616
{
17-
my $node = shift;
18-
my $table = shift;
17+
my $node = shift;
18+
my $table = shift;
1919
my $tablespace = shift;
20-
my $pgdata = $node->data_dir;
20+
my $pgdata = $node->data_dir;
2121

22-
$node->safe_psql('postgres',
22+
$node->safe_psql(
23+
'postgres',
2324
"SELECT a INTO $table FROM generate_series(1,10000) AS a;
2425
ALTER TABLE $table SET (autovacuum_enabled=false);");
2526

2627
$node->safe_psql('postgres',
27-
"ALTER TABLE ".$table." SET TABLESPACE ".$tablespace.";");
28+
"ALTER TABLE " . $table . " SET TABLESPACE " . $tablespace . ";");
2829

29-
my $file_corrupted = $node->safe_psql('postgres',
30-
"SELECT pg_relation_filepath('$table');");
31-
my $relfilenode_corrupted = $node->safe_psql('postgres',
30+
my $file_corrupted =
31+
$node->safe_psql('postgres', "SELECT pg_relation_filepath('$table');");
32+
my $relfilenode_corrupted = $node->safe_psql('postgres',
3233
"SELECT relfilenode FROM pg_class WHERE relname = '$table';");
3334

3435
# Set page header and block size
@@ -38,9 +39,14 @@ sub check_relation_corruption
3839

3940
# Checksums are correct for single relfilenode as the table is not
4041
# corrupted yet.
41-
command_ok(['pg_checksums', '--check', '-D', $pgdata, '-r',
42-
$relfilenode_corrupted],
43-
"succeeds for single relfilenode on tablespace $tablespace with offline cluster");
42+
command_ok(
43+
[
44+
'pg_checksums', '--check',
45+
'-D', $pgdata,
46+
'-r', $relfilenode_corrupted
47+
],
48+
"succeeds for single relfilenode on tablespace $tablespace with offline cluster"
49+
);
4450

4551
# Time to create some corruption
4652
open my $file, '+<', "$pgdata/$file_corrupted";
@@ -49,26 +55,32 @@ sub check_relation_corruption
4955
close $file;
5056

5157
# Checksum checks on single relfilenode fail
52-
$node->command_checks_all([ 'pg_checksums', '--check', '-D', $pgdata,
53-
'-r', $relfilenode_corrupted],
54-
1,
55-
[qr/Bad checksums:.*1/],
56-
[qr/checksum verification failed/],
57-
"fails with corrupted data for single relfilenode on tablespace $tablespace");
58+
$node->command_checks_all(
59+
[
60+
'pg_checksums', '--check',
61+
'-D', $pgdata,
62+
'-r', $relfilenode_corrupted
63+
],
64+
1,
65+
[qr/Bad checksums:.*1/],
66+
[qr/checksum verification failed/],
67+
"fails with corrupted data for single relfilenode on tablespace $tablespace"
68+
);
5869

5970
# Global checksum checks fail as well
60-
$node->command_checks_all([ 'pg_checksums', '--check', '-D', $pgdata],
61-
1,
62-
[qr/Bad checksums:.*1/],
63-
[qr/checksum verification failed/],
64-
"fails with corrupted data on tablespace $tablespace");
71+
$node->command_checks_all(
72+
[ 'pg_checksums', '--check', '-D', $pgdata ],
73+
1,
74+
[qr/Bad checksums:.*1/],
75+
[qr/checksum verification failed/],
76+
"fails with corrupted data on tablespace $tablespace");
6577

6678
# Drop corrupted table again and make sure there is no more corruption.
6779
$node->start;
6880
$node->safe_psql('postgres', "DROP TABLE $table;");
6981
$node->stop;
70-
$node->command_ok(['pg_checksums', '--check', '-D', $pgdata],
71-
"succeeds again after table drop on tablespace $tablespace");
82+
$node->command_ok([ 'pg_checksums', '--check', '-D', $pgdata ],
83+
"succeeds again after table drop on tablespace $tablespace");
7284

7385
$node->start;
7486
return;
@@ -80,19 +92,20 @@ sub check_relation_corruption
8092
my $pgdata = $node->data_dir;
8193

8294
# Control file should know that checksums are disabled.
83-
command_like(['pg_controldata', $pgdata],
84-
qr/Data page checksum version:.*0/,
85-
'checksums disabled in control file');
95+
command_like(
96+
[ 'pg_controldata', $pgdata ],
97+
qr/Data page checksum version:.*0/,
98+
'checksums disabled in control file');
8699

87100
# These are correct but empty files, so they should pass through.
88-
append_to_file "$pgdata/global/99999", "";
89-
append_to_file "$pgdata/global/99999.123", "";
90-
append_to_file "$pgdata/global/99999_fsm", "";
91-
append_to_file "$pgdata/global/99999_init", "";
92-
append_to_file "$pgdata/global/99999_vm", "";
101+
append_to_file "$pgdata/global/99999", "";
102+
append_to_file "$pgdata/global/99999.123", "";
103+
append_to_file "$pgdata/global/99999_fsm", "";
104+
append_to_file "$pgdata/global/99999_init", "";
105+
append_to_file "$pgdata/global/99999_vm", "";
93106
append_to_file "$pgdata/global/99999_init.123", "";
94-
append_to_file "$pgdata/global/99999_fsm.123", "";
95-
append_to_file "$pgdata/global/99999_vm.123", "";
107+
append_to_file "$pgdata/global/99999_fsm.123", "";
108+
append_to_file "$pgdata/global/99999_vm.123", "";
96109

97110
# These are temporary files and folders with dummy contents, which
98111
# should be ignored by the scan.
@@ -101,67 +114,75 @@ sub check_relation_corruption
101114
append_to_file "$pgdata/global/pgsql_tmp/1.1", "foo";
102115

103116
# Enable checksums.
104-
command_ok(['pg_checksums', '--enable', '--no-sync', '-D', $pgdata],
105-
"checksums successfully enabled in cluster");
117+
command_ok([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ],
118+
"checksums successfully enabled in cluster");
106119

107120
# Successive attempt to enable checksums fails.
108-
command_fails(['pg_checksums', '--enable', '--no-sync', '-D', $pgdata],
109-
"enabling checksums fails if already enabled");
121+
command_fails([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ],
122+
"enabling checksums fails if already enabled");
110123

111124
# Control file should know that checksums are enabled.
112-
command_like(['pg_controldata', $pgdata],
113-
qr/Data page checksum version:.*1/,
114-
'checksums enabled in control file');
125+
command_like(
126+
[ 'pg_controldata', $pgdata ],
127+
qr/Data page checksum version:.*1/,
128+
'checksums enabled in control file');
115129

116130
# Disable checksums again. Flush result here as that should be cheap.
117-
command_ok(['pg_checksums', '--disable', '-D', $pgdata],
118-
"checksums successfully disabled in cluster");
131+
command_ok(
132+
[ 'pg_checksums', '--disable', '-D', $pgdata ],
133+
"checksums successfully disabled in cluster");
119134

120135
# Successive attempt to disable checksums fails.
121-
command_fails(['pg_checksums', '--disable', '--no-sync', '-D', $pgdata],
122-
"disabling checksums fails if already disabled");
136+
command_fails(
137+
[ 'pg_checksums', '--disable', '--no-sync', '-D', $pgdata ],
138+
"disabling checksums fails if already disabled");
123139

124140
# Control file should know that checksums are disabled.
125-
command_like(['pg_controldata', $pgdata],
126-
qr/Data page checksum version:.*0/,
127-
'checksums disabled in control file');
141+
command_like(
142+
[ 'pg_controldata', $pgdata ],
143+
qr/Data page checksum version:.*0/,
144+
'checksums disabled in control file');
128145

129146
# Enable checksums again for follow-up tests.
130-
command_ok(['pg_checksums', '--enable', '--no-sync', '-D', $pgdata],
131-
"checksums successfully enabled in cluster");
147+
command_ok([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ],
148+
"checksums successfully enabled in cluster");
132149

133150
# Control file should know that checksums are enabled.
134-
command_like(['pg_controldata', $pgdata],
135-
qr/Data page checksum version:.*1/,
136-
'checksums enabled in control file');
151+
command_like(
152+
[ 'pg_controldata', $pgdata ],
153+
qr/Data page checksum version:.*1/,
154+
'checksums enabled in control file');
137155

138156
# Checksums pass on a newly-created cluster
139-
command_ok(['pg_checksums', '--check', '-D', $pgdata],
140-
"succeeds with offline cluster");
157+
command_ok([ 'pg_checksums', '--check', '-D', $pgdata ],
158+
"succeeds with offline cluster");
141159

142160
# Checksums are verified if no other arguments are specified
143-
command_ok(['pg_checksums', '-D', $pgdata],
144-
"verifies checksums as default action");
161+
command_ok(
162+
[ 'pg_checksums', '-D', $pgdata ],
163+
"verifies checksums as default action");
145164

146165
# Specific relation files cannot be requested when action is --disable
147166
# or --enable.
148-
command_fails(['pg_checksums', '--disable', '-r', '1234', '-D', $pgdata],
149-
"fails when relfilenodes are requested and action is --disable");
150-
command_fails(['pg_checksums', '--enable', '-r', '1234', '-D', $pgdata],
151-
"fails when relfilenodes are requested and action is --enable");
167+
command_fails(
168+
[ 'pg_checksums', '--disable', '-r', '1234', '-D', $pgdata ],
169+
"fails when relfilenodes are requested and action is --disable");
170+
command_fails(
171+
[ 'pg_checksums', '--enable', '-r', '1234', '-D', $pgdata ],
172+
"fails when relfilenodes are requested and action is --enable");
152173

153174
# Checks cannot happen with an online cluster
154175
$node->start;
155-
command_fails(['pg_checksums', '--check', '-D', $pgdata],
156-
"fails with online cluster");
176+
command_fails([ 'pg_checksums', '--check', '-D', $pgdata ],
177+
"fails with online cluster");
157178

158179
# Check corruption of table on default tablespace.
159180
check_relation_corruption($node, 'corrupt1', 'pg_default');
160181

161182
# Create tablespace to check corruptions in a non-default tablespace.
162-
my $basedir = $node->basedir;
183+
my $basedir = $node->basedir;
163184
my $tablespace_dir = "$basedir/ts_corrupt_dir";
164-
mkdir ($tablespace_dir);
185+
mkdir($tablespace_dir);
165186
$tablespace_dir = TestLib::real_dir($tablespace_dir);
166187
$node->safe_psql('postgres',
167188
"CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';");
@@ -171,19 +192,20 @@ sub check_relation_corruption
171192
# correctly-named relation files filled with some corrupted data.
172193
sub fail_corrupt
173194
{
174-
my $node = shift;
175-
my $file = shift;
195+
my $node = shift;
196+
my $file = shift;
176197
my $pgdata = $node->data_dir;
177198

178199
# Create the file with some dummy data in it.
179200
my $file_name = "$pgdata/global/$file";
180201
append_to_file $file_name, "foo";
181202

182-
$node->command_checks_all([ 'pg_checksums', '--check', '-D', $pgdata],
183-
1,
184-
[qr/^$/],
185-
[qr/could not read block 0 in file.*$file\":/],
186-
"fails for corrupted data in $file");
203+
$node->command_checks_all(
204+
[ 'pg_checksums', '--check', '-D', $pgdata ],
205+
1,
206+
[qr/^$/],
207+
[qr/could not read block 0 in file.*$file\":/],
208+
"fails for corrupted data in $file");
187209

188210
# Remove file to prevent future lookup errors on conflicts.
189211
unlink $file_name;

src/bin/pg_ctl/t/001_start_stop.pl

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
print $conf "fsync = off\n";
2727
print $conf TestLib::slurp_file($ENV{TEMP_CONFIG})
2828
if defined $ENV{TEMP_CONFIG};
29+
2930
if (!$windows_os)
3031
{
3132
print $conf "listen_addresses = ''\n";

src/bin/pg_ctl/t/004_logrotate.pl

+13-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525

2626
note "current_logfiles = $current_logfiles";
2727

28-
like($current_logfiles, qr|^stderr log/postgresql-.*log$|,
29-
'current_logfiles is sane');
28+
like(
29+
$current_logfiles,
30+
qr|^stderr log/postgresql-.*log$|,
31+
'current_logfiles is sane');
3032

3133
my $lfname = $current_logfiles;
3234
$lfname =~ s/^stderr //;
@@ -43,8 +45,7 @@
4345
usleep(100_000);
4446
}
4547

46-
like($first_logfile, qr/division by zero/,
47-
'found expected log file content');
48+
like($first_logfile, qr/division by zero/, 'found expected log file content');
4849

4950
# Sleep 2 seconds and ask for log rotation; this should result in
5051
# output into a different log file name.
@@ -63,8 +64,10 @@
6364

6465
note "now current_logfiles = $new_current_logfiles";
6566

66-
like($new_current_logfiles, qr|^stderr log/postgresql-.*log$|,
67-
'new current_logfiles is sane');
67+
like(
68+
$new_current_logfiles,
69+
qr|^stderr log/postgresql-.*log$|,
70+
'new current_logfiles is sane');
6871

6972
$lfname = $new_current_logfiles;
7073
$lfname =~ s/^stderr //;
@@ -82,7 +85,9 @@
8285
usleep(100_000);
8386
}
8487

85-
like($second_logfile, qr/syntax error/,
86-
'found expected log file content in new log file');
88+
like(
89+
$second_logfile,
90+
qr/syntax error/,
91+
'found expected log file content in new log file');
8792

8893
$node->stop();

0 commit comments

Comments
 (0)