Commit 35361ee7 authored by Andrew Dunstan's avatar Andrew Dunstan

Restrict vertical tightness to parentheses in Perl code

The vertical tightness settings collapse vertical whitespace between
opening and closing brackets (parentheses, square brakets and braces).
This can make data structures in particular harder to read, and is not
very consistent with our style in non-Perl code. This patch restricts
that setting to parentheses only, and reformats all the perl code
accordingly. Not applying this to parentheses has some unfortunate
effects, so the consensus is to keep the setting for parentheses and not
for the others.

The diff for this patch does highlight some places where structures
should have trailing commas. They can be added manually, as there is no
automatic tool to do so.

Discussion: https://postgr.es/m/a2f2b87c-56be-c070-bfc0-36288b4b41c1@2ndQuadrant.com
parent 286bb240
......@@ -95,10 +95,12 @@ sub ParseHeader
elsif (/^DECLARE_(UNIQUE_)?INDEX\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
{
push @{ $catalog{indexing} },
{ is_unique => $1 ? 1 : 0,
{
is_unique => $1 ? 1 : 0,
index_name => $2,
index_oid => $3,
index_decl => $4 };
index_decl => $4
};
}
elsif (/^CATALOG\((\w+),(\d+),(\w+)\)/)
{
......
......@@ -97,11 +97,13 @@ foreach my $row (@{ $catalog_data{pg_proc} })
next if $bki_values{prolang} ne $INTERNALlanguageId;
push @fmgr,
{ oid => $bki_values{oid},
{
oid => $bki_values{oid},
strict => $bki_values{proisstrict},
retset => $bki_values{proretset},
nargs => $bki_values{pronargs},
prosrc => $bki_values{prosrc}, };
prosrc => $bki_values{prosrc},
};
}
# Emit headers for both files
......
......@@ -48,12 +48,14 @@ foreach my $i (@$cp950txt)
&& $code <= 0xf9dc)
{
push @$all,
{ code => $code,
{
code => $code,
ucs => $ucs,
comment => $i->{comment},
direction => BOTH,
f => $i->{f},
l => $i->{l} };
l => $i->{l}
};
}
}
......
......@@ -70,11 +70,13 @@ while (<$in>)
}
push @mapping,
{ ucs => $ucs,
{
ucs => $ucs,
code => $code,
direction => BOTH,
f => $in_file,
l => $. };
l => $.
};
}
close($in);
......
......@@ -33,13 +33,15 @@ while (my $line = <$in>)
my $ucs2 = hex($u2);
push @all,
{ direction => BOTH,
{
direction => BOTH,
ucs => $ucs1,
ucs_second => $ucs2,
code => $code,
comment => $rest,
f => $in_file,
l => $. };
l => $.
};
}
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
{
......@@ -52,12 +54,14 @@ while (my $line = <$in>)
next if ($code < 0x80 && $ucs < 0x80);
push @all,
{ direction => BOTH,
{
direction => BOTH,
ucs => $ucs,
code => $code,
comment => $rest,
f => $in_file,
l => $. };
l => $.
};
}
}
close($in);
......
......@@ -32,23 +32,29 @@ foreach my $i (@$mapping)
# Some extra characters that are not in KSX1001.TXT
push @$mapping,
( { direction => BOTH,
( {
direction => BOTH,
ucs => 0x20AC,
code => 0xa2e6,
comment => '# EURO SIGN',
f => $this_script,
l => __LINE__ },
{ direction => BOTH,
l => __LINE__
},
{
direction => BOTH,
ucs => 0x00AE,
code => 0xa2e7,
comment => '# REGISTERED SIGN',
f => $this_script,
l => __LINE__ },
{ direction => BOTH,
l => __LINE__
},
{
direction => BOTH,
ucs => 0x327E,
code => 0xa2e8,
comment => '# CIRCLED HANGUL IEUNG U',
f => $this_script,
l => __LINE__ });
l => __LINE__
});
print_conversion_tables($this_script, "EUC_KR", $mapping);
......@@ -53,12 +53,14 @@ foreach my $i (@$mapping)
if ($origcode >= 0x12121 && $origcode <= 0x20000)
{
push @extras,
{ ucs => $i->{ucs},
{
ucs => $i->{ucs},
code => ($i->{code} + 0x8ea10000),
rest => $i->{rest},
direction => TO_UNICODE,
f => $i->{f},
l => $i->{l} };
l => $i->{l}
};
}
}
......
......@@ -36,11 +36,13 @@ while (<$in>)
if ($code >= 0x80 && $ucs >= 0x0080)
{
push @mapping,
{ ucs => $ucs,
{
ucs => $ucs,
code => $code,
direction => BOTH,
f => $in_file,
l => $. };
l => $.
};
}
}
close($in);
......
......@@ -26,23 +26,29 @@ my $mapping = &read_source("JOHAB.TXT");
# Some extra characters that are not in JOHAB.TXT
push @$mapping,
( { direction => BOTH,
( {
direction => BOTH,
ucs => 0x20AC,
code => 0xd9e6,
comment => '# EURO SIGN',
f => $this_script,
l => __LINE__ },
{ direction => BOTH,
l => __LINE__
},
{
direction => BOTH,
ucs => 0x00AE,
code => 0xd9e7,
comment => '# REGISTERED SIGN',
f => $this_script,
l => __LINE__ },
{ direction => BOTH,
l => __LINE__
},
{
direction => BOTH,
ucs => 0x327E,
code => 0xd9e8,
comment => '# CIRCLED HANGUL IEUNG U',
f => $this_script,
l => __LINE__ });
l => __LINE__
});
print_conversion_tables($this_script, "JOHAB", $mapping);
......@@ -33,13 +33,15 @@ while (my $line = <$in>)
my $ucs2 = hex($u2);
push @mapping,
{ code => $code,
{
code => $code,
ucs => $ucs1,
ucs_second => $ucs2,
comment => $rest,
direction => BOTH,
f => $in_file,
l => $. };
l => $.
};
}
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
{
......@@ -68,12 +70,14 @@ while (my $line = <$in>)
}
push @mapping,
{ code => $code,
{
code => $code,
ucs => $ucs,
comment => $rest,
direction => $direction,
f => $in_file,
l => $. };
l => $.
};
}
}
close($in);
......
......@@ -36,53 +36,69 @@ foreach my $i (@$mapping)
# Add these UTF8->SJIS pairs to the table.
push @$mapping,
( { direction => FROM_UNICODE,
( {
direction => FROM_UNICODE,
ucs => 0x00a2,
code => 0x8191,
comment => '# CENT SIGN',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x00a3,
code => 0x8192,
comment => '# POUND SIGN',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x00a5,
code => 0x5c,
comment => '# YEN SIGN',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x00ac,
code => 0x81ca,
comment => '# NOT SIGN',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x2016,
code => 0x8161,
comment => '# DOUBLE VERTICAL LINE',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x203e,
code => 0x7e,
comment => '# OVERLINE',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x2212,
code => 0x817c,
comment => '# MINUS SIGN',
f => $this_script,
l => __LINE__ },
{ direction => FROM_UNICODE,
l => __LINE__
},
{
direction => FROM_UNICODE,
ucs => 0x301c,
code => 0x8160,
comment => '# WAVE DASH',
f => $this_script,
l => __LINE__ });
l => __LINE__
});
print_conversion_tables($this_script, "SJIS", $mapping);
......@@ -39,22 +39,26 @@ while (<$in>)
if ($code >= 0x80 && $ucs >= 0x0080)
{
push @mapping,
{ ucs => $ucs,
{
ucs => $ucs,
code => $code,
direction => BOTH,
f => $in_file,
l => $. };
l => $.
};
}
}
close($in);
# One extra character that's not in the source file.
push @mapping,
{ direction => BOTH,
{
direction => BOTH,
code => 0xa2e8,
ucs => 0x327e,
comment => 'CIRCLED HANGUL IEUNG U',
f => $this_script,
l => __LINE__ };
l => __LINE__
};
print_conversion_tables($this_script, "UHC", \@mapping);
......@@ -18,7 +18,8 @@ use constant {
NONE => 0,
TO_UNICODE => 1,
FROM_UNICODE => 2,
BOTH => 3 };
BOTH => 3
};
#######################################################################
# read_source - common routine to read source file
......@@ -56,7 +57,8 @@ sub read_source
comment => $4,
direction => BOTH,
f => $fname,
l => $. };
l => $.
};
# Ignore pure ASCII mappings. PostgreSQL character conversion code
# never even passes these to the conversion code.
......@@ -370,9 +372,11 @@ sub print_radix_table
}
unshift @segments,
{ header => "Dummy map, for invalid values",
{
header => "Dummy map, for invalid values",
min_idx => 0,
max_idx => $widest_range };
max_idx => $widest_range
};
###
### Eliminate overlapping zeros
......@@ -655,12 +659,14 @@ sub build_segments_recurse
if ($level == $depth)
{
push @segments,
{ header => $header . ", leaf: ${path}xx",
{
header => $header . ", leaf: ${path}xx",
label => $label,
level => $level,
depth => $depth,
path => $path,
values => $map };
values => $map
};
}
else
{
......@@ -678,12 +684,14 @@ sub build_segments_recurse
}
push @segments,
{ header => $header . ", byte #$level: ${path}xx",
{
header => $header . ", byte #$level: ${path}xx",
label => $label,
level => $level,
depth => $depth,
path => $path,
values => \%children };
values => \%children
};
}
return @segments;
}
......@@ -776,7 +784,8 @@ sub make_charmap_combined
code => $c->{code},
comment => $c->{comment},
f => $c->{f},
l => $c->{l} };
l => $c->{l}
};
push @combined, $entry;
}
}
......
......@@ -73,8 +73,10 @@ sub run_check
create_files();
command_ok(
[ 'pg_archivecleanup', '-x', '.gz', $tempdir,
$walfiles[2] . $suffix ],
[
'pg_archivecleanup', '-x', '.gz', $tempdir,
$walfiles[2] . $suffix
],
"$test_name: runs");
ok(!-f "$tempdir/$walfiles[0]",
......
......@@ -159,8 +159,10 @@ isnt(slurp_file("$tempdir/backup/backup_label"),
rmtree("$tempdir/backup");
$node->command_ok(
[ 'pg_basebackup', '-D', "$tempdir/backup2", '--waldir',
"$tempdir/xlog2" ],
[
'pg_basebackup', '-D', "$tempdir/backup2", '--waldir',
"$tempdir/xlog2"
],
'separate xlog directory');
ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created');
ok(-d "$tempdir/xlog2/", 'xlog directory was created');
......@@ -179,8 +181,10 @@ $node->command_fails(
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=" ],
'-T with empty new directory fails');
$node->command_fails(
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp',
"-T/foo=/bar=/baz" ],
[
'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp',
"-T/foo=/bar=/baz"
],
'-T with multiple = fails');
$node->command_fails(
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ],
......@@ -279,8 +283,10 @@ SKIP:
'plain format with tablespaces fails without tablespace mapping');
$node->command_ok(
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp',
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ],
[
'pg_basebackup', '-D', "$tempdir/backup1", '-Fp',
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1"
],
'plain format with tablespaces succeeds with tablespace mapping');
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
opendir(my $dh, "$pgdata/pg_tblspc") or die;
......@@ -330,8 +336,10 @@ SKIP:
$node->safe_psql('postgres',
"CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';");
$node->command_ok(
[ 'pg_basebackup', '-D', "$tempdir/backup3", '-Fp',
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ],
[
'pg_basebackup', '-D', "$tempdir/backup3", '-Fp',
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2"
],
'mapping tablespace with = sign in path');
ok(-d "$tempdir/tbackup/tbl=spc2",
'tablespace with = sign was relocated');
......@@ -389,17 +397,21 @@ $node->command_ok(
ok(-f "$tempdir/backupxst/pg_wal.tar", "tar file was created");
rmtree("$tempdir/backupxst");
$node->command_ok(
[ 'pg_basebackup', '-D',
[
'pg_basebackup', '-D',
"$tempdir/backupnoslot", '-X',
'stream', '--no-slot' ],
'stream', '--no-slot'
],
'pg_basebackup -X stream runs with --no-slot');
rmtree("$tempdir/backupnoslot");
$node->command_fails(
[ 'pg_basebackup', '-D',
[
'pg_basebackup', '-D',
"$tempdir/backupxs_sl_fail", '-X',
'stream', '-S',
'slot0' ],
'slot0'
],
'pg_basebackup fails with nonexistent replication slot');
$node->command_fails(
......@@ -407,10 +419,12 @@ $node->command_fails(
'pg_basebackup -C fails without slot name');
$node->command_fails(
[ 'pg_basebackup', '-D',
[
'pg_basebackup', '-D',
"$tempdir/backupxs_slot", '-C',
'-S', 'slot0',
'--no-slot' ],
'--no-slot'
],
'pg_basebackup fails with -C -S --no-slot');
$node->command_ok(
......@@ -446,8 +460,10 @@ $node->command_fails(
[ 'pg_basebackup', '-D', "$tempdir/fail", '-S', 'slot1', '-X', 'none' ],
'pg_basebackup with replication slot fails without WAL streaming');
$node->command_ok(
[ 'pg_basebackup', '-D', "$tempdir/backupxs_sl", '-X',
'stream', '-S', 'slot1' ],
[
'pg_basebackup', '-D', "$tempdir/backupxs_sl", '-X',
'stream', '-S', 'slot1'
],
'pg_basebackup -X stream with replication slot runs');
$lsn = $node->safe_psql('postgres',
q{SELECT restart_lsn FROM pg_replication_slots WHERE slot_name = 'slot1'}
......@@ -456,8 +472,10 @@ like($lsn, qr!^0/[0-9A-Z]{7,8}$!, 'restart LSN of slot has advanced');
rmtree("$tempdir/backupxs_sl");
$node->command_ok(
[ 'pg_basebackup', '-D', "$tempdir/backupxs_sl_R", '-X',
'stream', '-S', 'slot1', '-R' ],
[
'pg_basebackup', '-D', "$tempdir/backupxs_sl_R", '-X',
'stream', '-S', 'slot1', '-R'
],
'pg_basebackup with replication slot and -R runs');
like(
slurp_file("$tempdir/backupxs_sl_R/recovery.conf"),
......
......@@ -57,8 +57,10 @@ $primary->psql('postgres',
# Stream up to the given position.
$primary->command_ok(
[ 'pg_receivewal', '-D', $stream_dir, '--verbose',
'--endpos', $nextlsn, '--synchronous', '--no-loop' ],
[
'pg_receivewal', '-D', $stream_dir, '--verbose',
'--endpos', $nextlsn, '--synchronous', '--no-loop'
],
'streaming some WAL with --synchronous');
# Permissions on WAL files should be default
......
......@@ -29,15 +29,19 @@ $node->command_fails([ 'pg_recvlogical', '-S', 'test' ],
$node->command_fails([ 'pg_recvlogical', '-S', 'test', '-d', 'postgres' ],
'pg_recvlogical needs an action');
$node->command_fails(
[ 'pg_recvlogical', '-S',
[
'pg_recvlogical', '-S',
'test', '-d',
$node->connstr('postgres'), '--start' ],
$node->connstr('postgres'), '--start'
],
'no destination file');
$node->command_ok(
[ 'pg_recvlogical', '-S',
[
'pg_recvlogical', '-S',
'test', '-d',
$node->connstr('postgres'), '--create-slot' ],
$node->connstr('postgres'), '--create-slot'
],
'slot created');
my $slot = $node->slot('test');
......@@ -51,6 +55,8 @@ my $nextlsn =
chomp($nextlsn);
$node->command_ok(
[ 'pg_recvlogical', '-S', 'test', '-d', $node->connstr('postgres'),
'--start', '--endpos', "$nextlsn", '--no-loop', '-f', '-' ],
[
'pg_recvlogical', '-S', 'test', '-d', $node->connstr('postgres'),
'--start', '--endpos', "$nextlsn", '--no-loop', '-f', '-'
],
'replayed a transaction');
......@@ -33,7 +33,9 @@ close $fh;
command_checks_all(
[ 'pg_controldata', $node->data_dir ],
0,
[ qr/WARNING: Calculated CRC checksum does not match value stored in file/,
qr/WARNING: invalid WAL segment size/ ],
[
qr/WARNING: Calculated CRC checksum does not match value stored in file/,
qr/WARNING: invalid WAL segment size/
],
[qr/^$/],
'pg_controldata with corrupted pg_control');
......@@ -36,7 +36,8 @@ else
close $conf;
my $ctlcmd = [
'pg_ctl', 'start', '-D', "$tempdir/data", '-l',
"$TestLib::log_path/001_start_stop_server.log" ];
"$TestLib::log_path/001_start_stop_server.log"
];
if ($Config{osname} ne 'msys')
{
command_like($ctlcmd, qr/done.*server started/s, 'pg_ctl start');
......
This diff is collapsed.
......@@ -34,9 +34,11 @@ $node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]);
# prep pg_hba.conf and pg_ident.conf
$node->run_log(
[ $ENV{PG_REGRESS}, '--config-auth',
[
$ENV{PG_REGRESS}, '--config-auth',
$node->data_dir, '--create-role',
"$dbname1,$dbname2,$dbname3,$dbname4" ]);
"$dbname1,$dbname2,$dbname3,$dbname4"
]);
$node->start;
my $backupdir = $node->backup_dir;
......@@ -54,24 +56,32 @@ foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase')
# For these tests, pg_dumpall -r is used because it produces a short
# dump.
$node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
[
'pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname1),
'-U', $dbname4 ],
'-U', $dbname4
],
'pg_dumpall with long ASCII name 1');
$node->command_ok(
[ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
[
'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname2),
'-U', $dbname3 ],
'-U', $dbname3
],
'pg_dumpall with long ASCII name 2');
$node->command_ok(
[ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
[
'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname3),
'-U', $dbname2 ],
'-U', $dbname2
],
'pg_dumpall with long ASCII name 3');
$node->command_ok(
[ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
[
'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname4),
'-U', $dbname1 ],
'-U', $dbname1
],
'pg_dumpall with long ASCII name 4');
$node->command_ok(
[ 'pg_dumpall', '--no-sync', '-r', '-l', 'dbname=template1' ],
......@@ -91,8 +101,10 @@ $node->safe_psql($dbname1, 'CREATE TABLE t0()');
# XXX no printed message when this fails, just SIGPIPE termination
$node->command_ok(
[ 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt, '-U', $dbname1,
$node->connstr($dbname1) ],
[
'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt, '-U', $dbname1,
$node->connstr($dbname1)
],
'parallel dump');
# recreate $dbname1 for restore test
......@@ -106,9 +118,11 @@ $node->command_ok(
$node->run_log([ 'dropdb', $dbname1 ]);
$node->command_ok(
[ 'pg_restore', '-C', '-v', '-d',
[
'pg_restore', '-C', '-v', '-d',
'template1', '-j2', '-U', $dbname1,
$dirfmt ],
$dirfmt
],
'parallel restore with create');
......@@ -127,9 +141,11 @@ my $envar_node = get_new_node('destination_envar');
$envar_node->init(
extra => [ '-U', $bootstrap_super, '--locale=C', '--encoding=LATIN1' ]);
$envar_node->run_log(
[ $ENV{PG_REGRESS}, '--config-auth',
[
$ENV{PG_REGRESS}, '--config-auth',
$envar_node->data_dir, '--create-role',
"$bootstrap_super,$restore_super" ]);
"$bootstrap_super,$restore_super"
]);
$envar_node->start;
# make superuser for restore
......@@ -157,16 +173,20 @@ my $cmdline_node = get_new_node('destination_cmdline');
$cmdline_node->init(
extra => [ '-U', $bootstrap_super, '--locale=C', '--encoding=LATIN1' ]);
$cmdline_node->run_log(
[ $ENV{PG_REGRESS}, '--config-auth',
[
$ENV{PG_REGRESS}, '--config-auth',
$cmdline_node->data_dir, '--create-role',
"$bootstrap_super,$restore_super" ]);
"$bootstrap_super,$restore_super"
]);
$cmdline_node->start;
$cmdline_node->run_log(
[ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]);
{
$result = run_log(
[ 'psql', '-p', $cmdline_node->port, '-U',
$restore_super, '-X', '-f', $plain ],
[
'psql', '-p', $cmdline_node->port, '-U',
$restore_super, '-X', '-f', $plain
],
'2>',
\$stderr);
}
......
......@@ -31,7 +31,8 @@ command_checks_all(
[ 'pg_resetwal', '-n', $node->data_dir ],
0,
[qr/pg_control version number/],
[ qr/pg_resetwal: pg_control exists but is broken or wrong version; ignoring it/
[
qr/pg_resetwal: pg_control exists but is broken or wrong version; ignoring it/
],
'processes corrupted pg_control all zeroes');
......@@ -46,6 +47,7 @@ command_checks_all(
[ 'pg_resetwal', '-n', $node->data_dir ],
0,
[qr/pg_control version number/],
[ qr/\Qpg_resetwal: pg_control specifies invalid WAL segment size (0 bytes); proceed with caution\E/
[
qr/\Qpg_resetwal: pg_control specifies invalid WAL segment size (0 bytes); proceed with caution\E/
],
'processes zero WAL segment size');
......@@ -92,7 +92,8 @@ sub check_query
my $result = run [
'psql', '-q', '-A', '-t', '--no-psqlrc', '-d',
$node_master->connstr('postgres'),
'-c', $query ],
'-c', $query
],
'>', \$stdout, '2>', \$stderr;
# We don't use ok() for the exit code and stderr, because we want this
......@@ -214,10 +215,12 @@ sub run_pg_rewind
# Stop the master and be ready to perform the rewind
$node_standby->stop;
command_ok(
[ 'pg_rewind',
[
'pg_rewind',
"--debug",
"--source-pgdata=$standby_pgdata",
"--target-pgdata=$master_pgdata" ],
"--target-pgdata=$master_pgdata"
],
'pg_rewind local');
}
elsif ($test_mode eq "remote")
......@@ -225,9 +228,11 @@ sub run_pg_rewind
# Do rewind using a remote connection as source
command_ok(
[ 'pg_rewind', "--debug",
[
'pg_rewind', "--debug",
"--source-server", $standby_connstr,
"--target-pgdata=$master_pgdata" ],
"--target-pgdata=$master_pgdata"
],
'pg_rewind remote');
}
else
......
......@@ -66,7 +66,8 @@ sub run_test
@paths = sort @paths;
is_deeply(
\@paths,
[ "$test_master_datadir/tst_both_dir",
[
"$test_master_datadir/tst_both_dir",
"$test_master_datadir/tst_both_dir/both_file1",
"$test_master_datadir/tst_both_dir/both_file2",
"$test_master_datadir/tst_both_dir/both_subdir",
......
......@@ -57,81 +57,126 @@ sub pgbench_scripts
my @options = (
# name, options, stderr checks
[ 'bad option',
[
'bad option',
'-h home -p 5432 -U calvin -d --bad-option',
[ qr{(unrecognized|illegal) option}, qr{--help.*more information} ] ],
[ 'no file',
[ qr{(unrecognized|illegal) option}, qr{--help.*more information} ]
],
[
'no file',
'-f no-such-file',
[qr{could not open file "no-such-file":}] ],
[ 'no builtin',
[qr{could not open file "no-such-file":}]
],
[
'no builtin',
'-b no-such-builtin',
[qr{no builtin script .* "no-such-builtin"}] ],
[ 'invalid weight',
[qr{no builtin script .* "no-such-builtin"}]
],
[
'invalid weight',
'--builtin=select-only@one',
[qr{invalid weight specification: \@one}] ],
[ 'invalid weight',
[qr{invalid weight specification: \@one}]
],
[
'invalid weight',
'-b select-only@-1',
[qr{weight spec.* out of range .*: -1}] ],
[qr{weight spec.* out of range .*: -1}]
],
[ 'too many scripts', '-S ' x 129, [qr{at most 128 SQL scripts}] ],
[ 'bad #clients', '-c three', [qr{invalid number of clients: "three"}] ],
[ 'bad #threads', '-j eleven', [qr{invalid number of threads: "eleven"}]
[
'bad #threads', '-j eleven', [qr{invalid number of threads: "eleven"}]
],
[ 'bad scale', '-i -s two', [qr{invalid scaling factor: "two"}] ],
[ 'invalid #transactions',
[
'invalid #transactions',
'-t zil',
[qr{invalid number of transactions: "zil"}] ],
[qr{invalid number of transactions: "zil"}]
],
[ 'invalid duration', '-T ten', [qr{invalid duration: "ten"}] ],
[ '-t XOR -T',
[
'-t XOR -T',
'-N -l --aggregate-interval=5 --log-prefix=notused -t 1000 -T 1',
[qr{specify either }] ],
[ '-T XOR -t',
[qr{specify either }]
],
[
'-T XOR -t',
'-P 1 --progress-timestamp -l --sampling-rate=0.001 -T 10 -t 1000',
[qr{specify either }] ],
[qr{specify either }]
],
[ 'bad variable', '--define foobla', [qr{invalid variable definition}] ],
[ 'invalid fillfactor', '-F 1', [qr{invalid fillfactor}] ],
[ 'invalid query mode', '-M no-such-mode', [qr{invalid query mode}] ],
[ 'invalid progress', '--progress=0',
[qr{invalid thread progress delay}] ],
[
'invalid progress', '--progress=0',
[qr{invalid thread progress delay}]
],
[ 'invalid rate', '--rate=0.0', [qr{invalid rate limit}] ],
[ 'invalid latency', '--latency-limit=0.0', [qr{invalid latency limit}] ],
[ 'invalid sampling rate', '--sampling-rate=0',
[qr{invalid sampling rate}] ],
[ 'invalid aggregate interval', '--aggregate-interval=-3',
[qr{invalid .* seconds for}] ],
[ 'weight zero',
[
'invalid sampling rate', '--sampling-rate=0',
[qr{invalid sampling rate}]
],
[
'invalid aggregate interval', '--aggregate-interval=-3',
[qr{invalid .* seconds for}]
],
[
'weight zero',
'-b se@0 -b si@0 -b tpcb@0',
[qr{weight must not be zero}] ],
[qr{weight must not be zero}]
],
[ 'init vs run', '-i -S', [qr{cannot be used in initialization}] ],
[ 'run vs init', '-S -F 90', [qr{cannot be used in benchmarking}] ],
[ 'ambiguous builtin', '-b s', [qr{ambiguous}] ],
[ '--progress-timestamp => --progress', '--progress-timestamp',
[qr{allowed only under}] ],
[ '-I without init option',
[
'--progress-timestamp => --progress', '--progress-timestamp',
[qr{allowed only under}]
],
[
'-I without init option',
'-I dtg',
[qr{cannot be used in benchmarking mode}] ],
[ 'invalid init step',
[qr{cannot be used in benchmarking mode}]
],
[
'invalid init step',
'-i -I dta',
[ qr{unrecognized initialization step}, qr{allowed steps are} ] ],
[ 'bad random seed',
[ qr{unrecognized initialization step}, qr{allowed steps are} ]
],
[
'bad random seed',
'--random-seed=one',
[ qr{unrecognized random seed option "one": expecting an unsigned integer, "time" or "rand"},
qr{error while setting random seed from --random-seed option} ] ],
[
qr{unrecognized random seed option "one": expecting an unsigned integer, "time" or "rand"},
qr{error while setting random seed from --random-seed option}
]
],
# loging sub-options
[ 'sampling => log', '--sampling-rate=0.01',
[qr{log sampling .* only when}] ],
[ 'sampling XOR aggregate',
[
'sampling => log', '--sampling-rate=0.01',
[qr{log sampling .* only when}]
],
[
'sampling XOR aggregate',
'-l --sampling-rate=0.1 --aggregate-interval=3',
[qr{sampling .* aggregation .* cannot be used at the same time}] ],
[ 'aggregate => log', '--aggregate-interval=3',
[qr{aggregation .* only when}] ],
[qr{sampling .* aggregation .* cannot be used at the same time}]
],
[
'aggregate => log', '--aggregate-interval=3',
[qr{aggregation .* only when}]
],
[ 'log-prefix => log', '--log-prefix=x', [qr{prefix .* only when}] ],
[ 'duration & aggregation',
[
'duration & aggregation',
'-l -T 1 --aggregate-interval=3',
[qr{aggr.* not be higher}] ],
[ 'duration % aggregation',
[qr{aggr.* not be higher}]
],
[
'duration % aggregation',
'-l -T 5 --aggregate-interval=3',
[qr{multiple}] ],);
[qr{multiple}]
],);
for my $o (@options)
{
......@@ -143,11 +188,13 @@ for my $o (@options)
# Help
pgbench(
'--help', 0,
[ qr{benchmarking tool for PostgreSQL},
[
qr{benchmarking tool for PostgreSQL},
qr{Usage},
qr{Initialization options:},
qr{Common options:},
qr{Report bugs to} ],
qr{Report bugs to}
],
[qr{^$}],
'pgbench help');
......@@ -159,43 +206,65 @@ pgbench(
'-b list',
0,
[qr{^$}],
[ qr{Available builtin scripts:}, qr{tpcb-like},
qr{simple-update}, qr{select-only} ],
[
qr{Available builtin scripts:}, qr{tpcb-like},
qr{simple-update}, qr{select-only}
],
'pgbench builtin list');
my @script_tests = (
# name, err, { file => contents }
[ 'missing endif',
[
'missing endif',
[qr{\\if without matching \\endif}],
{ 'if-noendif.sql' => '\if 1' } ],
[ 'missing if on elif',
{ 'if-noendif.sql' => '\if 1' }
],
[
'missing if on elif',
[qr{\\elif without matching \\if}],
{ 'elif-noif.sql' => '\elif 1' } ],
[ 'missing if on else',
{ 'elif-noif.sql' => '\elif 1' }
],
[
'missing if on else',
[qr{\\else without matching \\if}],
{ 'else-noif.sql' => '\else' } ],
[ 'missing if on endif',
{ 'else-noif.sql' => '\else' }
],
[
'missing if on endif',
[qr{\\endif without matching \\if}],
{ 'endif-noif.sql' => '\endif' } ],
[ 'elif after else',
{ 'endif-noif.sql' => '\endif' }
],
[
'elif after else',
[qr{\\elif after \\else}],
{ 'else-elif.sql' => "\\if 1\n\\else\n\\elif 0\n\\endif" } ],
[ 'else after else',
{ 'else-elif.sql' => "\\if 1\n\\else\n\\elif 0\n\\endif" }
],
[
'else after else',
[qr{\\else after \\else}],
{ 'else-else.sql' => "\\if 1\n\\else\n\\else\n\\endif" } ],
[ 'if syntax error',
{ 'else-else.sql' => "\\if 1\n\\else\n\\else\n\\endif" }
],
[
'if syntax error',
[qr{syntax error in command "if"}],
{ 'if-bad.sql' => "\\if\n\\endif\n" } ],
[ 'elif syntax error',
{ 'if-bad.sql' => "\\if\n\\endif\n" }
],
[
'elif syntax error',
[qr{syntax error in command "elif"}],
{ 'elif-bad.sql' => "\\if 0\n\\elif +\n\\endif\n" } ],
[ 'else syntax error',
{ 'elif-bad.sql' => "\\if 0\n\\elif +\n\\endif\n" }
],
[
'else syntax error',
[qr{unexpected argument in command "else"}],
{ 'else-bad.sql' => "\\if 0\n\\else BAD\n\\endif\n" } ],
[ 'endif syntax error',
{ 'else-bad.sql' => "\\if 0\n\\else BAD\n\\endif\n" }
],
[
'endif syntax error',
[qr{unexpected argument in command "endif"}],
{ 'endif-bad.sql' => "\\if 0\n\\endif BAD\n" } ],);
{ 'endif-bad.sql' => "\\if 0\n\\endif BAD\n" }
],);
for my $t (@script_tests)
{
......
......@@ -149,7 +149,8 @@ foreach my $file (sort readdir DIR)
cmddesc => $cmddesc,
cmdsynopsis => $cmdsynopsis,
params => \@params,
nl_count => $nl_count };
nl_count => $nl_count
};
$maxlen =
($maxlen >= length $cmdname) ? $maxlen : length $cmdname;
}
......
......@@ -161,7 +161,8 @@ sub test_access
'SELECT 1',
extra_params => [
'-d', $node->connstr('postgres') . ' host=localhost',
'-U', $role ]);
'-U', $role
]);
is($res, $expected_res, $test_name);
}
......
This diff is collapsed.
......@@ -155,7 +155,8 @@ sub new
_host => $pghost,
_basedir => "$TestLib::tmp_check/t_${testname}_${name}_data",
_name => $name,
_logfile => "$TestLib::log_path/${testname}_${name}.log" };
_logfile => "$TestLib::log_path/${testname}_${name}.log"
};
bless $self, $class;
mkdir $self->{_basedir}
......
......@@ -256,7 +256,8 @@ sub check_mode_recursive
my $result = 1;
find(
{ follow_fast => 1,
{
follow_fast => 1,
wanted => sub {
my $file_stat = stat($File::Find::name);
......@@ -322,7 +323,8 @@ sub chmod_recursive
my ($dir, $dir_mode, $file_mode) = @_;
find(
{ follow_fast => 1,
{
follow_fast => 1,
wanted => sub {
my $file_stat = stat($File::Find::name);
......
......@@ -112,8 +112,10 @@ SKIP:
skip "Test fails on Windows perl", 2 if $Config{osname} eq 'MSWin32';
my $pg_recvlogical = IPC::Run::start(
[ 'pg_recvlogical', '-d', $node_master->connstr('otherdb'),
'-S', 'otherdb_slot', '-f', '-', '--start' ]);
[
'pg_recvlogical', '-d', $node_master->connstr('otherdb'),
'-S', 'otherdb_slot', '-f', '-', '--start'
]);
$node_master->poll_query_until('otherdb',
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'otherdb_slot' AND active_pid IS NOT NULL)"
) or die "slot never became active";
......
......@@ -29,8 +29,10 @@ my ($stdin, $stdout, $stderr) = ('', '', '');
# an xact to be in-progress when we crash and we need to know
# its xid.
my $tx = IPC::Run::start(
[ 'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d',
$node->connstr('postgres') ],
[
'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d',
$node->connstr('postgres')
],
'<',
\$stdin,
'>',
......
......@@ -39,8 +39,10 @@ $node->safe_psql(
# Run psql, keeping session alive, so we have an alive backend to kill.
my ($killme_stdin, $killme_stdout, $killme_stderr) = ('', '', '');
my $killme = IPC::Run::start(
[ 'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d',
$node->connstr('postgres') ],
[
'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d',
$node->connstr('postgres')
],
'<',
\$killme_stdin,
'>',
......@@ -52,8 +54,10 @@ my $killme = IPC::Run::start(
# Need a second psql to check if crash-restart happened.
my ($monitor_stdin, $monitor_stdout, $monitor_stderr) = ('', '', '');
my $monitor = IPC::Run::start(
[ 'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d',
$node->connstr('postgres') ],
[
'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d',
$node->connstr('postgres')
],
'<',
\$monitor_stdin,
'>',
......
......@@ -43,7 +43,8 @@ sub test_connect_ok
my $cmd = [
'psql', '-X', '-A', '-t', '-c',
"SELECT \$\$connected with $connstr\$\$",
'-d', "$common_connstr $connstr" ];
'-d', "$common_connstr $connstr"
];
command_ok($cmd, $test_name);
}
......@@ -55,7 +56,8 @@ sub test_connect_fails
my $cmd = [
'psql', '-X', '-A', '-t', '-c',
"SELECT \$\$connected with $connstr\$\$",
'-d', "$common_connstr $connstr" ];
'-d', "$common_connstr $connstr"
];
command_fails_like($cmd, $expected_stderr, $test_name);
}
......
......@@ -317,7 +317,8 @@ sub push_commit
'message' => $c->{'message'},
'commit' => $c->{'commit'},
'commits' => [],
'timestamp' => $ts };
'timestamp' => $ts
};
push @{ $all_commits{$ht} }, $cc;
}
......@@ -326,7 +327,8 @@ sub push_commit
'branch' => $c->{'branch'},
'commit' => $c->{'commit'},
'date' => $c->{'date'},
'last_tag' => $c->{'last_tag'} };
'last_tag' => $c->{'last_tag'}
};
push @{ $cc->{'commits'} }, $smallc;
push @{ $all_commits_by_branch{ $c->{'branch'} } }, $cc;
$cc->{'branch_position'}{ $c->{'branch'} } =
......
......@@ -95,7 +95,8 @@ sub Install
my @top_dir = ("src");
@top_dir = ("src\\bin", "src\\interfaces") if ($insttype eq "client");
File::Find::find(
{ wanted => sub {
{
wanted => sub {
/^.*\.sample\z/s
&& push(@$sample_files, $File::Find::name);
......@@ -155,7 +156,8 @@ sub Install
push @pldirs, "src/pl/plpython" if $config->{python};
push @pldirs, "src/pl/tcl" if $config->{tcl};
File::Find::find(
{ wanted => sub {
{
wanted => sub {
/^(.*--.*\.sql|.*\.control)\z/s
&& push(@$pl_extension_files, $File::Find::name);
......@@ -686,7 +688,8 @@ sub GenerateNLSFiles
EnsureDirectories($target, "share/locale");
my @flist;
File::Find::find(
{ wanted => sub {
{
wanted => sub {
/^nls\.mk\z/s
&& !push(@flist, $File::Find::name);
}
......
......@@ -65,17 +65,21 @@ EOF
$self->WriteItemDefinitionGroup(
$f, 'Debug',
{ defs => "_DEBUG;DEBUG=1",
{
defs => "_DEBUG;DEBUG=1",
opt => 'Disabled',
strpool => 'false',
runtime => 'MultiThreadedDebugDLL' });
runtime => 'MultiThreadedDebugDLL'
});
$self->WriteItemDefinitionGroup(
$f,
'Release',
{ defs => "",
{
defs => "",
opt => 'Full',
strpool => 'true',
runtime => 'MultiThreadedDLL' });
runtime => 'MultiThreadedDLL'
});
}
sub AddDefine
......
......@@ -39,7 +39,8 @@ my $contrib_extralibs = undef;
my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
my $contrib_extrasource = {
'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ], };
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
};
my @contrib_excludes = (
'commit_ts', 'hstore_plperl',
'hstore_plpython', 'intagg',
......@@ -64,14 +65,17 @@ my $frontend_extralibs = {
'initdb' => ['ws2_32.lib'],
'pg_restore' => ['ws2_32.lib'],
'pgbench' => ['ws2_32.lib'],
'psql' => ['ws2_32.lib'] };
'psql' => ['ws2_32.lib']
};
my $frontend_extraincludes = {
'initdb' => ['src/timezone'],
'psql' => ['src/backend'] };
'psql' => ['src/backend']
};
my $frontend_extrasource = {
'psql' => ['src/bin/psql/psqlscanslash.l'],
'pgbench' =>
[ 'src/bin/pgbench/exprscan.l', 'src/bin/pgbench/exprparse.y' ] };
[ 'src/bin/pgbench/exprscan.l', 'src/bin/pgbench/exprparse.y' ]
};
my @frontend_excludes = (
'pgevent', 'pg_basebackup', 'pg_rewind', 'pg_dump',
'pg_waldump', 'scripts');
......
......@@ -16,7 +16,8 @@ sub _new
my $good_types = {
lib => 1,
exe => 1,
dll => 1, };
dll => 1,
};
confess("Bad project type: $type\n") unless exists $good_types->{$type};
my $self = {
name => $name,
......@@ -32,7 +33,8 @@ sub _new
solution => $solution,
disablewarnings => '4018;4244;4273;4102;4090;4267',
disablelinkerwarnings => '',
platform => $solution->{platform}, };
platform => $solution->{platform},
};
bless($self, $classname);
return $self;
......
......@@ -22,7 +22,8 @@ sub _new
VisualStudioVersion => undef,
MinimumVisualStudioVersion => undef,
vcver => undef,
platform => undef, };
platform => undef,
};
bless($self, $classname);
$self->DeterminePlatform();
......
......@@ -35,19 +35,23 @@ EOF
$self->WriteConfiguration(
$f, 'Debug',
{ defs => "_DEBUG;DEBUG=1",
{
defs => "_DEBUG;DEBUG=1",
wholeopt => 0,
opt => 0,
strpool => 'false',
runtime => 3 });
runtime => 3
});
$self->WriteConfiguration(
$f,
'Release',
{ defs => "",
{
defs => "",
wholeopt => 0,
opt => 3,
strpool => 'true',
runtime => 2 });
runtime => 2
});
print $f <<EOF;
</Configurations>
EOF
......
......@@ -11,5 +11,5 @@
--opening-brace-on-new-line
--output-line-ending=unix
--paren-tightness=2
--vertical-tightness=2
--vertical-tightness-closing=2
--paren-vertical-tightness=2
--paren-vertical-tightness-closing=2
......@@ -389,7 +389,8 @@ sub build_clean
# get the list of files under code base, if it's set
File::Find::find(
{ wanted => sub {
{
wanted => sub {
my ($dev, $ino, $mode, $nlink, $uid, $gid);
(($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_))
&& -f _
......
......@@ -47,9 +47,11 @@ foreach my $keyname (@subkeys)
die "Incomplete timezone data for $keyname!\n"
unless ($vals{Std} && $vals{Dlt} && $vals{Display});
push @system_zones,
{ 'std' => $vals{Std}->[2],
{
'std' => $vals{Std}->[2],
'dlt' => $vals{Dlt}->[2],
'display' => clean_displayname($vals{Display}->[2]), };
'display' => clean_displayname($vals{Display}->[2]),
};
}
$basekey->Close();
......@@ -75,10 +77,12 @@ while ($pgtz =~
m/{\s+"([^"]+)",\s+"([^"]+)",\s+"([^"]+)",?\s+},\s+\/\*(.+?)\*\//gs)
{
push @file_zones,
{ 'std' => $1,
{
'std' => $1,
'dlt' => $2,
'match' => $3,
'display' => clean_displayname($4), };
'display' => clean_displayname($4),
};
}
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment