Commit f04d4ac9 authored by Tom Lane's avatar Tom Lane

Reindent Perl files with perltidy version 20170521.

Discussion: https://postgr.es/m/CABUevEzK3cNiHZQ18f5tK0guoT+cN_jWeVzhYYxY=r+1Q3SmoA@mail.gmail.com
parent 46cda5bf
......@@ -185,6 +185,7 @@ sub ParseHeader
{
$column{forcenotnull} = 1;
}
# We use quotes for values like \0 and \054, to
# make sure all compilers and syntax highlighters
# can recognize them properly.
......@@ -199,7 +200,7 @@ sub ParseHeader
else
{
die
"unknown column option $attopt on column $attname";
"unknown column option $attopt on column $attname";
}
if ($column{forcenull} and $column{forcenotnull})
......@@ -311,8 +312,9 @@ sub AddDefaultValues
{
$row->{$attname} = $column->{default};
}
elsif ($catname eq 'pg_proc' && $attname eq 'pronargs' &&
defined($row->{proargtypes}))
elsif ($catname eq 'pg_proc'
&& $attname eq 'pronargs'
&& defined($row->{proargtypes}))
{
# pg_proc.pronargs can be derived from proargtypes.
my @proargtypes = split /\s+/, $row->{proargtypes};
......@@ -379,7 +381,7 @@ sub FindDefinedSymbol
sub FindDefinedSymbolFromData
{
my ($data, $symbol) = @_;
foreach my $row (@{ $data })
foreach my $row (@{$data})
{
if ($row->{oid_symbol} eq $symbol)
{
......
......@@ -116,10 +116,12 @@ foreach my $header (@input_files)
# within a given Postgres release, such as fixed OIDs. Do not substitute
# anything that could depend on platform or configuration. (The right place
# to handle those sorts of things is in initdb.c's bootstrap_template1().)
my $BOOTSTRAP_SUPERUSERID = Catalog::FindDefinedSymbolFromData(
$catalog_data{pg_authid}, 'BOOTSTRAP_SUPERUSERID');
my $PG_CATALOG_NAMESPACE = Catalog::FindDefinedSymbolFromData(
$catalog_data{pg_namespace}, 'PG_CATALOG_NAMESPACE');
my $BOOTSTRAP_SUPERUSERID =
Catalog::FindDefinedSymbolFromData($catalog_data{pg_authid},
'BOOTSTRAP_SUPERUSERID');
my $PG_CATALOG_NAMESPACE =
Catalog::FindDefinedSymbolFromData($catalog_data{pg_namespace},
'PG_CATALOG_NAMESPACE');
# Build lookup tables for OID macro substitutions and for pg_attribute
......@@ -138,8 +140,7 @@ foreach my $row (@{ $catalog_data{pg_opclass} })
{
# There is no unique name, so we need to combine access method
# and opclass name.
my $key = sprintf "%s/%s",
$row->{opcmethod}, $row->{opcname};
my $key = sprintf "%s/%s", $row->{opcmethod}, $row->{opcname};
$opcoids{$key} = $row->{oid};
}
......@@ -160,8 +161,7 @@ foreach my $row (@{ $catalog_data{pg_opfamily} })
{
# There is no unique name, so we need to combine access method
# and opfamily name.
my $key = sprintf "%s/%s",
$row->{opfmethod}, $row->{opfname};
my $key = sprintf "%s/%s", $row->{opfmethod}, $row->{opfname};
$opfoids{$key} = $row->{oid};
}
......@@ -179,6 +179,7 @@ foreach my $row (@{ $catalog_data{pg_proc} })
{
$procoids{$prokey} = $row->{oid};
}
# Also generate an entry using proname(proargtypes). This is not quite
# identical to regprocedure lookup because we don't worry much about
# special SQL names for types etc; we just use the names in the source
......@@ -211,8 +212,7 @@ my %lookup_kind = (
pg_operator => \%operoids,
pg_opfamily => \%opfoids,
pg_proc => \%procoids,
pg_type => \%typeoids
);
pg_type => \%typeoids);
# Generate postgres.bki, postgres.description, postgres.shdescription,
......@@ -345,7 +345,10 @@ EOM
# Complain about unrecognized keys; they are presumably misspelled
foreach my $key (keys %bki_values)
{
next if $key eq "oid" || $key eq "oid_symbol" || $key eq "descr"
next
if $key eq "oid"
|| $key eq "oid_symbol"
|| $key eq "descr"
|| $key eq "line_number";
die sprintf "unrecognized field name \"%s\" in %s.dat line %s\n",
$key, $catname, $bki_values{line_number}
......@@ -379,8 +382,8 @@ EOM
if ($atttype eq 'oidvector')
{
@lookupnames = split /\s+/, $bki_values{$attname};
@lookupoids = lookup_oids($lookup, $catname,
\%bki_values, @lookupnames);
@lookupoids = lookup_oids($lookup, $catname, \%bki_values,
@lookupnames);
$bki_values{$attname} = join(' ', @lookupoids);
}
elsif ($atttype eq '_oid')
......@@ -389,17 +392,18 @@ EOM
{
$bki_values{$attname} =~ s/[{}]//g;
@lookupnames = split /,/, $bki_values{$attname};
@lookupoids = lookup_oids($lookup, $catname,
\%bki_values, @lookupnames);
$bki_values{$attname} =
sprintf "{%s}", join(',', @lookupoids);
@lookupoids =
lookup_oids($lookup, $catname, \%bki_values,
@lookupnames);
$bki_values{$attname} = sprintf "{%s}",
join(',', @lookupoids);
}
}
else
{
$lookupnames[0] = $bki_values{$attname};
@lookupoids = lookup_oids($lookup, $catname,
\%bki_values, @lookupnames);
@lookupoids = lookup_oids($lookup, $catname, \%bki_values,
@lookupnames);
$bki_values{$attname} = $lookupoids[0];
}
}
......@@ -756,7 +760,8 @@ sub lookup_oids
else
{
push @lookupoids, $lookupname;
warn sprintf "unresolved OID reference \"%s\" in %s.dat line %s\n",
warn sprintf
"unresolved OID reference \"%s\" in %s.dat line %s\n",
$lookupname, $catname, $bki_values->{line_number}
if $lookupname ne '-' and $lookupname ne '0';
}
......
......@@ -68,7 +68,7 @@ foreach my $datfile (@input_files)
my $header = "$1.h";
die "There in no header file corresponding to $datfile"
if ! -e $header;
if !-e $header;
my $catalog = Catalog::ParseHeader($header);
my $catname = $catalog->{catname};
......@@ -79,10 +79,12 @@ foreach my $datfile (@input_files)
}
# Fetch some values for later.
my $FirstBootstrapObjectId = Catalog::FindDefinedSymbol(
'access/transam.h', \@include_path, 'FirstBootstrapObjectId');
my $INTERNALlanguageId = Catalog::FindDefinedSymbolFromData(
$catalog_data{pg_language}, 'INTERNALlanguageId');
my $FirstBootstrapObjectId =
Catalog::FindDefinedSymbol('access/transam.h', \@include_path,
'FirstBootstrapObjectId');
my $INTERNALlanguageId =
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
'INTERNALlanguageId');
print "Generating fmgrtab.c, fmgroids.h, and fmgrprotos.h...\n";
......@@ -230,7 +232,7 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
print $tfh
" { $s->{oid}, \"$s->{prosrc}\", $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, $s->{prosrc} }";
$fmgr_builtin_oid_index[$s->{oid}] = $fmgr_count++;
$fmgr_builtin_oid_index[ $s->{oid} ] = $fmgr_count++;
if ($fmgr_count <= $#fmgr)
{
......
......@@ -51,7 +51,8 @@ mkdir $datadir;
# Permissions on PGDATA should be default
SKIP:
{
skip "unix-style permissions not supported on Windows", 1 if ($windows_os);
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
ok(check_mode_recursive($datadir, 0700, 0600),
"check PGDATA permissions");
......@@ -63,7 +64,8 @@ command_fails([ 'initdb', $datadir ], 'existing data directory');
# Check group access on PGDATA
SKIP:
{
skip "unix-style permissions not supported on Windows", 2 if ($windows_os);
skip "unix-style permissions not supported on Windows", 2
if ($windows_os);
# Init a new db with group access
my $datadir_group = "$tempdir/data_group";
......
......@@ -10,11 +10,8 @@ program_options_handling_ok('pg_archivecleanup');
my $tempdir = TestLib::tempdir;
my @walfiles = (
'00000001000000370000000C.gz',
'00000001000000370000000D',
'00000001000000370000000E',
'00000001000000370000000F.partial',
);
'00000001000000370000000C.gz', '00000001000000370000000D',
'00000001000000370000000E', '00000001000000370000000F.partial',);
sub create_files
{
......@@ -28,32 +25,41 @@ sub create_files
create_files();
command_fails_like(['pg_archivecleanup'],
command_fails_like(
['pg_archivecleanup'],
qr/must specify archive location/,
'fails if archive location is not specified');
command_fails_like(['pg_archivecleanup', $tempdir],
command_fails_like(
[ 'pg_archivecleanup', $tempdir ],
qr/must specify oldest kept WAL file/,
'fails if oldest kept WAL file name is not specified');
command_fails_like(['pg_archivecleanup', 'notexist', 'foo'],
command_fails_like(
[ 'pg_archivecleanup', 'notexist', 'foo' ],
qr/archive location .* does not exist/,
'fails if archive location does not exist');
command_fails_like(['pg_archivecleanup', $tempdir, 'foo', 'bar'],
command_fails_like(
[ 'pg_archivecleanup', $tempdir, 'foo', 'bar' ],
qr/too many command-line arguments/,
'fails with too many command-line arguments');
command_fails_like(['pg_archivecleanup', $tempdir, 'foo'],
command_fails_like(
[ 'pg_archivecleanup', $tempdir, 'foo' ],
qr/invalid file name argument/,
'fails with invalid restart file name');
{
# like command_like but checking stderr
my $stderr;
my $result = IPC::Run::run ['pg_archivecleanup', '-d', '-n', $tempdir, $walfiles[2]], '2>', \$stderr;
my $result = IPC::Run::run [ 'pg_archivecleanup', '-d', '-n', $tempdir,
$walfiles[2] ], '2>', \$stderr;
ok($result, "pg_archivecleanup dry run: exit code 0");
like($stderr, qr/$walfiles[1].*would be removed/, "pg_archivecleanup dry run: matches");
like(
$stderr,
qr/$walfiles[1].*would be removed/,
"pg_archivecleanup dry run: matches");
foreach my $fn (@walfiles)
{
ok(-f "$tempdir/$fn", "$fn not removed");
......@@ -66,14 +72,21 @@ sub run_check
create_files();
command_ok(['pg_archivecleanup', '-x', '.gz', $tempdir, $walfiles[2] . $suffix],
command_ok(
[ 'pg_archivecleanup', '-x', '.gz', $tempdir,
$walfiles[2] . $suffix ],
"$test_name: runs");
ok(! -f "$tempdir/$walfiles[0]", "$test_name: first older WAL file was cleaned up");
ok(! -f "$tempdir/$walfiles[1]", "$test_name: second older WAL file was cleaned up");
ok(-f "$tempdir/$walfiles[2]", "$test_name: restartfile was not cleaned up");
ok(-f "$tempdir/$walfiles[3]", "$test_name: newer WAL file was not cleaned up");
ok(-f "$tempdir/unrelated_file", "$test_name: unrelated file was not cleaned up");
ok(!-f "$tempdir/$walfiles[0]",
"$test_name: first older WAL file was cleaned up");
ok(!-f "$tempdir/$walfiles[1]",
"$test_name: second older WAL file was cleaned up");
ok(-f "$tempdir/$walfiles[2]",
"$test_name: restartfile was not cleaned up");
ok(-f "$tempdir/$walfiles[3]",
"$test_name: newer WAL file was not cleaned up");
ok(-f "$tempdir/unrelated_file",
"$test_name: unrelated file was not cleaned up");
}
run_check('', 'pg_archivecleanup');
......
......@@ -20,7 +20,7 @@ my $node = get_new_node('main');
umask(0077);
# Initialize node without replication settings
$node->init(extra => [ '--data-checksums' ]);
$node->init(extra => ['--data-checksums']);
$node->start;
my $pgdata = $node->data_dir;
......@@ -92,7 +92,8 @@ ok(-f "$pgdata/$baseUnloggedPath", 'unlogged main fork in base');
my $postgresOid = $node->safe_psql('postgres',
q{select oid from pg_database where datname = 'postgres'});
my @tempRelationFiles = qw(t999_999 t9999_999.1 t999_9999_vm t99999_99999_vm.1);
my @tempRelationFiles =
qw(t999_999 t9999_999.1 t999_9999_vm t99999_99999_vm.1);
foreach my $filename (@tempRelationFiles)
{
......@@ -107,7 +108,8 @@ ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
# Permissions on backup should be default
SKIP:
{
skip "unix-style permissions not supported on Windows", 1 if ($windows_os);
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
ok(check_mode_recursive("$tempdir/backup", 0700, 0600),
"check backup dir permissions");
......@@ -133,8 +135,7 @@ foreach my $dirname (
# These files should not be copied.
foreach my $filename (
qw(postgresql.auto.conf.tmp postmaster.opts postmaster.pid tablespace_map current_logfiles.tmp
global/pg_internal.init)
)
global/pg_internal.init))
{
ok(!-f "$tempdir/backup/$filename", "$filename not copied");
}
......@@ -142,13 +143,13 @@ foreach my $filename (
# Unlogged relation forks other than init should not be copied
ok(-f "$tempdir/backup/${baseUnloggedPath}_init",
'unlogged init fork in backup');
ok(!-f "$tempdir/backup/$baseUnloggedPath",
ok( !-f "$tempdir/backup/$baseUnloggedPath",
'unlogged main fork not in backup');
# Temp relations should not be copied.
foreach my $filename (@tempRelationFiles)
{
ok(!-f "$tempdir/backup/base/$postgresOid/$filename",
ok( !-f "$tempdir/backup/base/$postgresOid/$filename",
"base/$postgresOid/$filename not copied");
}
......@@ -246,22 +247,25 @@ SKIP:
# Create an unlogged table to test that forks other than init are not copied.
$node->safe_psql('postgres',
'CREATE UNLOGGED TABLE tblspc1_unlogged (id int) TABLESPACE tblspc1;');
'CREATE UNLOGGED TABLE tblspc1_unlogged (id int) TABLESPACE tblspc1;'
);
my $tblspc1UnloggedPath = $node->safe_psql(
'postgres', q{select pg_relation_filepath('tblspc1_unlogged')});
my $tblspc1UnloggedPath = $node->safe_psql('postgres',
q{select pg_relation_filepath('tblspc1_unlogged')});
# Make sure main and init forks exist
ok(-f "$pgdata/${tblspc1UnloggedPath}_init",
ok( -f "$pgdata/${tblspc1UnloggedPath}_init",
'unlogged init fork in tablespace');
ok(-f "$pgdata/$tblspc1UnloggedPath",
'unlogged main fork in tablespace');
ok(-f "$pgdata/$tblspc1UnloggedPath", 'unlogged main fork in tablespace');
# Create files that look like temporary relations to ensure they are ignored
# in a tablespace.
my @tempRelationFiles = qw(t888_888 t888888_888888_vm.1);
my $tblSpc1Id = basename(dirname(dirname($node->safe_psql('postgres',
q{select pg_relation_filepath('test1')}))));
my $tblSpc1Id = basename(
dirname(
dirname(
$node->safe_psql(
'postgres', q{select pg_relation_filepath('test1')}))));
foreach my $filename (@tempRelationFiles)
{
......@@ -293,7 +297,8 @@ SKIP:
"check backup dir permissions");
# Unlogged relation forks other than init should not be copied
my ($tblspc1UnloggedBackupPath) = $tblspc1UnloggedPath =~ /[^\/]*\/[^\/]*\/[^\/]*$/g;
my ($tblspc1UnloggedBackupPath) =
$tblspc1UnloggedPath =~ /[^\/]*\/[^\/]*\/[^\/]*$/g;
ok(-f "$tempdir/tbackup/tblspc1/${tblspc1UnloggedBackupPath}_init",
'unlogged init fork in tablespace backup');
......@@ -303,7 +308,7 @@ SKIP:
# Temp relations should not be copied.
foreach my $filename (@tempRelationFiles)
{
ok(!-f "$tempdir/tbackup/tblspc1/$tblSpc1Id/$postgresOid/$filename",
ok( !-f "$tempdir/tbackup/tblspc1/$tblSpc1Id/$postgresOid/$filename",
"[tblspc1]/$postgresOid/$filename not copied");
# Also remove temp relation files or tablespace drop will fail.
......@@ -402,7 +407,10 @@ $node->command_fails(
'pg_basebackup -C fails without slot name');
$node->command_fails(
[ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0', '--no-slot' ],
[ 'pg_basebackup', '-D',
"$tempdir/backupxs_slot", '-C',
'-S', 'slot0',
'--no-slot' ],
'pg_basebackup fails with -C -S --no-slot');
$node->command_ok(
......@@ -410,10 +418,15 @@ $node->command_ok(
'pg_basebackup -C runs');
rmtree("$tempdir/backupxs_slot");
is($node->safe_psql('postgres', q{SELECT slot_name FROM pg_replication_slots WHERE slot_name = 'slot0'}),
is( $node->safe_psql(
'postgres',
q{SELECT slot_name FROM pg_replication_slots WHERE slot_name = 'slot0'}),
'slot0',
'replication slot was created');
isnt($node->safe_psql('postgres', q{SELECT restart_lsn FROM pg_replication_slots WHERE slot_name = 'slot0'}),
isnt(
$node->safe_psql(
'postgres',
q{SELECT restart_lsn FROM pg_replication_slots WHERE slot_name = 'slot0'}),
'',
'restart LSN of new slot is not null');
......@@ -455,10 +468,10 @@ rmtree("$tempdir/backupxs_sl_R");
# create tables to corrupt and get their relfilenodes
my $file_corrupt1 = $node->safe_psql('postgres',
q{SELECT a INTO corrupt1 FROM generate_series(1,10000) AS a; ALTER TABLE corrupt1 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt1')}
q{SELECT a INTO corrupt1 FROM generate_series(1,10000) AS a; ALTER TABLE corrupt1 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt1')}
);
my $file_corrupt2 = $node->safe_psql('postgres',
q{SELECT b INTO corrupt2 FROM generate_series(1,2) AS b; ALTER TABLE corrupt2 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt2')}
q{SELECT b INTO corrupt2 FROM generate_series(1,2) AS b; ALTER TABLE corrupt2 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt2')}
);
# set page header and block sizes
......@@ -473,18 +486,19 @@ syswrite($file, '\0\0\0\0\0\0\0\0\0');
close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
$node->command_checks_all([ 'pg_basebackup', '-D', "$tempdir/backup_corrupt"],
$node->command_checks_all(
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt" ],
1,
[qr{^$}],
[qr/^WARNING.*checksum verification failed/s],
'pg_basebackup reports checksum mismatch'
);
'pg_basebackup reports checksum mismatch');
rmtree("$tempdir/backup_corrupt");
# induce further corruption in 5 more blocks
system_or_bail 'pg_ctl', '-D', $pgdata, 'stop';
open $file, '+<', "$pgdata/$file_corrupt1";
for my $i ( 1..5 ) {
for my $i (1 .. 5)
{
my $offset = $pageheader_size + $i * $block_size;
seek($file, $offset, 0);
syswrite($file, '\0\0\0\0\0\0\0\0\0');
......@@ -492,12 +506,12 @@ for my $i ( 1..5 ) {
close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
$node->command_checks_all([ 'pg_basebackup', '-D', "$tempdir/backup_corrupt2"],
$node->command_checks_all(
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt2" ],
1,
[qr{^$}],
[qr/^WARNING.*further.*failures.*will.not.be.reported/s],
'pg_basebackup does not report more than 5 checksum mismatches'
);
'pg_basebackup does not report more than 5 checksum mismatches');
rmtree("$tempdir/backup_corrupt2");
# induce corruption in a second file
......@@ -508,12 +522,12 @@ syswrite($file, '\0\0\0\0\0\0\0\0\0');
close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
$node->command_checks_all([ 'pg_basebackup', '-D', "$tempdir/backup_corrupt3"],
$node->command_checks_all(
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt3" ],
1,
[qr{^$}],
[qr/^WARNING.*7 total checksum verification failures/s],
'pg_basebackup correctly report the total number of checksum mismatches'
);
'pg_basebackup correctly report the total number of checksum mismatches');
rmtree("$tempdir/backup_corrupt3");
# do not verify checksums, should return ok
......
......@@ -41,7 +41,8 @@ is($slot->{'slot_type'}, 'physical', 'physical replication slot was created');
is($slot->{'restart_lsn'}, '', 'restart LSN of new slot is null');
$primary->command_ok([ 'pg_receivewal', '--slot', $slot_name, '--drop-slot' ],
'dropping a replication slot');
is($primary->slot($slot_name)->{'slot_type'}, '', 'replication slot was removed');
is($primary->slot($slot_name)->{'slot_type'},
'', 'replication slot was removed');
# Generate some WAL. Use --synchronous at the same time to add more
# code coverage. Switch to the next segment first so that subsequent
......@@ -63,7 +64,8 @@ $primary->command_ok(
# Permissions on WAL files should be default
SKIP:
{
skip "unix-style permissions not supported on Windows", 1 if ($windows_os);
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
ok(check_mode_recursive($stream_dir, 0700, 0600),
"check stream dir permissions");
......
......@@ -25,13 +25,16 @@ my $size = (stat($pg_control))[7];
open my $fh, '>', $pg_control or BAIL_OUT($!);
binmode $fh;
# fill file with zeros
print $fh pack("x[$size]");
close $fh;
command_checks_all([ 'pg_controldata', $node->data_dir ],
command_checks_all(
[ 'pg_controldata', $node->data_dir ],
0,
[ qr/WARNING: Calculated CRC checksum does not match value stored in file/,
[
qr/WARNING: Calculated CRC checksum does not match value stored in file/,
qr/WARNING: invalid WAL segment size/ ],
[ qr/^$/ ],
[qr/^$/],
'pg_controldata with corrupted pg_control');
......@@ -63,14 +63,14 @@ command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ],
# Windows but we still want to do the restart test.
my $logFileName = "$tempdir/data/perm-test-600.log";
command_ok(
[ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-l', $logFileName ],
command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-l', $logFileName ],
'pg_ctl restart with server not running');
# Permissions on log file should be default
SKIP:
{
skip "unix-style permissions not supported on Windows", 2 if ($windows_os);
skip "unix-style permissions not supported on Windows", 2
if ($windows_os);
ok(-f $logFileName);
ok(check_mode_recursive("$tempdir/data", 0700, 0600));
......
This diff is collapsed.
......@@ -13,14 +13,14 @@ my $node = get_new_node('main');
$node->init;
command_like([ 'pg_resetwal', '-n', $node->data_dir ],
qr/checkpoint/,
'pg_resetwal -n produces output');
qr/checkpoint/, 'pg_resetwal -n produces output');
# Permissions on PGDATA should be default
SKIP:
{
skip "unix-style permissions not supported on Windows", 1 if ($windows_os);
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
ok(check_mode_recursive($node->data_dir, 0700, 0600),
'check PGDATA permissions');
......
......@@ -27,10 +27,13 @@ binmode $fh;
print $fh pack("x[$size]");
close $fh;
command_checks_all([ 'pg_resetwal', '-n', $node->data_dir ],
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_control version number/],
[
qr/pg_resetwal: pg_control exists but is broken or wrong version; ignoring it/
],
'processes corrupted pg_control all zeroes');
# Put in the previously saved header data. This uses a different code
......@@ -40,8 +43,11 @@ binmode $fh;
print $fh $data, pack("x[" . ($size - 16) . "]");
close $fh;
command_checks_all([ 'pg_resetwal', '-n', $node->data_dir ],
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/pg_control version number/],
[
qr/\Qpg_resetwal: pg_control specifies invalid WAL segment size (0 bytes); proceed with caution\E/
],
'processes zero WAL segment size');
......@@ -119,12 +119,14 @@ sub setup_cluster
my $extra = shift; # Extra params for initdb
# Initialize master, data checksums are mandatory
$node_master = get_new_node('master' . ($extra_name ? "_${extra_name}" : ''));
$node_master->init(
allows_streaming => 1, extra => $extra);
$node_master =
get_new_node('master' . ($extra_name ? "_${extra_name}" : ''));
$node_master->init(allows_streaming => 1, extra => $extra);
# Set wal_keep_segments to prevent WAL segment recycling after enforced
# checkpoints in the tests.
$node_master->append_conf('postgresql.conf', qq(
$node_master->append_conf(
'postgresql.conf', qq(
wal_keep_segments = 20
));
}
......@@ -141,7 +143,8 @@ sub create_standby
{
my $extra_name = shift;
$node_standby = get_new_node('standby' . ($extra_name ? "_${extra_name}" : ''));
$node_standby =
get_new_node('standby' . ($extra_name ? "_${extra_name}" : ''));
$node_master->backup('my_backup');
$node_standby->init_from_backup($node_master, 'my_backup');
my $connstr_master = $node_master->connstr();
......@@ -239,7 +242,8 @@ sub run_pg_rewind
"$tmp_folder/master-postgresql.conf.tmp",
"$master_pgdata/postgresql.conf");
chmod($node_master->group_access() ? 0640 : 0600,
chmod(
$node_master->group_access() ? 0640 : 0600,
"$master_pgdata/postgresql.conf")
or BAIL_OUT(
"unable to set permissions for $master_pgdata/postgresql.conf");
......
......@@ -89,7 +89,8 @@ in master, before promotion
# Permissions on PGDATA should be default
SKIP:
{
skip "unix-style permissions not supported on Windows", 1 if ($windows_os);
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
ok(check_mode_recursive($node_master->data_dir(), 0700, 0600),
'check PGDATA permissions');
......
......@@ -45,7 +45,8 @@ template1
# Permissions on PGDATA should have group permissions
SKIP:
{
skip "unix-style permissions not supported on Windows", 1 if ($windows_os);
skip "unix-style permissions not supported on Windows", 1
if ($windows_os);
ok(check_mode_recursive($node_master->data_dir(), 0750, 0640),
'check PGDATA permissions');
......
......@@ -81,8 +81,10 @@ pgbench(
# Initialize pgbench tables scale 1
pgbench(
'-i', 0, [qr{^$}],
[ qr{creating tables}, qr{vacuuming}, qr{creating primary keys}, qr{done\.} ],
'-i', 0,
[qr{^$}],
[ qr{creating tables}, qr{vacuuming},
qr{creating primary keys}, qr{done\.} ],
'pgbench scale 1 initialization',);
# Again, with all possible options
......@@ -100,8 +102,9 @@ pgbench(
# Test interaction of --init-steps with legacy step-selection options
pgbench(
'--initialize --init-steps=dtpvgvv --no-vacuum --foreign-keys --unlogged-tables',
0, [qr{^$}],
'--initialize --init-steps=dtpvgvv --no-vacuum --foreign-keys --unlogged-tables',
0,
[qr{^$}],
[ qr{dropping old tables},
qr{creating tables},
qr{creating primary keys},
......@@ -218,10 +221,11 @@ COMMIT;
# test expressions
# command 1..3 and 23 depend on random seed which is used to call srandom.
pgbench(
'--random-seed=5432 -t 1 -Dfoo=-10.1 -Dbla=false -Di=+3 -Dminint=-9223372036854775808 -Dn=null -Dt=t -Df=of -Dd=1.0',
'--random-seed=5432 -t 1 -Dfoo=-10.1 -Dbla=false -Di=+3 -Dminint=-9223372036854775808 -Dn=null -Dt=t -Df=of -Dd=1.0',
0,
[ qr{type: .*/001_pgbench_expressions}, qr{processed: 1/1} ],
[ qr{setting random seed to 5432\b},
# After explicit seeding, the four * random checks (1-3,20) should be
# deterministic, but not necessarily portable.
qr{command=1.: int 1\d\b}, # uniform random: 12 on linux
......@@ -411,13 +415,15 @@ SELECT :v0, :v1, :v2, :v3;
# random determinism when seeded
$node->safe_psql('postgres',
'CREATE UNLOGGED TABLE seeded_random(seed INT8 NOT NULL, rand TEXT NOT NULL, val INTEGER NOT NULL);');
'CREATE UNLOGGED TABLE seeded_random(seed INT8 NOT NULL, rand TEXT NOT NULL, val INTEGER NOT NULL);'
);
# same value to check for determinism
my $seed = int(rand(1000000000));
for my $i (1, 2)
{
pgbench("--random-seed=$seed -t 1",
pgbench(
"--random-seed=$seed -t 1",
0,
[qr{processed: 1/1}],
[qr{setting random seed to $seed\b}],
......@@ -436,16 +442,20 @@ INSERT INTO seeded_random(seed, rand, val) VALUES
}
# check that all runs generated the same 4 values
my ($ret, $out, $err) =
$node->psql('postgres',
'SELECT seed, rand, val, COUNT(*) FROM seeded_random GROUP BY seed, rand, val');
my ($ret, $out, $err) = $node->psql('postgres',
'SELECT seed, rand, val, COUNT(*) FROM seeded_random GROUP BY seed, rand, val'
);
ok($ret == 0, "psql seeded_random count ok");
ok($err eq '', "psql seeded_random count stderr is empty");
ok($out =~ /\b$seed\|uniform\|1\d\d\d\|2/, "psql seeded_random count uniform");
ok($out =~ /\b$seed\|exponential\|2\d\d\d\|2/, "psql seeded_random count exponential");
ok($out =~ /\b$seed\|gaussian\|3\d\d\d\|2/, "psql seeded_random count gaussian");
ok($out =~ /\b$seed\|zipfian\|4\d\d\d\|2/, "psql seeded_random count zipfian");
ok($out =~ /\b$seed\|uniform\|1\d\d\d\|2/,
"psql seeded_random count uniform");
ok( $out =~ /\b$seed\|exponential\|2\d\d\d\|2/,
"psql seeded_random count exponential");
ok( $out =~ /\b$seed\|gaussian\|3\d\d\d\|2/,
"psql seeded_random count gaussian");
ok($out =~ /\b$seed\|zipfian\|4\d\d\d\|2/,
"psql seeded_random count zipfian");
$node->safe_psql('postgres', 'DROP TABLE seeded_random;');
......@@ -481,8 +491,8 @@ my @errors = (
# SQL
[ 'sql syntax error',
0,
[ qr{ERROR: syntax error}, qr{prepared statement .* does not exist}
],
[ qr{ERROR: syntax error},
qr{prepared statement .* does not exist} ],
q{-- SQL syntax error
SELECT 1 + ;
} ],
......@@ -567,42 +577,24 @@ SELECT LEAST(:i, :i, :i, :i, :i, :i, :i, :i, :i, :i, :i);
q{\set i random_zipfian(0, 10, 1000000)} ],
[ 'set non numeric value', 0,
[qr{malformed variable "foo" value: "bla"}], q{\set i :foo + 1} ],
[ 'set no expression',
1,
[qr{syntax error}],
q{\set i} ],
[ 'set missing argument',
1,
[qr{missing argument}i],
q{\set} ],
[ 'set not a bool',
0,
[ qr{cannot coerce double to boolean} ],
q{\set b NOT 0.0} ],
[ 'set not an int',
0,
[ qr{cannot coerce boolean to int} ],
q{\set i TRUE + 2} ],
[ 'set not a double',
0,
[ qr{cannot coerce boolean to double} ],
q{\set d ln(TRUE)} ],
[ 'set no expression', 1, [qr{syntax error}], q{\set i} ],
[ 'set missing argument', 1, [qr{missing argument}i], q{\set} ],
[ 'set not a bool', 0,
[qr{cannot coerce double to boolean}], q{\set b NOT 0.0} ],
[ 'set not an int', 0,
[qr{cannot coerce boolean to int}], q{\set i TRUE + 2} ],
[ 'set not a double', 0,
[qr{cannot coerce boolean to double}], q{\set d ln(TRUE)} ],
[ 'set case error',
1,
[ qr{syntax error in command "set"} ],
[qr{syntax error in command "set"}],
q{\set i CASE TRUE THEN 1 ELSE 0 END} ],
[ 'set random error',
0,
[ qr{cannot coerce boolean to int} ],
q{\set b random(FALSE, TRUE)} ],
[ 'set number of args mismatch',
1,
[ qr{unexpected number of arguments} ],
q{\set d ln(1.0, 2.0))} ],
[ 'set at least one arg',
1,
[ qr{at least one argument expected} ],
q{\set i greatest())} ],
[ 'set random error', 0,
[qr{cannot coerce boolean to int}], q{\set b random(FALSE, TRUE)} ],
[ 'set number of args mismatch', 1,
[qr{unexpected number of arguments}], q{\set d ln(1.0, 2.0))} ],
[ 'set at least one arg', 1,
[qr{at least one argument expected}], q{\set i greatest())} ],
# SETSHELL
[ 'setshell not an int', 0,
......@@ -625,8 +617,8 @@ SELECT LEAST(:i, :i, :i, :i, :i, :i, :i, :i, :i, :i, :i);
[ 'misc invalid backslash command', 1,
[qr{invalid command .* "nosuchcommand"}], q{\nosuchcommand} ],
[ 'misc empty script', 1, [qr{empty command list for script}], q{} ],
[ 'bad boolean', 0, [qr{malformed variable.*trueXXX}], q{\set b :badtrue or true} ],
);
[ 'bad boolean', 0,
[qr{malformed variable.*trueXXX}], q{\set b :badtrue or true} ],);
for my $e (@errors)
......@@ -635,7 +627,7 @@ for my $e (@errors)
my $n = '001_pgbench_error_' . $name;
$n =~ s/ /_/g;
pgbench(
'-n -t 1 -Dfoo=bla -Dnull=null -Dtrue=true -Done=1 -Dzero=0.0 -Dbadtrue=trueXXX -M prepared',
'-n -t 1 -Dfoo=bla -Dnull=null -Dtrue=true -Done=1 -Dzero=0.0 -Dbadtrue=trueXXX -M prepared',
$status,
[ $status ? qr{^$} : qr{processed: 0/1} ],
$re,
......@@ -647,7 +639,7 @@ for my $e (@errors)
pgbench(
'-t 1', 0,
[ qr{processed: 1/1}, qr{zipfian cache array overflowed 1 time\(s\)} ],
[ qr{^} ],
[qr{^}],
'pgbench zipfian array overflow on random_zipfian',
{ '001_pgbench_random_zipfian' => q{
\set i random_zipfian(1, 100, 0.5)
......
......@@ -15,8 +15,7 @@ $testname =~ s/\.pl$//;
my $testdir = "$TestLib::tmp_check/t_${testname}_stuff";
mkdir $testdir
or
BAIL_OUT("could not create test directory \"${testdir}\": $!");
or BAIL_OUT("could not create test directory \"${testdir}\": $!");
# invoke pgbench
sub pgbench
......@@ -38,8 +37,10 @@ sub pgbench_scripts
for my $fn (sort keys %$files)
{
my $filename = $testdir . '/' . $fn;
# cleanup file weight if any
$filename =~ s/\@\d+$//;
# cleanup from prior runs
unlink $filename;
append_to_file($filename, $$files{$fn});
......@@ -105,13 +106,16 @@ my @options = (
[ 'ambiguous builtin', '-b s', [qr{ambiguous}] ],
[ '--progress-timestamp => --progress', '--progress-timestamp',
[qr{allowed only under}] ],
[ '-I without init option', '-I dtg',
[ '-I without init option',
'-I dtg',
[qr{cannot be used in benchmarking mode}] ],
[ 'invalid init step', '-i -I dta',
[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"},
[ 'invalid init step',
'-i -I dta',
[ 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} ] ],
# loging sub-options
......@@ -161,23 +165,44 @@ pgbench(
'pgbench builtin list');
my @script_tests = (
# name, err, { file => contents }
[ 'missing endif', [qr{\\if without matching \\endif}], {'if-noendif.sql' => '\if 1'} ],
[ 'missing if on elif', [qr{\\elif without matching \\if}], {'elif-noif.sql' => '\elif 1'} ],
[ 'missing if on else', [qr{\\else without matching \\if}], {'else-noif.sql' => '\else'} ],
[ 'missing if on endif', [qr{\\endif without matching \\if}], {'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', [qr{\\else after \\else}], {'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', [qr{syntax error in command "elif"}], {'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', [qr{unexpected argument in command "endif"}], {'endif-bad.sql' => "\\if 0\n\\endif BAD\n"} ],
);
[ 'missing endif',
[qr{\\if without matching \\endif}],
{ 'if-noendif.sql' => '\if 1' } ],
[ 'missing if on elif',
[qr{\\elif without matching \\if}],
{ 'elif-noif.sql' => '\elif 1' } ],
[ 'missing if on else',
[qr{\\else without matching \\if}],
{ 'else-noif.sql' => '\else' } ],
[ 'missing if on endif',
[qr{\\endif without matching \\if}],
{ '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',
[qr{\\else after \\else}],
{ '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',
[qr{syntax error in command "elif"}],
{ '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',
[qr{unexpected argument in command "endif"}],
{ 'endif-bad.sql' => "\\if 0\n\\endif BAD\n" } ],);
for my $t (@script_tests)
{
my ($name, $err, $files) = @$t;
pgbench_scripts('', 1, [qr{^$}], $err, 'pgbench option error: ' . $name, $files);
pgbench_scripts('', 1, [qr{^$}], $err, 'pgbench option error: ' . $name,
$files);
}
done_testing();
......@@ -16,4 +16,5 @@ $node->init;
$node->start;
# use a long timeout for the benefit of very slow buildfarm machines
$node->command_ok([qw(pg_isready --timeout=60)], 'succeeds with server running');
$node->command_ok([qw(pg_isready --timeout=60)],
'succeeds with server running');
......@@ -36,13 +36,17 @@ $node->issues_sql_like(
$node->command_ok([qw(vacuumdb -Z --table=pg_am dbname=template1)],
'vacuumdb with connection string');
$node->command_fails([qw(vacuumdb -Zt pg_am;ABORT postgres)],
$node->command_fails(
[qw(vacuumdb -Zt pg_am;ABORT postgres)],
'trailing command in "-t", without COLUMNS');
# Unwanted; better if it failed.
$node->command_ok([qw(vacuumdb -Zt pg_am(amname);ABORT postgres)],
$node->command_ok(
[qw(vacuumdb -Zt pg_am(amname);ABORT postgres)],
'trailing command in "-t", with COLUMNS');
$node->safe_psql('postgres', q|
$node->safe_psql(
'postgres', q|
CREATE TABLE "need""q(uot" (")x" text);
CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
......@@ -53,5 +57,6 @@ $node->safe_psql('postgres', q|
|);
$node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|],
'column list');
$node->command_fails([qw|vacuumdb -Zt funcidx postgres|],
$node->command_fails(
[qw|vacuumdb -Zt funcidx postgres|],
'unqualifed name via functional index');
......@@ -73,7 +73,7 @@ foreach my $datfile (@input_files)
my $header = "$1.h";
die "There in no header file corresponding to $datfile"
if ! -e $header;
if !-e $header;
my $catalog = Catalog::ParseHeader($header);
my $catname = $catalog->{catname};
......@@ -186,7 +186,7 @@ sub strip_default_values
{
my $attname = $column->{name};
die "strip_default_values: $catname.$attname undefined\n"
if ! defined $row->{$attname};
if !defined $row->{$attname};
# Delete values that match defaults.
if (defined $column->{default}
......@@ -196,8 +196,9 @@ sub strip_default_values
}
# Also delete pg_proc.pronargs, since that can be recomputed.
if ($catname eq 'pg_proc' && $attname eq 'pronargs' &&
defined($row->{proargtypes}))
if ( $catname eq 'pg_proc'
&& $attname eq 'pronargs'
&& defined($row->{proargtypes}))
{
delete $row->{$attname};
}
......
......@@ -62,13 +62,16 @@ my $keytab = "${TestLib::tmp_check}/krb5.keytab";
note "setting up Kerberos";
my ($stdout, $krb5_version);
run_log [ $krb5_config, '--version' ], '>', \$stdout or BAIL_OUT("could not execute krb5-config");
run_log [ $krb5_config, '--version' ], '>', \$stdout
or BAIL_OUT("could not execute krb5-config");
BAIL_OUT("Heimdal is not supported") if $stdout =~ m/heimdal/;
$stdout =~ m/Kerberos 5 release ([0-9]+\.[0-9]+)/ or BAIL_OUT("could not get Kerberos version");
$stdout =~ m/Kerberos 5 release ([0-9]+\.[0-9]+)/
or BAIL_OUT("could not get Kerberos version");
$krb5_version = $1;
append_to_file($krb5_conf,
qq![logging]
append_to_file(
$krb5_conf,
qq![logging]
default = FILE:$krb5_log
kdc = FILE:$kdc_log
......@@ -80,27 +83,32 @@ $realm = {
kdc = localhost:$kdc_port
}!);
append_to_file($kdc_conf,
qq![kdcdefaults]
append_to_file(
$kdc_conf,
qq![kdcdefaults]
!);
# For new-enough versions of krb5, use the _listen settings rather
# than the _ports settings so that we can bind to localhost only.
if ($krb5_version >= 1.15)
{
append_to_file($kdc_conf,
qq!kdc_listen = localhost:$kdc_port
append_to_file(
$kdc_conf,
qq!kdc_listen = localhost:$kdc_port
kdc_tcp_listen = localhost:$kdc_port
!);
}
else
{
append_to_file($kdc_conf,
qq!kdc_ports = $kdc_port
append_to_file(
$kdc_conf,
qq!kdc_ports = $kdc_port
kdc_tcp_ports = $kdc_port
!);
}
append_to_file($kdc_conf,
qq!
append_to_file(
$kdc_conf,
qq!
[realms]
$realm = {
database_name = $kdc_datadir/principal
......@@ -148,8 +156,11 @@ sub test_access
my ($node, $role, $expected_res, $test_name) = @_;
# need to connect over TCP/IP for Kerberos
my $res = $node->psql('postgres', 'SELECT 1',
extra_params => [ '-d', $node->connstr('postgres').' host=localhost',
my $res = $node->psql(
'postgres',
'SELECT 1',
extra_params => [
'-d', $node->connstr('postgres') . ' host=localhost',
'-U', $role ]);
is($res, $expected_res, $test_name);
}
......@@ -171,7 +182,8 @@ test_access($node, 'test1', 0, 'succeeds with mapping');
truncate($node->data_dir . '/pg_ident.conf', 0);
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{host all all localhost gss include_realm=0});
$node->append_conf('pg_hba.conf',
qq{host all all localhost gss include_realm=0});
$node->restart;
test_access($node, 'test1', 0, 'succeeds with include_realm=0');
......@@ -59,8 +59,9 @@ my $ldap_pwfile = "${TestLib::tmp_check}/ldappassword";
note "setting up slapd";
append_to_file($slapd_conf,
qq{include $ldap_schema_dir/core.schema
append_to_file(
$slapd_conf,
qq{include $ldap_schema_dir/core.schema
include $ldap_schema_dir/cosine.schema
include $ldap_schema_dir/nis.schema
include $ldap_schema_dir/inetorgperson.schema
......@@ -84,16 +85,23 @@ rootdn "$ldap_rootdn"
rootpw $ldap_rootpw});
# don't bother to check the server's cert (though perhaps we should)
append_to_file($ldap_conf,
qq{TLS_REQCERT never
append_to_file(
$ldap_conf,
qq{TLS_REQCERT never
});
mkdir $ldap_datadir or die;
mkdir $slapd_certs or die;
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout", "$slapd_certs/ca.key", "-x509", "-out", "$slapd_certs/ca.crt", "-subj", "/cn=CA";
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout", "$slapd_certs/server.key", "-out", "$slapd_certs/server.csr", "-subj", "/cn=server";
system_or_bail "openssl", "x509", "-req", "-in", "$slapd_certs/server.csr", "-CA", "$slapd_certs/ca.crt", "-CAkey", "$slapd_certs/ca.key", "-CAcreateserial", "-out", "$slapd_certs/server.crt";
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout",
"$slapd_certs/ca.key", "-x509", "-out", "$slapd_certs/ca.crt", "-subj",
"/cn=CA";
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout",
"$slapd_certs/server.key", "-out", "$slapd_certs/server.csr", "-subj",
"/cn=server";
system_or_bail "openssl", "x509", "-req", "-in", "$slapd_certs/server.csr",
"-CA", "$slapd_certs/ca.crt", "-CAkey", "$slapd_certs/ca.key",
"-CAcreateserial", "-out", "$slapd_certs/server.crt";
system_or_bail $slapd, '-f', $slapd_conf, '-h', "$ldap_url $ldaps_url";
......@@ -112,8 +120,10 @@ $ENV{'LDAPCONF'} = $ldap_conf;
note "loading LDAP data";
system_or_bail 'ldapadd', '-x', '-y', $ldap_pwfile, '-f', 'authdata.ldif';
system_or_bail 'ldappasswd', '-x', '-y', $ldap_pwfile, '-s', 'secret1', 'uid=test1,dc=example,dc=net';
system_or_bail 'ldappasswd', '-x', '-y', $ldap_pwfile, '-s', 'secret2', 'uid=test2,dc=example,dc=net';
system_or_bail 'ldappasswd', '-x', '-y', $ldap_pwfile, '-s', 'secret1',
'uid=test1,dc=example,dc=net';
system_or_bail 'ldappasswd', '-x', '-y', $ldap_pwfile, '-s', 'secret2',
'uid=test2,dc=example,dc=net';
note "setting up PostgreSQL instance";
......@@ -131,50 +141,66 @@ sub test_access
{
my ($node, $role, $expected_res, $test_name) = @_;
my $res = $node->psql('postgres', 'SELECT 1', extra_params => [ '-U', $role ]);
my $res =
$node->psql('postgres', 'SELECT 1', extra_params => [ '-U', $role ]);
is($res, $expected_res, $test_name);
}
note "simple bind";
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="uid=" ldapsuffix=",dc=example,dc=net"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="uid=" ldapsuffix=",dc=example,dc=net"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'wrong';
test_access($node, 'test0', 2, 'simple bind authentication fails if user not found in LDAP');
test_access($node, 'test1', 2, 'simple bind authentication fails with wrong password');
test_access($node, 'test0', 2,
'simple bind authentication fails if user not found in LDAP');
test_access($node, 'test1', 2,
'simple bind authentication fails with wrong password');
$ENV{"PGPASSWORD"} = 'secret1';
test_access($node, 'test1', 0, 'simple bind authentication succeeds');
note "search+bind";
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'wrong';
test_access($node, 'test0', 2, 'search+bind authentication fails if user not found in LDAP');
test_access($node, 'test1', 2, 'search+bind authentication fails with wrong password');
test_access($node, 'test0', 2,
'search+bind authentication fails if user not found in LDAP');
test_access($node, 'test1', 2,
'search+bind authentication fails with wrong password');
$ENV{"PGPASSWORD"} = 'secret1';
test_access($node, 'test1', 0, 'search+bind authentication succeeds');
note "LDAP URLs";
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn?uid?sub"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn?uid?sub"});
$node->restart;
$ENV{"PGPASSWORD"} = 'wrong';
test_access($node, 'test0', 2, 'search+bind with LDAP URL authentication fails if user not found in LDAP');
test_access($node, 'test1', 2, 'search+bind with LDAP URL authentication fails with wrong password');
test_access($node, 'test0', 2,
'search+bind with LDAP URL authentication fails if user not found in LDAP'
);
test_access($node, 'test1', 2,
'search+bind with LDAP URL authentication fails with wrong password');
$ENV{"PGPASSWORD"} = 'secret1';
test_access($node, 'test1', 0, 'search+bind with LDAP URL authentication succeeds');
test_access($node, 'test1', 0,
'search+bind with LDAP URL authentication succeeds');
note "search filters";
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -185,7 +211,9 @@ test_access($node, 'test2@example.net', 0, 'search filter finds by mail');
note "search filters in LDAP URLs";
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub?(|(uid=\$username)(mail=\$username))"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub?(|(uid=\$username)(mail=\$username))"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -197,7 +225,9 @@ test_access($node, 'test2@example.net', 0, 'search filter finds by mail');
# settings. ldapurl is always parsed first, then the other settings
# override. It might be useful in a case like this.
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapurl="$ldap_url/$ldap_basedn??sub" ldapsearchfilter="(|(uid=\$username)(mail=\$username))"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -207,7 +237,9 @@ note "diagnostic message";
# note bad ldapprefix with a question mark that triggers a diagnostic message
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="?uid=" ldapsuffix=""});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapprefix="?uid=" ldapsuffix=""}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -217,7 +249,9 @@ note "TLS";
# request StartTLS with ldaptls=1
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)" ldaptls=1});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)" ldaptls=1}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -225,7 +259,9 @@ test_access($node, 'test1', 0, 'StartTLS');
# request LDAPS with ldapscheme=ldaps
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapserver=$ldap_server ldapscheme=ldaps ldapport=$ldaps_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapserver=$ldap_server ldapscheme=ldaps ldapport=$ldaps_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -233,7 +269,9 @@ test_access($node, 'test1', 0, 'LDAPS');
# request LDAPS with ldapurl=ldaps://...
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)"});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)"}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......@@ -241,7 +279,9 @@ test_access($node, 'test1', 0, 'LDAPS with URL');
# bad combination of LDAPS and StartTLS
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)" ldaptls=1});
$node->append_conf('pg_hba.conf',
qq{local all all ldap ldapurl="$ldaps_url/$ldap_basedn??sub?(uid=\$username)" ldaptls=1}
);
$node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
......
......@@ -15,25 +15,27 @@ $node->start;
$node->safe_psql('postgres', 'create extension pageinspect');
# Create a table with an autosummarizing BRIN index
$node->safe_psql('postgres',
$node->safe_psql(
'postgres',
'create table brin_wi (a int) with (fillfactor = 10);
create index brin_wi_idx on brin_wi using brin (a) with (pages_per_range=1, autosummarize=on);
'
);
my $count = $node->safe_psql('postgres',
"select count(*) from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
"select count(*) from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
);
is($count, '1', "initial index state is correct");
$node->safe_psql('postgres',
'insert into brin_wi select * from generate_series(1, 100)');
$node->poll_query_until('postgres',
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)",
$node->poll_query_until(
'postgres',
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)",
't');
$count = $node->safe_psql('postgres',
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
);
is($count, 't', "index got summarized");
$node->stop;
......@@ -184,8 +184,7 @@ my %full_runs = (
createdb => 1,
defaults => 1,
no_privs => 1,
no_owner => 1,
);
no_owner => 1,);
my %tests = (
'ALTER EXTENSION test_pg_dump' => {
......@@ -209,8 +208,7 @@ my %tests = (
%full_runs,
schema_only => 1,
section_pre_data => 1, },
unlike => {
binary_upgrade => 1, }, },
unlike => { binary_upgrade => 1, }, },
'CREATE ROLE regress_dump_test_role' => {
create_order => 1,
......@@ -307,8 +305,7 @@ my %tests = (
%full_runs,
schema_only => 1,
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
unlike => { no_privs => 1, }, },
'GRANT SELECT ON TABLE regress_pg_dump_table' => {
regexp => qr/^
......@@ -326,8 +323,9 @@ my %tests = (
\n/xms,
like => { binary_upgrade => 1, }, },
'GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role' =>
{ create_order => 4,
'GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role'
=> {
create_order => 4,
create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table
TO regress_dump_test_role;',
regexp => qr/^
......@@ -337,8 +335,7 @@ my %tests = (
%full_runs,
schema_only => 1,
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
unlike => { no_privs => 1, }, },
'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role'
=> {
......@@ -352,8 +349,7 @@ my %tests = (
%full_runs,
schema_only => 1,
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
unlike => { no_privs => 1, }, },
'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
regexp => qr/^
......@@ -372,8 +368,7 @@ my %tests = (
%full_runs,
schema_only => 1,
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
unlike => { no_privs => 1, }, },
# Objects included in extension part of a schema created by this extension */
'CREATE TABLE regress_pg_dump_schema.test_table' => {
......@@ -469,8 +464,7 @@ my %tests = (
like => {
%full_runs,
schema_only => 1,
section_pre_data => 1, }, },
);
section_pre_data => 1, }, },);
#########################################
# Create a PG instance to test actually dumping from
......@@ -504,8 +498,9 @@ foreach my $run (sort keys %pgdump_runs)
# Then count all the tests run against each run
foreach my $test (sort keys %tests)
{
# If there is a like entry, but no unlike entry, then we will test the like case
if ($tests{$test}->{like}->{$test_key} && !defined($tests{$test}->{unlike}->{$test_key}))
# If there is a like entry, but no unlike entry, then we will test the like case
if ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{
$num_tests++;
}
......@@ -585,18 +580,18 @@ foreach my $run (sort keys %pgdump_runs)
{
# Run the test listed as a like, unless it is specifically noted
# as an unlike (generally due to an explicit exclusion or similar).
if ($tests{$test}->{like}->{$test_key} && !defined($tests{$test}->{unlike}->{$test_key}))
if ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{
if (!ok($output_file =~ $tests{$test}->{regexp}, "$run: should dump $test"))
if (!ok($output_file =~ $tests{$test}->{regexp},
"$run: should dump $test"))
{
diag("Review $run results in $tempdir");
}
}
else
{
if (!ok(
$output_file !~
$tests{$test}->{regexp},
if (!ok($output_file !~ $tests{$test}->{regexp},
"$run: should not dump $test"))
{
diag("Review $run results in $tempdir");
......
......@@ -1535,7 +1535,7 @@ sub wait_for_catchup
}
else
{
$lsn_expr = 'pg_current_wal_lsn()'
$lsn_expr = 'pg_current_wal_lsn()';
}
print "Waiting for replication conn "
. $standby_name . "'s "
......@@ -1686,8 +1686,8 @@ to check for timeout. retval is undef on timeout.
sub pg_recvlogical_upto
{
my ($self, $dbname, $slot_name, $endpos, $timeout_secs, %plugin_options) =
@_;
my ($self, $dbname, $slot_name, $endpos, $timeout_secs, %plugin_options)
= @_;
my ($stdout, $stderr);
my $timeout_exception = 'pg_recvlogical timed out';
......
......@@ -174,6 +174,7 @@ sub real_dir
return $dir unless $Config{osname} eq 'msys';
my $here = cwd;
chdir $dir;
# this odd way of calling 'pwd -W' is the only way that seems to work.
$dir = qx{sh -c "pwd -W"};
chomp $dir;
......@@ -254,12 +255,9 @@ sub check_mode_recursive
# Result defaults to true
my $result = 1;
find
(
{follow_fast => 1,
wanted =>
sub
{
find(
{ follow_fast => 1,
wanted => sub {
my $file_stat = stat($File::Find::name);
# Is file in the ignore list?
......@@ -281,7 +279,8 @@ sub check_mode_recursive
{
if ($file_mode != $expected_file_mode)
{
print(*STDERR,
print(
*STDERR,
sprintf("$File::Find::name mode must be %04o\n",
$expected_file_mode));
......@@ -289,12 +288,14 @@ sub check_mode_recursive
return;
}
}
# Else a directory?
elsif (S_ISDIR($file_stat->mode))
{
if ($file_mode != $expected_dir_mode)
{
print(*STDERR,
print(
*STDERR,
sprintf("$File::Find::name mode must be %04o\n",
$expected_dir_mode));
......@@ -302,14 +303,15 @@ sub check_mode_recursive
return;
}
}
# Else something we can't handle
else
{
die "unknown file type for $File::Find::name";
}
}},
$dir
);
}
},
$dir);
return $result;
}
......@@ -319,23 +321,21 @@ sub chmod_recursive
{
my ($dir, $dir_mode, $file_mode) = @_;
find
(
{follow_fast => 1,
wanted =>
sub
{
find(
{ follow_fast => 1,
wanted => sub {
my $file_stat = stat($File::Find::name);
if (defined($file_stat))
{
chmod(S_ISDIR($file_stat->mode) ? $dir_mode : $file_mode,
$File::Find::name)
or die "unable to chmod $File::Find::name";
chmod(
S_ISDIR($file_stat->mode) ? $dir_mode : $file_mode,
$File::Find::name
) or die "unable to chmod $File::Find::name";
}
}
}},
$dir
);
},
$dir);
}
# Check presence of a given regexp within pg_config.h for the installation
......@@ -351,7 +351,7 @@ sub check_pg_config
chomp($stdout);
open my $pg_config_h, '<', "$stdout/pg_config.h" or die "$!";
my $match = (grep {/^$regexp/} <$pg_config_h>);
my $match = (grep { /^$regexp/ } <$pg_config_h>);
close $pg_config_h;
return $match;
}
......
......@@ -80,8 +80,7 @@ is($stdout_recv, $expected,
$node_master->poll_query_until('postgres',
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_slot' AND active_pid IS NULL)"
)
or die "slot never became inactive";
) or die "slot never became inactive";
$stdout_recv = $node_master->pg_recvlogical_upto(
'postgres', 'test_slot', $endpos, 10,
......
......@@ -30,7 +30,8 @@ $node->init(allows_streaming => 1);
$node->start();
# by default PostgresNode doesn't doesn't restart after a crash
$node->safe_psql('postgres',
$node->safe_psql(
'postgres',
q[ALTER SYSTEM SET restart_after_crash = 1;
ALTER SYSTEM SET log_connections = 1;
SELECT pg_reload_conf();]);
......@@ -107,7 +108,11 @@ is($ret, 0, "killed process with SIGQUIT");
$killme_stdin .= q[
SELECT 1;
];
ok(pump_until($killme, \$killme_stderr, qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m),
ok( pump_until(
$killme,
\$killme_stderr,
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
),
"psql query died successfully after SIGQUIT");
$killme_stderr = '';
$killme_stdout = '';
......@@ -116,13 +121,21 @@ $killme->finish;
# Wait till server restarts - we should get the WARNING here, but
# sometimes the server is unable to send that, if interrupted while
# sending.
ok(pump_until($monitor, \$monitor_stderr, qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m),
ok( pump_until(
$monitor,
\$monitor_stderr,
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
),
"psql monitor died successfully after SIGQUIT");
$monitor->finish;
# Wait till server restarts
is($node->poll_query_until('postgres', 'SELECT $$restarted after sigquit$$;', 'restarted after sigquit'),
"1", "reconnected after SIGQUIT");
is( $node->poll_query_until(
'postgres',
'SELECT $$restarted after sigquit$$;',
'restarted after sigquit'),
"1",
"reconnected after SIGQUIT");
# restart psql processes, now that the crash cycle finished
......@@ -179,35 +192,51 @@ is($ret, 0, "killed process with KILL");
$killme_stdin .= q[
SELECT 1;
];
ok(pump_until($killme, \$killme_stderr, qr/server closed the connection unexpectedly/m),
ok( pump_until(
$killme, \$killme_stderr,
qr/server closed the connection unexpectedly/m),
"psql query died successfully after SIGKILL");
$killme->finish;
# Wait till server restarts - we should get the WARNING here, but
# sometimes the server is unable to send that, if interrupted while
# sending.
ok(pump_until($monitor, \$monitor_stderr, qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m),
ok( pump_until(
$monitor,
\$monitor_stderr,
qr/WARNING: terminating connection because of crash of another server process|server closed the connection unexpectedly/m
),
"psql monitor died successfully after SIGKILL");
$monitor->finish;
# Wait till server restarts
is($node->poll_query_until('postgres', 'SELECT 1', '1'), "1", "reconnected after SIGKILL");
is($node->poll_query_until('postgres', 'SELECT 1', '1'),
"1", "reconnected after SIGKILL");
# Make sure the committed rows survived, in-progress ones not
is($node->safe_psql('postgres', 'SELECT * FROM alive'),
"committed-before-sigquit\ncommitted-before-sigkill", 'data survived');
is( $node->safe_psql('postgres', 'SELECT * FROM alive'),
"committed-before-sigquit\ncommitted-before-sigkill",
'data survived');
is($node->safe_psql('postgres', 'INSERT INTO alive VALUES($$before-orderly-restart$$) RETURNING status'),
'before-orderly-restart', 'can still write after crash restart');
is( $node->safe_psql(
'postgres',
'INSERT INTO alive VALUES($$before-orderly-restart$$) RETURNING status'),
'before-orderly-restart',
'can still write after crash restart');
# Just to be sure, check that an orderly restart now still works
$node->restart();
is($node->safe_psql('postgres', 'SELECT * FROM alive'),
"committed-before-sigquit\ncommitted-before-sigkill\nbefore-orderly-restart", 'data survived');
is( $node->safe_psql('postgres', 'SELECT * FROM alive'),
"committed-before-sigquit\ncommitted-before-sigkill\nbefore-orderly-restart",
'data survived');
is($node->safe_psql('postgres', 'INSERT INTO alive VALUES($$after-orderly-restart$$) RETURNING status'),
'after-orderly-restart', 'can still write after orderly restart');
is( $node->safe_psql(
'postgres',
'INSERT INTO alive VALUES($$after-orderly-restart$$) RETURNING status'
),
'after-orderly-restart',
'can still write after orderly restart');
$node->stop();
......@@ -221,7 +250,7 @@ sub pump_until
if ($psql_timeout->is_expired)
{
diag("aborting wait: program timed out");
diag("stream contents: >>", $$stream,"<<");
diag("stream contents: >>", $$stream, "<<");
diag("pattern searched for: ", $untl);
return 0;
......@@ -229,7 +258,7 @@ sub pump_until
if (not $proc->pumpable())
{
diag("aborting wait: program died");
diag("stream contents: >>", $$stream,"<<");
diag("stream contents: >>", $$stream, "<<");
diag("pattern searched for: ", $untl);
return 0;
......@@ -239,4 +268,4 @@ sub pump_until
}
return 1;
};
}
......@@ -32,8 +32,7 @@ my $tablespaceDir = TestLib::tempdir;
my $realTSDir = TestLib::real_dir($tablespaceDir);
$node->safe_psql('postgres',
"CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
$node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
$node->safe_psql('postgres',
'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1');
......@@ -64,11 +63,9 @@ unlink("$pgdata/${ts1UnloggedPath}")
$node->start;
# check unlogged table in base
ok(-f "$pgdata/${baseUnloggedPath}_init",
'init fork in base still exists');
ok(-f "$pgdata/$baseUnloggedPath",
'main fork in base recreated at startup');
ok( !-f "$pgdata/${baseUnloggedPath}_vm",
ok(-f "$pgdata/${baseUnloggedPath}_init", 'init fork in base still exists');
ok(-f "$pgdata/$baseUnloggedPath", 'main fork in base recreated at startup');
ok(!-f "$pgdata/${baseUnloggedPath}_vm",
'vm fork in base removed at startup');
ok( !-f "$pgdata/${baseUnloggedPath}_fsm",
'fsm fork in base removed at startup');
......
......@@ -41,7 +41,8 @@ sub test_connect_ok
my ($common_connstr, $connstr, $test_name) = @_;
my $cmd = [
'psql', '-X', '-A', '-t', '-c', "SELECT \$\$connected with $connstr\$\$",
'psql', '-X', '-A', '-t', '-c',
"SELECT \$\$connected with $connstr\$\$",
'-d', "$common_connstr $connstr" ];
command_ok($cmd, $test_name);
......@@ -52,7 +53,8 @@ sub test_connect_fails
my ($common_connstr, $connstr, $expected_stderr, $test_name) = @_;
my $cmd = [
'psql', '-X', '-A', '-t', '-c', "SELECT \$\$connected with $connstr\$\$",
'psql', '-X', '-A', '-t', '-c',
"SELECT \$\$connected with $connstr\$\$",
'-d', "$common_connstr $connstr" ];
command_fails_like($cmd, $expected_stderr, $test_name);
......@@ -89,9 +91,11 @@ sub configure_test_server_for_ssl
if (defined($password))
{
$node->psql('postgres',
"SET password_encryption='$password_enc'; ALTER USER ssltestuser PASSWORD '$password';");
"SET password_encryption='$password_enc'; ALTER USER ssltestuser PASSWORD '$password';"
);
$node->psql('postgres',
"SET password_encryption='$password_enc'; ALTER USER anotheruser PASSWORD '$password';");
"SET password_encryption='$password_enc'; ALTER USER anotheruser PASSWORD '$password';"
);
}
# enable logging etc.
......
This diff is collapsed.
......@@ -43,34 +43,37 @@ configure_test_server_for_ssl($node, $SERVERHOSTADDR, "scram-sha-256",
switch_server_cert($node, 'server-cn-only');
$ENV{PGPASSWORD} = "pass";
$common_connstr =
"user=ssltestuser dbname=trustdb sslmode=require hostaddr=$SERVERHOSTADDR";
"user=ssltestuser dbname=trustdb sslmode=require hostaddr=$SERVERHOSTADDR";
# Default settings
test_connect_ok($common_connstr, '',
"SCRAM authentication with default channel binding");
# Channel binding settings
test_connect_ok($common_connstr,
test_connect_ok(
$common_connstr,
"scram_channel_binding=tls-unique",
"SCRAM authentication with tls-unique as channel binding");
test_connect_ok($common_connstr,
"scram_channel_binding=''",
test_connect_ok($common_connstr, "scram_channel_binding=''",
"SCRAM authentication without channel binding");
if ($supports_tls_server_end_point)
{
test_connect_ok($common_connstr,
test_connect_ok(
$common_connstr,
"scram_channel_binding=tls-server-end-point",
"SCRAM authentication with tls-server-end-point as channel binding");
}
else
{
test_connect_fails($common_connstr,
test_connect_fails(
$common_connstr,
"scram_channel_binding=tls-server-end-point",
qr/channel binding type "tls-server-end-point" is not supported by this build/,
qr/channel binding type "tls-server-end-point" is not supported by this build/,
"SCRAM authentication with tls-server-end-point as channel binding");
$number_of_tests++;
}
test_connect_fails($common_connstr,
test_connect_fails(
$common_connstr,
"scram_channel_binding=not-exists",
qr/unsupported SCRAM channel-binding type/,
"SCRAM authentication with invalid channel binding");
......
......@@ -32,7 +32,8 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres',
"INSERT INTO tab_mixed (a, b) VALUES (1, 'foo')");
$node_publisher->safe_psql('postgres',
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))");
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
);
# Setup structure on subscriber
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_notrep (a int)");
......@@ -48,7 +49,8 @@ $node_subscriber->safe_psql('postgres',
# replication of the table with included index
$node_subscriber->safe_psql('postgres',
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))");
"CREATE TABLE tab_include (a int, b text, CONSTRAINT covering PRIMARY KEY(a) INCLUDE(b))"
);
# Setup logical replication
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
......@@ -97,7 +99,8 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres',
"INSERT INTO tab_include SELECT generate_series(1,50)");
$node_publisher->safe_psql('postgres', "DELETE FROM tab_include WHERE a > 20");
$node_publisher->safe_psql('postgres',
"DELETE FROM tab_include WHERE a > 20");
$node_publisher->safe_psql('postgres', "UPDATE tab_include SET a = -a");
$node_publisher->wait_for_catchup($appname);
......@@ -117,7 +120,8 @@ is( $result, qq(|foo|1
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab_include");
is($result, qq(20|-20|-1), 'check replicated changes with primary key index with included columns');
is($result, qq(20|-20|-1),
'check replicated changes with primary key index with included columns');
# insert some duplicate rows
$node_publisher->safe_psql('postgres',
......
......@@ -34,7 +34,7 @@ $node_publisher->wait_for_catchup($appname);
# Wait for initial sync to finish as well
my $synced_query =
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
......
......@@ -30,15 +30,16 @@ $node_publisher->wait_for_catchup($appname);
# Wait for initial sync to finish as well
my $synced_query =
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
$node_publisher->safe_psql('postgres', q{INSERT INTO test1 (a, b) VALUES (1, 'one'), (2, 'two');});
$node_publisher->safe_psql('postgres',
q{INSERT INTO test1 (a, b) VALUES (1, 'one'), (2, 'two');});
$node_publisher->wait_for_catchup($appname);
is($node_subscriber->safe_psql('postgres', q{SELECT a, b FROM test1}),
is( $node_subscriber->safe_psql('postgres', q{SELECT a, b FROM test1}),
qq(1|one
2|two),
'initial data replicated to subscriber');
......@@ -50,11 +51,12 @@ $node_publisher->safe_psql('postgres', $ddl2);
$node_publisher->wait_for_catchup($appname);
$node_publisher->safe_psql('postgres', q{INSERT INTO test1 (a, b, c) VALUES (3, 'three', 33);});
$node_publisher->safe_psql('postgres',
q{INSERT INTO test1 (a, b, c) VALUES (3, 'three', 33);});
$node_publisher->wait_for_catchup($appname);
is($node_subscriber->safe_psql('postgres', q{SELECT a, b, c FROM test1}),
is( $node_subscriber->safe_psql('postgres', q{SELECT a, b, c FROM test1}),
qq(1|one|0
2|two|0
3|three|33),
......
......@@ -28,7 +28,8 @@ $node_subscriber->safe_psql('postgres',
$node_publisher->wait_for_catchup($appname);
$node_subscriber->safe_psql('postgres', q{
$node_subscriber->safe_psql(
'postgres', q{
BEGIN;
ALTER SUBSCRIPTION mysub DISABLE;
ALTER SUBSCRIPTION mysub SET (slot_name = NONE);
......
......@@ -22,11 +22,14 @@ $node_publisher->safe_psql('postgres',
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
# Setup structure on subscriber
$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999, e int GENERATED BY DEFAULT AS IDENTITY)");
$node_subscriber->safe_psql('postgres',
"CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999, e int GENERATED BY DEFAULT AS IDENTITY)"
);
# Setup logical replication
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
$node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub FOR TABLE test_tab");
$node_publisher->safe_psql('postgres',
"CREATE PUBLICATION tap_pub FOR TABLE test_tab");
my $appname = 'tap_sub';
$node_subscriber->safe_psql('postgres',
......@@ -42,7 +45,8 @@ $node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
my $result =
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab");
$node_subscriber->safe_psql('postgres',
"SELECT count(*), count(c), count(d = 999) FROM test_tab");
is($result, qq(2|2|2), 'check initial data was copied to subscriber');
# Update the rows on the publisher and check the additional columns on
......@@ -52,19 +56,25 @@ $node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = md5(b)");
$node_publisher->wait_for_catchup($appname);
$result =
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab");
is($result, qq(2|2|2|2), 'check extra columns contain local defaults after copy');
$node_subscriber->safe_psql('postgres',
"SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab");
is($result, qq(2|2|2|2),
'check extra columns contain local defaults after copy');
# Change the local values of the extra columns on the subscriber,
# update publisher, and check that subscriber retains the expected
# values
$node_subscriber->safe_psql('postgres', "UPDATE test_tab SET c = 'epoch'::timestamptz + 987654321 * interval '1s'");
$node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = md5(a::text)");
$node_subscriber->safe_psql('postgres',
"UPDATE test_tab SET c = 'epoch'::timestamptz + 987654321 * interval '1s'"
);
$node_publisher->safe_psql('postgres',
"UPDATE test_tab SET b = md5(a::text)");
$node_publisher->wait_for_catchup($appname);
$result =
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab");
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab"
);
is($result, qq(2|2|2), 'check extra columns contain locally changed data');
# Another insert
......@@ -74,8 +84,10 @@ $node_publisher->safe_psql('postgres',
$node_publisher->wait_for_catchup($appname);
$result =
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab");
is($result, qq(3|3|3|3), 'check extra columns contain local defaults after apply');
$node_subscriber->safe_psql('postgres',
"SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab");
is($result, qq(3|3|3|3),
'check extra columns contain local defaults after apply');
$node_subscriber->stop;
$node_publisher->stop;
......@@ -22,10 +22,13 @@ $node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;"
);
$node_publisher->safe_psql('postgres', q{CREATE TABLE test1 (a int PRIMARY KEY, b text)});
$node_publisher->safe_psql('postgres', q{INSERT INTO test1 (a, b) VALUES (1, 'one'), (2, 'two');});
$node_publisher->safe_psql('postgres',
q{CREATE TABLE test1 (a int PRIMARY KEY, b text)});
$node_publisher->safe_psql('postgres',
q{INSERT INTO test1 (a, b) VALUES (1, 'one'), (2, 'two');});
$node_subscriber->safe_psql('postgres', q{CREATE TABLE test1 (a int PRIMARY KEY, b text);});
$node_subscriber->safe_psql('postgres',
q{CREATE TABLE test1 (a int PRIMARY KEY, b text);});
$node_publisher->wait_for_catchup($appname);
......@@ -34,8 +37,10 @@ $node_publisher->wait_for_catchup($appname);
# need to make sure they are properly ignored. (bug #15044)
# create a MV with some data
$node_publisher->safe_psql('postgres', q{CREATE MATERIALIZED VIEW testmv1 AS SELECT * FROM test1;});
$node_publisher->safe_psql('postgres',
q{CREATE MATERIALIZED VIEW testmv1 AS SELECT * FROM test1;});
$node_publisher->wait_for_catchup($appname);
# There is no equivalent relation on the subscriber, but MV data is
# not replicated, so this does not hang.
......
......@@ -42,11 +42,8 @@ $node_subscriber->safe_psql('postgres',
"CREATE TABLE tab4 (x int PRIMARY KEY, y int REFERENCES tab3)");
$node_subscriber->safe_psql('postgres',
"CREATE SEQUENCE seq1 OWNED BY tab1.a"
);
$node_subscriber->safe_psql('postgres',
"ALTER SEQUENCE seq1 START 101"
);
"CREATE SEQUENCE seq1 OWNED BY tab1.a");
$node_subscriber->safe_psql('postgres', "ALTER SEQUENCE seq1 START 101");
$node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub1 FOR TABLE tab1");
......@@ -55,11 +52,14 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub3 FOR TABLE tab3, tab4");
$node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr application_name=sub1' PUBLICATION pub1");
"CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr application_name=sub1' PUBLICATION pub1"
);
$node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION sub2 CONNECTION '$publisher_connstr application_name=sub2' PUBLICATION pub2");
"CREATE SUBSCRIPTION sub2 CONNECTION '$publisher_connstr application_name=sub2' PUBLICATION pub2"
);
$node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION sub3 CONNECTION '$publisher_connstr application_name=sub3' PUBLICATION pub3");
"CREATE SUBSCRIPTION sub3 CONNECTION '$publisher_connstr application_name=sub3' PUBLICATION pub3"
);
# Wait for initial sync of all subscriptions
my $synced_query =
......@@ -69,7 +69,8 @@ $node_subscriber->poll_query_until('postgres', $synced_query)
# insert data to truncate
$node_subscriber->safe_psql('postgres', "INSERT INTO tab1 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres',
"INSERT INTO tab1 VALUES (1), (2), (3)");
$node_publisher->wait_for_catchup('sub1');
......@@ -81,13 +82,10 @@ $node_publisher->wait_for_catchup('sub1');
my $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab1");
is($result, qq(0||),
'truncate replicated');
is($result, qq(0||), 'truncate replicated');
$result = $node_subscriber->safe_psql('postgres',
"SELECT nextval('seq1')");
is($result, qq(1),
'sequence not restarted');
$result = $node_subscriber->safe_psql('postgres', "SELECT nextval('seq1')");
is($result, qq(1), 'sequence not restarted');
# truncate with restart identity
......@@ -95,14 +93,13 @@ $node_publisher->safe_psql('postgres', "TRUNCATE tab1 RESTART IDENTITY");
$node_publisher->wait_for_catchup('sub1');
$result = $node_subscriber->safe_psql('postgres',
"SELECT nextval('seq1')");
is($result, qq(101),
'truncate restarted identities');
$result = $node_subscriber->safe_psql('postgres', "SELECT nextval('seq1')");
is($result, qq(101), 'truncate restarted identities');
# test publication that does not replicate truncate
$node_subscriber->safe_psql('postgres', "INSERT INTO tab2 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres',
"INSERT INTO tab2 VALUES (1), (2), (3)");
$node_publisher->safe_psql('postgres', "TRUNCATE tab2");
......@@ -110,8 +107,7 @@ $node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab2");
is($result, qq(3|1|3),
'truncate not replicated');
is($result, qq(3|1|3), 'truncate not replicated');
$node_publisher->safe_psql('postgres',
"ALTER PUBLICATION pub2 SET (publish = 'insert, truncate')");
......@@ -122,13 +118,14 @@ $node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab2");
is($result, qq(0||),
'truncate replicated after publication change');
is($result, qq(0||), 'truncate replicated after publication change');
# test multiple tables connected by foreign keys
$node_subscriber->safe_psql('postgres', "INSERT INTO tab3 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres', "INSERT INTO tab4 VALUES (11, 1), (111, 1), (22, 2)");
$node_subscriber->safe_psql('postgres',
"INSERT INTO tab3 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres',
"INSERT INTO tab4 VALUES (11, 1), (111, 1), (22, 2)");
$node_publisher->safe_psql('postgres', "TRUNCATE tab3, tab4");
......@@ -136,20 +133,20 @@ $node_publisher->wait_for_catchup('sub3');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab3");
is($result, qq(0||),
'truncate of multiple tables replicated');
is($result, qq(0||), 'truncate of multiple tables replicated');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(x), max(x) FROM tab4");
is($result, qq(0||),
'truncate of multiple tables replicated');
is($result, qq(0||), 'truncate of multiple tables replicated');
# test truncate of multiple tables, some of which are not published
$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION sub2");
$node_publisher->safe_psql('postgres', "DROP PUBLICATION pub2");
$node_subscriber->safe_psql('postgres', "INSERT INTO tab1 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres', "INSERT INTO tab2 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres',
"INSERT INTO tab1 VALUES (1), (2), (3)");
$node_subscriber->safe_psql('postgres',
"INSERT INTO tab2 VALUES (1), (2), (3)");
$node_publisher->safe_psql('postgres', "TRUNCATE tab1, tab2");
......@@ -157,9 +154,7 @@ $node_publisher->wait_for_catchup('sub1');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab1");
is($result, qq(0||),
'truncate of multiple tables some not published');
is($result, qq(0||), 'truncate of multiple tables some not published');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab2");
is($result, qq(3|1|3),
'truncate of multiple tables some not published');
is($result, qq(3|1|3), 'truncate of multiple tables some not published');
......@@ -102,7 +102,7 @@ my %rel_tags;
{
my $commit = $1;
my $tag = $2;
if ($tag =~ /^REL_\d+_\d+$/
if ( $tag =~ /^REL_\d+_\d+$/
|| $tag =~ /^REL\d+_\d+$/
|| $tag =~ /^REL\d+_\d+_\d+$/)
{
......
......@@ -530,11 +530,12 @@ sub mkvcbuild
my $perl_path = $solution->{options}->{perl} . '\lib\CORE\*perl*';
# ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a
# Starting with ActivePerl 5.24, both perlnn.lib and libperlnn.a are provided.
# In this case, prefer .lib.
# ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a
# Starting with ActivePerl 5.24, both perlnn.lib and libperlnn.a are provided.
# In this case, prefer .lib.
my @perl_libs =
reverse sort grep { /perl\d+\.lib$|libperl\d+\.a$/ } glob($perl_path);
reverse sort grep { /perl\d+\.lib$|libperl\d+\.a$/ }
glob($perl_path);
if (@perl_libs > 0)
{
$plperl->AddLibrary($perl_libs[0]);
......
......@@ -176,8 +176,7 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c
"\n";
print $o "#define RELSEG_SIZE ",
(1024 / $self->{options}->{blocksize}) *
$self->{options}->{segsize} *
1024, "\n";
$self->{options}->{segsize} * 1024, "\n";
print $o "#define XLOG_BLCKSZ ",
1024 * $self->{options}->{wal_blocksize}, "\n";
......@@ -267,16 +266,13 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c
chdir('src/backend/utils');
my $pg_language_dat = '../../../src/include/catalog/pg_language.dat';
my $pg_proc_dat = '../../../src/include/catalog/pg_proc.dat';
if (IsNewer(
'fmgrtab.c', $pg_language_dat)
|| IsNewer(
'fmgrtab.c', $pg_proc_dat)
|| IsNewer(
'fmgrtab.c', '../../../src/include/access/transam.h')
)
if ( IsNewer('fmgrtab.c', $pg_language_dat)
|| IsNewer('fmgrtab.c', $pg_proc_dat)
|| IsNewer('fmgrtab.c', '../../../src/include/access/transam.h'))
{
system(
"perl -I ../catalog Gen_fmgrtab.pl -I../../../src/include/ $pg_language_dat $pg_proc_dat");
"perl -I ../catalog Gen_fmgrtab.pl -I../../../src/include/ $pg_language_dat $pg_proc_dat"
);
}
chdir('../../..');
......@@ -471,6 +467,7 @@ EOF
$mf =~ /^POSTGRES_BKI_DATA\s*:?=[^,]+,(.*)\)$/gm
|| croak "Could not find POSTGRES_BKI_DATA in Makefile\n";
my @bki_data = split /\s+/, $1;
foreach my $bki (@bki_srcs, @bki_data)
{
next if $bki eq "";
......@@ -480,7 +477,8 @@ EOF
{
chdir('src/backend/catalog');
my $bki_srcs = join(' ../../../src/include/catalog/', @bki_srcs);
system("perl genbki.pl --set-version=$self->{majorver} $bki_srcs");
system(
"perl genbki.pl --set-version=$self->{majorver} $bki_srcs");
chdir('../../..');
# Copy generated headers to include directory.
......
......@@ -53,8 +53,10 @@ sub CreateSolution
{
return new VS2015Solution(@_);
}
# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
elsif (($visualStudioVersion ge '14.10')
or ($visualStudioVersion eq '15.00'))
{
return new VS2017Solution(@_);
}
......@@ -98,8 +100,10 @@ sub CreateProject
{
return new VC2015Project(@_);
}
# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
elsif (($visualStudioVersion ge '14.10')
or ($visualStudioVersion eq '15.00'))
{
return new VC2017Project(@_);
}
......@@ -132,7 +136,8 @@ sub DetermineVisualStudioVersion
sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;
# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
if ($major > 14)
{
carp
......
......@@ -254,13 +254,16 @@ sub plcheck
{
next unless -d "$dir/sql" && -d "$dir/expected";
my $lang;
if ($dir eq 'plpgsql/src') {
if ($dir eq 'plpgsql/src')
{
$lang = 'plpgsql';
}
elsif ($dir eq 'tcl') {
elsif ($dir eq 'tcl')
{
$lang = 'pltcl';
}
else {
else
{
$lang = $dir;
}
if ($lang eq 'plpython')
......
......@@ -59,8 +59,7 @@ $excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns"
# easier to configure. Note that the typedefs need trailing newlines.
my @whitelist = ("bool\n");
my %blacklist = map { +"$_\n" => 1 }
qw( FD_SET date interval timestamp ANY
my %blacklist = map { +"$_\n" => 1 } qw( FD_SET date interval timestamp ANY
abs allocfunc iterator other pointer printfunc reference string type );
# globals
......@@ -135,7 +134,7 @@ sub load_typedefs
push(@typedefs, @whitelist);
# remove blacklisted entries
@typedefs = grep { ! $blacklist{$_} } @typedefs;
@typedefs = grep { !$blacklist{$_} } @typedefs;
# write filtered typedefs
my $filter_typedefs_fh = new File::Temp(TEMPLATE => "pgtypedefXXXXX");
......
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