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 ...@@ -185,6 +185,7 @@ sub ParseHeader
{ {
$column{forcenotnull} = 1; $column{forcenotnull} = 1;
} }
# We use quotes for values like \0 and \054, to # We use quotes for values like \0 and \054, to
# make sure all compilers and syntax highlighters # make sure all compilers and syntax highlighters
# can recognize them properly. # can recognize them properly.
...@@ -199,7 +200,7 @@ sub ParseHeader ...@@ -199,7 +200,7 @@ sub ParseHeader
else else
{ {
die die
"unknown column option $attopt on column $attname"; "unknown column option $attopt on column $attname";
} }
if ($column{forcenull} and $column{forcenotnull}) if ($column{forcenull} and $column{forcenotnull})
...@@ -311,8 +312,9 @@ sub AddDefaultValues ...@@ -311,8 +312,9 @@ sub AddDefaultValues
{ {
$row->{$attname} = $column->{default}; $row->{$attname} = $column->{default};
} }
elsif ($catname eq 'pg_proc' && $attname eq 'pronargs' && elsif ($catname eq 'pg_proc'
defined($row->{proargtypes})) && $attname eq 'pronargs'
&& defined($row->{proargtypes}))
{ {
# pg_proc.pronargs can be derived from proargtypes. # pg_proc.pronargs can be derived from proargtypes.
my @proargtypes = split /\s+/, $row->{proargtypes}; my @proargtypes = split /\s+/, $row->{proargtypes};
...@@ -379,7 +381,7 @@ sub FindDefinedSymbol ...@@ -379,7 +381,7 @@ sub FindDefinedSymbol
sub FindDefinedSymbolFromData sub FindDefinedSymbolFromData
{ {
my ($data, $symbol) = @_; my ($data, $symbol) = @_;
foreach my $row (@{ $data }) foreach my $row (@{$data})
{ {
if ($row->{oid_symbol} eq $symbol) if ($row->{oid_symbol} eq $symbol)
{ {
......
...@@ -116,10 +116,12 @@ foreach my $header (@input_files) ...@@ -116,10 +116,12 @@ foreach my $header (@input_files)
# within a given Postgres release, such as fixed OIDs. Do not substitute # within a given Postgres release, such as fixed OIDs. Do not substitute
# anything that could depend on platform or configuration. (The right place # anything that could depend on platform or configuration. (The right place
# to handle those sorts of things is in initdb.c's bootstrap_template1().) # to handle those sorts of things is in initdb.c's bootstrap_template1().)
my $BOOTSTRAP_SUPERUSERID = Catalog::FindDefinedSymbolFromData( my $BOOTSTRAP_SUPERUSERID =
$catalog_data{pg_authid}, 'BOOTSTRAP_SUPERUSERID'); Catalog::FindDefinedSymbolFromData($catalog_data{pg_authid},
my $PG_CATALOG_NAMESPACE = Catalog::FindDefinedSymbolFromData( 'BOOTSTRAP_SUPERUSERID');
$catalog_data{pg_namespace}, 'PG_CATALOG_NAMESPACE'); my $PG_CATALOG_NAMESPACE =
Catalog::FindDefinedSymbolFromData($catalog_data{pg_namespace},
'PG_CATALOG_NAMESPACE');
# Build lookup tables for OID macro substitutions and for pg_attribute # Build lookup tables for OID macro substitutions and for pg_attribute
...@@ -138,8 +140,7 @@ foreach my $row (@{ $catalog_data{pg_opclass} }) ...@@ -138,8 +140,7 @@ foreach my $row (@{ $catalog_data{pg_opclass} })
{ {
# There is no unique name, so we need to combine access method # There is no unique name, so we need to combine access method
# and opclass name. # and opclass name.
my $key = sprintf "%s/%s", my $key = sprintf "%s/%s", $row->{opcmethod}, $row->{opcname};
$row->{opcmethod}, $row->{opcname};
$opcoids{$key} = $row->{oid}; $opcoids{$key} = $row->{oid};
} }
...@@ -160,8 +161,7 @@ foreach my $row (@{ $catalog_data{pg_opfamily} }) ...@@ -160,8 +161,7 @@ foreach my $row (@{ $catalog_data{pg_opfamily} })
{ {
# There is no unique name, so we need to combine access method # There is no unique name, so we need to combine access method
# and opfamily name. # and opfamily name.
my $key = sprintf "%s/%s", my $key = sprintf "%s/%s", $row->{opfmethod}, $row->{opfname};
$row->{opfmethod}, $row->{opfname};
$opfoids{$key} = $row->{oid}; $opfoids{$key} = $row->{oid};
} }
...@@ -179,6 +179,7 @@ foreach my $row (@{ $catalog_data{pg_proc} }) ...@@ -179,6 +179,7 @@ foreach my $row (@{ $catalog_data{pg_proc} })
{ {
$procoids{$prokey} = $row->{oid}; $procoids{$prokey} = $row->{oid};
} }
# Also generate an entry using proname(proargtypes). This is not quite # Also generate an entry using proname(proargtypes). This is not quite
# identical to regprocedure lookup because we don't worry much about # 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 # special SQL names for types etc; we just use the names in the source
...@@ -211,8 +212,7 @@ my %lookup_kind = ( ...@@ -211,8 +212,7 @@ my %lookup_kind = (
pg_operator => \%operoids, pg_operator => \%operoids,
pg_opfamily => \%opfoids, pg_opfamily => \%opfoids,
pg_proc => \%procoids, pg_proc => \%procoids,
pg_type => \%typeoids pg_type => \%typeoids);
);
# Generate postgres.bki, postgres.description, postgres.shdescription, # Generate postgres.bki, postgres.description, postgres.shdescription,
...@@ -345,7 +345,10 @@ EOM ...@@ -345,7 +345,10 @@ EOM
# Complain about unrecognized keys; they are presumably misspelled # Complain about unrecognized keys; they are presumably misspelled
foreach my $key (keys %bki_values) 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"; || $key eq "line_number";
die sprintf "unrecognized field name \"%s\" in %s.dat line %s\n", die sprintf "unrecognized field name \"%s\" in %s.dat line %s\n",
$key, $catname, $bki_values{line_number} $key, $catname, $bki_values{line_number}
...@@ -379,8 +382,8 @@ EOM ...@@ -379,8 +382,8 @@ EOM
if ($atttype eq 'oidvector') if ($atttype eq 'oidvector')
{ {
@lookupnames = split /\s+/, $bki_values{$attname}; @lookupnames = split /\s+/, $bki_values{$attname};
@lookupoids = lookup_oids($lookup, $catname, @lookupoids = lookup_oids($lookup, $catname, \%bki_values,
\%bki_values, @lookupnames); @lookupnames);
$bki_values{$attname} = join(' ', @lookupoids); $bki_values{$attname} = join(' ', @lookupoids);
} }
elsif ($atttype eq '_oid') elsif ($atttype eq '_oid')
...@@ -389,17 +392,18 @@ EOM ...@@ -389,17 +392,18 @@ EOM
{ {
$bki_values{$attname} =~ s/[{}]//g; $bki_values{$attname} =~ s/[{}]//g;
@lookupnames = split /,/, $bki_values{$attname}; @lookupnames = split /,/, $bki_values{$attname};
@lookupoids = lookup_oids($lookup, $catname, @lookupoids =
\%bki_values, @lookupnames); lookup_oids($lookup, $catname, \%bki_values,
$bki_values{$attname} = @lookupnames);
sprintf "{%s}", join(',', @lookupoids); $bki_values{$attname} = sprintf "{%s}",
join(',', @lookupoids);
} }
} }
else else
{ {
$lookupnames[0] = $bki_values{$attname}; $lookupnames[0] = $bki_values{$attname};
@lookupoids = lookup_oids($lookup, $catname, @lookupoids = lookup_oids($lookup, $catname, \%bki_values,
\%bki_values, @lookupnames); @lookupnames);
$bki_values{$attname} = $lookupoids[0]; $bki_values{$attname} = $lookupoids[0];
} }
} }
...@@ -756,7 +760,8 @@ sub lookup_oids ...@@ -756,7 +760,8 @@ sub lookup_oids
else else
{ {
push @lookupoids, $lookupname; 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} $lookupname, $catname, $bki_values->{line_number}
if $lookupname ne '-' and $lookupname ne '0'; if $lookupname ne '-' and $lookupname ne '0';
} }
......
...@@ -68,7 +68,7 @@ foreach my $datfile (@input_files) ...@@ -68,7 +68,7 @@ foreach my $datfile (@input_files)
my $header = "$1.h"; my $header = "$1.h";
die "There in no header file corresponding to $datfile" die "There in no header file corresponding to $datfile"
if ! -e $header; if !-e $header;
my $catalog = Catalog::ParseHeader($header); my $catalog = Catalog::ParseHeader($header);
my $catname = $catalog->{catname}; my $catname = $catalog->{catname};
...@@ -79,10 +79,12 @@ foreach my $datfile (@input_files) ...@@ -79,10 +79,12 @@ foreach my $datfile (@input_files)
} }
# Fetch some values for later. # Fetch some values for later.
my $FirstBootstrapObjectId = Catalog::FindDefinedSymbol( my $FirstBootstrapObjectId =
'access/transam.h', \@include_path, 'FirstBootstrapObjectId'); Catalog::FindDefinedSymbol('access/transam.h', \@include_path,
my $INTERNALlanguageId = Catalog::FindDefinedSymbolFromData( 'FirstBootstrapObjectId');
$catalog_data{pg_language}, 'INTERNALlanguageId'); my $INTERNALlanguageId =
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
'INTERNALlanguageId');
print "Generating fmgrtab.c, fmgroids.h, and fmgrprotos.h...\n"; print "Generating fmgrtab.c, fmgroids.h, and fmgrprotos.h...\n";
...@@ -230,7 +232,7 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr) ...@@ -230,7 +232,7 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
print $tfh print $tfh
" { $s->{oid}, \"$s->{prosrc}\", $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, $s->{prosrc} }"; " { $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) if ($fmgr_count <= $#fmgr)
{ {
......
...@@ -51,7 +51,8 @@ mkdir $datadir; ...@@ -51,7 +51,8 @@ mkdir $datadir;
# Permissions on PGDATA should be default # Permissions on PGDATA should be default
SKIP: 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), ok(check_mode_recursive($datadir, 0700, 0600),
"check PGDATA permissions"); "check PGDATA permissions");
...@@ -63,7 +64,8 @@ command_fails([ 'initdb', $datadir ], 'existing data directory'); ...@@ -63,7 +64,8 @@ command_fails([ 'initdb', $datadir ], 'existing data directory');
# Check group access on PGDATA # Check group access on PGDATA
SKIP: 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 # Init a new db with group access
my $datadir_group = "$tempdir/data_group"; my $datadir_group = "$tempdir/data_group";
......
...@@ -10,11 +10,8 @@ program_options_handling_ok('pg_archivecleanup'); ...@@ -10,11 +10,8 @@ program_options_handling_ok('pg_archivecleanup');
my $tempdir = TestLib::tempdir; my $tempdir = TestLib::tempdir;
my @walfiles = ( my @walfiles = (
'00000001000000370000000C.gz', '00000001000000370000000C.gz', '00000001000000370000000D',
'00000001000000370000000D', '00000001000000370000000E', '00000001000000370000000F.partial',);
'00000001000000370000000E',
'00000001000000370000000F.partial',
);
sub create_files sub create_files
{ {
...@@ -28,32 +25,41 @@ sub create_files ...@@ -28,32 +25,41 @@ sub create_files
create_files(); create_files();
command_fails_like(['pg_archivecleanup'], command_fails_like(
['pg_archivecleanup'],
qr/must specify archive location/, qr/must specify archive location/,
'fails if archive location is not specified'); '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/, qr/must specify oldest kept WAL file/,
'fails if oldest kept WAL file name is not specified'); '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/, qr/archive location .* does not exist/,
'fails if 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/, qr/too many command-line arguments/,
'fails with 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/, qr/invalid file name argument/,
'fails with invalid restart file name'); 'fails with invalid restart file name');
{ {
# like command_like but checking stderr # like command_like but checking stderr
my $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"); 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) foreach my $fn (@walfiles)
{ {
ok(-f "$tempdir/$fn", "$fn not removed"); ok(-f "$tempdir/$fn", "$fn not removed");
...@@ -66,14 +72,21 @@ sub run_check ...@@ -66,14 +72,21 @@ sub run_check
create_files(); 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"); "$test_name: runs");
ok(! -f "$tempdir/$walfiles[0]", "$test_name: first older WAL file was cleaned up"); ok(!-f "$tempdir/$walfiles[0]",
ok(! -f "$tempdir/$walfiles[1]", "$test_name: second older WAL file was cleaned up"); "$test_name: first older WAL file was cleaned up");
ok(-f "$tempdir/$walfiles[2]", "$test_name: restartfile was not cleaned up"); ok(!-f "$tempdir/$walfiles[1]",
ok(-f "$tempdir/$walfiles[3]", "$test_name: newer WAL file was not cleaned up"); "$test_name: second older WAL file was cleaned up");
ok(-f "$tempdir/unrelated_file", "$test_name: unrelated file was not 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'); run_check('', 'pg_archivecleanup');
......
...@@ -20,7 +20,7 @@ my $node = get_new_node('main'); ...@@ -20,7 +20,7 @@ my $node = get_new_node('main');
umask(0077); umask(0077);
# Initialize node without replication settings # Initialize node without replication settings
$node->init(extra => [ '--data-checksums' ]); $node->init(extra => ['--data-checksums']);
$node->start; $node->start;
my $pgdata = $node->data_dir; my $pgdata = $node->data_dir;
...@@ -92,7 +92,8 @@ ok(-f "$pgdata/$baseUnloggedPath", 'unlogged main fork in base'); ...@@ -92,7 +92,8 @@ ok(-f "$pgdata/$baseUnloggedPath", 'unlogged main fork in base');
my $postgresOid = $node->safe_psql('postgres', my $postgresOid = $node->safe_psql('postgres',
q{select oid from pg_database where datname = '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) foreach my $filename (@tempRelationFiles)
{ {
...@@ -107,7 +108,8 @@ ok(-f "$tempdir/backup/PG_VERSION", 'backup was created'); ...@@ -107,7 +108,8 @@ ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
# Permissions on backup should be default # Permissions on backup should be default
SKIP: 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), ok(check_mode_recursive("$tempdir/backup", 0700, 0600),
"check backup dir permissions"); "check backup dir permissions");
...@@ -133,8 +135,7 @@ foreach my $dirname ( ...@@ -133,8 +135,7 @@ foreach my $dirname (
# These files should not be copied. # These files should not be copied.
foreach my $filename ( foreach my $filename (
qw(postgresql.auto.conf.tmp postmaster.opts postmaster.pid tablespace_map current_logfiles.tmp 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"); ok(!-f "$tempdir/backup/$filename", "$filename not copied");
} }
...@@ -142,13 +143,13 @@ foreach my $filename ( ...@@ -142,13 +143,13 @@ foreach my $filename (
# Unlogged relation forks other than init should not be copied # Unlogged relation forks other than init should not be copied
ok(-f "$tempdir/backup/${baseUnloggedPath}_init", ok(-f "$tempdir/backup/${baseUnloggedPath}_init",
'unlogged init fork in backup'); 'unlogged init fork in backup');
ok(!-f "$tempdir/backup/$baseUnloggedPath", ok( !-f "$tempdir/backup/$baseUnloggedPath",
'unlogged main fork not in backup'); 'unlogged main fork not in backup');
# Temp relations should not be copied. # Temp relations should not be copied.
foreach my $filename (@tempRelationFiles) foreach my $filename (@tempRelationFiles)
{ {
ok(!-f "$tempdir/backup/base/$postgresOid/$filename", ok( !-f "$tempdir/backup/base/$postgresOid/$filename",
"base/$postgresOid/$filename not copied"); "base/$postgresOid/$filename not copied");
} }
...@@ -246,22 +247,25 @@ SKIP: ...@@ -246,22 +247,25 @@ SKIP:
# Create an unlogged table to test that forks other than init are not copied. # Create an unlogged table to test that forks other than init are not copied.
$node->safe_psql('postgres', $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( my $tblspc1UnloggedPath = $node->safe_psql('postgres',
'postgres', q{select pg_relation_filepath('tblspc1_unlogged')}); q{select pg_relation_filepath('tblspc1_unlogged')});
# Make sure main and init forks exist # Make sure main and init forks exist
ok(-f "$pgdata/${tblspc1UnloggedPath}_init", ok( -f "$pgdata/${tblspc1UnloggedPath}_init",
'unlogged init fork in tablespace'); 'unlogged init fork in tablespace');
ok(-f "$pgdata/$tblspc1UnloggedPath", ok(-f "$pgdata/$tblspc1UnloggedPath", 'unlogged main fork in tablespace');
'unlogged main fork in tablespace');
# Create files that look like temporary relations to ensure they are ignored # Create files that look like temporary relations to ensure they are ignored
# in a tablespace. # in a tablespace.
my @tempRelationFiles = qw(t888_888 t888888_888888_vm.1); my @tempRelationFiles = qw(t888_888 t888888_888888_vm.1);
my $tblSpc1Id = basename(dirname(dirname($node->safe_psql('postgres', my $tblSpc1Id = basename(
q{select pg_relation_filepath('test1')})))); dirname(
dirname(
$node->safe_psql(
'postgres', q{select pg_relation_filepath('test1')}))));
foreach my $filename (@tempRelationFiles) foreach my $filename (@tempRelationFiles)
{ {
...@@ -293,7 +297,8 @@ SKIP: ...@@ -293,7 +297,8 @@ SKIP:
"check backup dir permissions"); "check backup dir permissions");
# Unlogged relation forks other than init should not be copied # 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", ok(-f "$tempdir/tbackup/tblspc1/${tblspc1UnloggedBackupPath}_init",
'unlogged init fork in tablespace backup'); 'unlogged init fork in tablespace backup');
...@@ -303,7 +308,7 @@ SKIP: ...@@ -303,7 +308,7 @@ SKIP:
# Temp relations should not be copied. # Temp relations should not be copied.
foreach my $filename (@tempRelationFiles) 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"); "[tblspc1]/$postgresOid/$filename not copied");
# Also remove temp relation files or tablespace drop will fail. # Also remove temp relation files or tablespace drop will fail.
...@@ -402,7 +407,10 @@ $node->command_fails( ...@@ -402,7 +407,10 @@ $node->command_fails(
'pg_basebackup -C fails without slot name'); 'pg_basebackup -C fails without slot name');
$node->command_fails( $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'); 'pg_basebackup fails with -C -S --no-slot');
$node->command_ok( $node->command_ok(
...@@ -410,10 +418,15 @@ $node->command_ok( ...@@ -410,10 +418,15 @@ $node->command_ok(
'pg_basebackup -C runs'); 'pg_basebackup -C runs');
rmtree("$tempdir/backupxs_slot"); 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', 'slot0',
'replication slot was created'); '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'); 'restart LSN of new slot is not null');
...@@ -455,10 +468,10 @@ rmtree("$tempdir/backupxs_sl_R"); ...@@ -455,10 +468,10 @@ rmtree("$tempdir/backupxs_sl_R");
# create tables to corrupt and get their relfilenodes # create tables to corrupt and get their relfilenodes
my $file_corrupt1 = $node->safe_psql('postgres', 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', 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 # set page header and block sizes
...@@ -473,18 +486,19 @@ syswrite($file, '\0\0\0\0\0\0\0\0\0'); ...@@ -473,18 +486,19 @@ syswrite($file, '\0\0\0\0\0\0\0\0\0');
close $file; close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; 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, 1,
[qr{^$}], [qr{^$}],
[qr/^WARNING.*checksum verification failed/s], [qr/^WARNING.*checksum verification failed/s],
'pg_basebackup reports checksum mismatch' 'pg_basebackup reports checksum mismatch');
);
rmtree("$tempdir/backup_corrupt"); rmtree("$tempdir/backup_corrupt");
# induce further corruption in 5 more blocks # induce further corruption in 5 more blocks
system_or_bail 'pg_ctl', '-D', $pgdata, 'stop'; system_or_bail 'pg_ctl', '-D', $pgdata, 'stop';
open $file, '+<', "$pgdata/$file_corrupt1"; open $file, '+<', "$pgdata/$file_corrupt1";
for my $i ( 1..5 ) { for my $i (1 .. 5)
{
my $offset = $pageheader_size + $i * $block_size; my $offset = $pageheader_size + $i * $block_size;
seek($file, $offset, 0); seek($file, $offset, 0);
syswrite($file, '\0\0\0\0\0\0\0\0\0'); syswrite($file, '\0\0\0\0\0\0\0\0\0');
...@@ -492,12 +506,12 @@ for my $i ( 1..5 ) { ...@@ -492,12 +506,12 @@ for my $i ( 1..5 ) {
close $file; close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; 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, 1,
[qr{^$}], [qr{^$}],
[qr/^WARNING.*further.*failures.*will.not.be.reported/s], [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"); rmtree("$tempdir/backup_corrupt2");
# induce corruption in a second file # induce corruption in a second file
...@@ -508,12 +522,12 @@ syswrite($file, '\0\0\0\0\0\0\0\0\0'); ...@@ -508,12 +522,12 @@ syswrite($file, '\0\0\0\0\0\0\0\0\0');
close $file; close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; 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, 1,
[qr{^$}], [qr{^$}],
[qr/^WARNING.*7 total checksum verification failures/s], [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"); rmtree("$tempdir/backup_corrupt3");
# do not verify checksums, should return ok # do not verify checksums, should return ok
......
...@@ -41,7 +41,8 @@ is($slot->{'slot_type'}, 'physical', 'physical replication slot was created'); ...@@ -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'); is($slot->{'restart_lsn'}, '', 'restart LSN of new slot is null');
$primary->command_ok([ 'pg_receivewal', '--slot', $slot_name, '--drop-slot' ], $primary->command_ok([ 'pg_receivewal', '--slot', $slot_name, '--drop-slot' ],
'dropping a replication 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 # Generate some WAL. Use --synchronous at the same time to add more
# code coverage. Switch to the next segment first so that subsequent # code coverage. Switch to the next segment first so that subsequent
...@@ -63,7 +64,8 @@ $primary->command_ok( ...@@ -63,7 +64,8 @@ $primary->command_ok(
# Permissions on WAL files should be default # Permissions on WAL files should be default
SKIP: 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), ok(check_mode_recursive($stream_dir, 0700, 0600),
"check stream dir permissions"); "check stream dir permissions");
......
...@@ -25,13 +25,16 @@ my $size = (stat($pg_control))[7]; ...@@ -25,13 +25,16 @@ my $size = (stat($pg_control))[7];
open my $fh, '>', $pg_control or BAIL_OUT($!); open my $fh, '>', $pg_control or BAIL_OUT($!);
binmode $fh; binmode $fh;
# fill file with zeros # fill file with zeros
print $fh pack("x[$size]"); print $fh pack("x[$size]");
close $fh; close $fh;
command_checks_all([ 'pg_controldata', $node->data_dir ], command_checks_all(
[ 'pg_controldata', $node->data_dir ],
0, 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/WARNING: invalid WAL segment size/ ],
[ qr/^$/ ], [qr/^$/],
'pg_controldata with corrupted pg_control'); 'pg_controldata with corrupted pg_control');
...@@ -63,14 +63,14 @@ command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ], ...@@ -63,14 +63,14 @@ command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ],
# Windows but we still want to do the restart test. # Windows but we still want to do the restart test.
my $logFileName = "$tempdir/data/perm-test-600.log"; my $logFileName = "$tempdir/data/perm-test-600.log";
command_ok( command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-l', $logFileName ],
[ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-l', $logFileName ],
'pg_ctl restart with server not running'); 'pg_ctl restart with server not running');
# Permissions on log file should be default # Permissions on log file should be default
SKIP: 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(-f $logFileName);
ok(check_mode_recursive("$tempdir/data", 0700, 0600)); ok(check_mode_recursive("$tempdir/data", 0700, 0600));
......
...@@ -302,8 +302,7 @@ my %pgdump_runs = ( ...@@ -302,8 +302,7 @@ my %pgdump_runs = (
# Tests which target the 'dump_test' schema, specifically. # Tests which target the 'dump_test' schema, specifically.
my %dump_test_schema_runs = ( my %dump_test_schema_runs = (
only_dump_test_schema => 1, only_dump_test_schema => 1,
test_schema_plus_blobs => 1, test_schema_plus_blobs => 1,);
);
# Tests which are considered 'full' dumps by pg_dump, but there # Tests which are considered 'full' dumps by pg_dump, but there
# are flags used to exclude specific items (ACLs, blobs, etc). # are flags used to exclude specific items (ACLs, blobs, etc).
...@@ -321,8 +320,7 @@ my %full_runs = ( ...@@ -321,8 +320,7 @@ my %full_runs = (
no_privs => 1, no_privs => 1,
pg_dumpall_dbprivs => 1, pg_dumpall_dbprivs => 1,
schema_only => 1, schema_only => 1,
with_oids => 1, with_oids => 1,);
);
# This is where the actual tests are defined. # This is where the actual tests are defined.
my %tests = ( my %tests = (
...@@ -336,10 +334,8 @@ my %tests = ( ...@@ -336,10 +334,8 @@ my %tests = (
\QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E \QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E
\QGRANT SELECT ON TABLES TO regress_dump_test_role;\E \QGRANT SELECT ON TABLES TO regress_dump_test_role;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
%dump_test_schema_runs,
section_post_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
...@@ -354,11 +350,8 @@ my %tests = ( ...@@ -354,11 +350,8 @@ my %tests = (
\QFOR ROLE regress_dump_test_role \E \QFOR ROLE regress_dump_test_role \E
\QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E \QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_post_data => 1, },
unlike => {
no_privs => 1, }, },
'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role REVOKE SELECT' 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role REVOKE SELECT'
=> { => {
...@@ -374,11 +367,8 @@ my %tests = ( ...@@ -374,11 +367,8 @@ my %tests = (
\QFOR ROLE regress_dump_test_role \E \QFOR ROLE regress_dump_test_role \E
\QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,UPDATE ON TABLES TO regress_dump_test_role;\E \QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,UPDATE ON TABLES TO regress_dump_test_role;\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_post_data => 1, },
unlike => {
no_privs => 1, }, },
'ALTER ROLE regress_dump_test_role' => { 'ALTER ROLE regress_dump_test_role' => {
regexp => qr/^ regexp => qr/^
...@@ -394,38 +384,26 @@ my %tests = ( ...@@ -394,38 +384,26 @@ my %tests = (
'ALTER COLLATION test0 OWNER TO' => { 'ALTER COLLATION test0 OWNER TO' => {
regexp => qr/^ALTER COLLATION public.test0 OWNER TO .*;/m, regexp => qr/^ALTER COLLATION public.test0 OWNER TO .*;/m,
collation => 1, collation => 1,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { %dump_test_schema_runs, no_owner => 1, }, },
section_pre_data => 1, },
unlike => {
%dump_test_schema_runs,
no_owner => 1, }, },
'ALTER FOREIGN DATA WRAPPER dummy OWNER TO' => { 'ALTER FOREIGN DATA WRAPPER dummy OWNER TO' => {
regexp => qr/^ALTER FOREIGN DATA WRAPPER dummy OWNER TO .*;/m, regexp => qr/^ALTER FOREIGN DATA WRAPPER dummy OWNER TO .*;/m,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_owner => 1, }, },
section_pre_data => 1, },
unlike => {
no_owner => 1, }, },
'ALTER SERVER s1 OWNER TO' => { 'ALTER SERVER s1 OWNER TO' => {
regexp => qr/^ALTER SERVER s1 OWNER TO .*;/m, regexp => qr/^ALTER SERVER s1 OWNER TO .*;/m,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_owner => 1, }, },
section_pre_data => 1, },
unlike => {
no_owner => 1, }, },
'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => { 'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => {
regexp => qr/^ regexp => qr/^
\QALTER FUNCTION dump_test.pltestlang_call_handler() \E \QALTER FUNCTION dump_test.pltestlang_call_handler() \E
\QOWNER TO \E \QOWNER TO \E
.*;/xm, .*;/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
...@@ -435,10 +413,8 @@ my %tests = ( ...@@ -435,10 +413,8 @@ my %tests = (
\QALTER OPERATOR FAMILY dump_test.op_family USING btree \E \QALTER OPERATOR FAMILY dump_test.op_family USING btree \E
\QOWNER TO \E \QOWNER TO \E
.*;/xm, .*;/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
...@@ -464,33 +440,25 @@ my %tests = ( ...@@ -464,33 +440,25 @@ my %tests = (
\QFUNCTION 1 (integer, integer) btint4cmp(integer,integer) ,\E\n\s+ \QFUNCTION 1 (integer, integer) btint4cmp(integer,integer) ,\E\n\s+
\QFUNCTION 2 (integer, integer) btint4sortsupport(internal);\E \QFUNCTION 2 (integer, integer) btint4sortsupport(internal);\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'ALTER OPERATOR CLASS dump_test.op_class OWNER TO' => { 'ALTER OPERATOR CLASS dump_test.op_class OWNER TO' => {
regexp => qr/^ regexp => qr/^
\QALTER OPERATOR CLASS dump_test.op_class USING btree \E \QALTER OPERATOR CLASS dump_test.op_class USING btree \E
\QOWNER TO \E \QOWNER TO \E
.*;/xm, .*;/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
'ALTER PUBLICATION pub1 OWNER TO' => { 'ALTER PUBLICATION pub1 OWNER TO' => {
regexp => qr/^ALTER PUBLICATION pub1 OWNER TO .*;/m, regexp => qr/^ALTER PUBLICATION pub1 OWNER TO .*;/m,
like => { like => { %full_runs, section_post_data => 1, },
%full_runs, unlike => { no_owner => 1, }, },
section_post_data => 1, },
unlike => {
no_owner => 1, }, },
'ALTER LARGE OBJECT ... OWNER TO' => { 'ALTER LARGE OBJECT ... OWNER TO' => {
regexp => qr/^ALTER LARGE OBJECT \d+ OWNER TO .*;/m, regexp => qr/^ALTER LARGE OBJECT \d+ OWNER TO .*;/m,
...@@ -507,18 +475,13 @@ my %tests = ( ...@@ -507,18 +475,13 @@ my %tests = (
'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => { 'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => {
regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .*;/m, regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .*;/m,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_owner => 1, }, },
section_pre_data => 1, },
unlike => {
no_owner => 1, }, },
'ALTER SCHEMA dump_test OWNER TO' => { 'ALTER SCHEMA dump_test OWNER TO' => {
regexp => qr/^ALTER SCHEMA dump_test OWNER TO .*;/m, regexp => qr/^ALTER SCHEMA dump_test OWNER TO .*;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
...@@ -529,8 +492,7 @@ my %tests = ( ...@@ -529,8 +492,7 @@ my %tests = (
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_owner => 1, }, },
no_owner => 1, }, },
'ALTER SEQUENCE test_table_col1_seq' => { 'ALTER SEQUENCE test_table_col1_seq' => {
regexp => qr/^ regexp => qr/^
...@@ -671,12 +633,9 @@ my %tests = ( ...@@ -671,12 +633,9 @@ my %tests = (
\s+\Qcolumn_name 'col1'\E\n \s+\Qcolumn_name 'col1'\E\n
\Q);\E\n \Q);\E\n
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'ALTER TABLE test_table OWNER TO' => { 'ALTER TABLE test_table OWNER TO' => {
regexp => qr/^ALTER TABLE dump_test.test_table OWNER TO .*;/m, regexp => qr/^ALTER TABLE dump_test.test_table OWNER TO .*;/m,
...@@ -694,7 +653,8 @@ my %tests = ( ...@@ -694,7 +653,8 @@ my %tests = (
create_order => 23, create_order => 23,
create_sql => 'ALTER TABLE dump_test.test_table create_sql => 'ALTER TABLE dump_test.test_table
ENABLE ROW LEVEL SECURITY;', ENABLE ROW LEVEL SECURITY;',
regexp => qr/^ALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;/m, regexp =>
qr/^ALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;/m,
like => { like => {
%full_runs, %full_runs,
%dump_test_schema_runs, %dump_test_schema_runs,
...@@ -706,70 +666,61 @@ my %tests = ( ...@@ -706,70 +666,61 @@ my %tests = (
'ALTER TABLE test_second_table OWNER TO' => { 'ALTER TABLE test_second_table OWNER TO' => {
regexp => qr/^ALTER TABLE dump_test.test_second_table OWNER TO .*;/m, regexp => qr/^ALTER TABLE dump_test.test_second_table OWNER TO .*;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
'ALTER TABLE test_third_table OWNER TO' => { 'ALTER TABLE test_third_table OWNER TO' => {
regexp => qr/^ALTER TABLE dump_test_second_schema.test_third_table OWNER TO .*;/m, regexp =>
qr/^ALTER TABLE dump_test_second_schema.test_third_table OWNER TO .*;/m,
like => { like => {
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_owner => 1, }, },
no_owner => 1, }, },
'ALTER TABLE measurement OWNER TO' => { 'ALTER TABLE measurement OWNER TO' => {
regexp => qr/^ALTER TABLE dump_test.measurement OWNER TO .*;/m, regexp => qr/^ALTER TABLE dump_test.measurement OWNER TO .*;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
'ALTER TABLE measurement_y2006m2 OWNER TO' => { 'ALTER TABLE measurement_y2006m2 OWNER TO' => {
regexp => qr/^ALTER TABLE dump_test_second_schema.measurement_y2006m2 OWNER TO .*;/m, regexp =>
qr/^ALTER TABLE dump_test_second_schema.measurement_y2006m2 OWNER TO .*;/m,
like => { like => {
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_owner => 1, }, },
no_owner => 1, }, },
'ALTER FOREIGN TABLE foreign_table OWNER TO' => { 'ALTER FOREIGN TABLE foreign_table OWNER TO' => {
regexp => qr/^ALTER FOREIGN TABLE dump_test.foreign_table OWNER TO .*;/m, regexp =>
like => { qr/^ALTER FOREIGN TABLE dump_test.foreign_table OWNER TO .*;/m,
%full_runs, like =>
%dump_test_schema_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
'ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 OWNER TO' => { 'ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 OWNER TO' => {
regexp => regexp =>
qr/^ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 OWNER TO .*;/m, qr/^ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 OWNER TO .*;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_owner => 1, }, }, no_owner => 1, }, },
'ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 OWNER TO' => { 'ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 OWNER TO' => {
regexp => regexp =>
qr/^ALTER TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 OWNER TO .*;/m, qr/^ALTER TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 OWNER TO .*;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
only_dump_test_table => 1, only_dump_test_table => 1,
...@@ -811,11 +762,13 @@ my %tests = ( ...@@ -811,11 +762,13 @@ my %tests = (
'COMMENT ON DATABASE postgres' => { 'COMMENT ON DATABASE postgres' => {
regexp => qr/^COMMENT ON DATABASE postgres IS .*;/m, regexp => qr/^COMMENT ON DATABASE postgres IS .*;/m,
# Should appear in the same tests as "CREATE DATABASE postgres" # Should appear in the same tests as "CREATE DATABASE postgres"
like => { createdb => 1, }, }, like => { createdb => 1, }, },
'COMMENT ON EXTENSION plpgsql' => { 'COMMENT ON EXTENSION plpgsql' => {
regexp => qr/^COMMENT ON EXTENSION plpgsql IS .*;/m, regexp => qr/^COMMENT ON EXTENSION plpgsql IS .*;/m,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
...@@ -823,7 +776,8 @@ my %tests = ( ...@@ -823,7 +776,8 @@ my %tests = (
create_order => 36, create_order => 36,
create_sql => 'COMMENT ON TABLE dump_test.test_table create_sql => 'COMMENT ON TABLE dump_test.test_table
IS \'comment on table\';', IS \'comment on table\';',
regexp => qr/^COMMENT ON TABLE dump_test.test_table IS 'comment on table';/m, regexp =>
qr/^COMMENT ON TABLE dump_test.test_table IS 'comment on table';/m,
like => { like => {
%full_runs, %full_runs,
%dump_test_schema_runs, %dump_test_schema_runs,
...@@ -856,12 +810,9 @@ my %tests = ( ...@@ -856,12 +810,9 @@ my %tests = (
regexp => qr/^ regexp => qr/^
\QCOMMENT ON COLUMN dump_test.composite.f1 IS 'comment on column of type';\E \QCOMMENT ON COLUMN dump_test.composite.f1 IS 'comment on column of type';\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON COLUMN dump_test.test_second_table.col1' => { 'COMMENT ON COLUMN dump_test.test_second_table.col1' => {
create_order => 63, create_order => 63,
...@@ -870,12 +821,9 @@ my %tests = ( ...@@ -870,12 +821,9 @@ my %tests = (
regexp => qr/^ regexp => qr/^
\QCOMMENT ON COLUMN dump_test.test_second_table.col1 IS 'comment on column col1';\E \QCOMMENT ON COLUMN dump_test.test_second_table.col1 IS 'comment on column col1';\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON COLUMN dump_test.test_second_table.col2' => { 'COMMENT ON COLUMN dump_test.test_second_table.col2' => {
create_order => 64, create_order => 64,
...@@ -884,12 +832,9 @@ my %tests = ( ...@@ -884,12 +832,9 @@ my %tests = (
regexp => qr/^ regexp => qr/^
\QCOMMENT ON COLUMN dump_test.test_second_table.col2 IS 'comment on column col2';\E \QCOMMENT ON COLUMN dump_test.test_second_table.col2 IS 'comment on column col2';\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON CONVERSION dump_test.test_conversion' => { 'COMMENT ON CONVERSION dump_test.test_conversion' => {
create_order => 79, create_order => 79,
...@@ -897,23 +842,18 @@ my %tests = ( ...@@ -897,23 +842,18 @@ my %tests = (
IS \'comment on test conversion\';', IS \'comment on test conversion\';',
regexp => regexp =>
qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversion';/m, qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversion';/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON COLLATION test0' => { 'COMMENT ON COLLATION test0' => {
create_order => 77, create_order => 77,
create_sql => 'COMMENT ON COLLATION test0 create_sql => 'COMMENT ON COLLATION test0
IS \'comment on test0 collation\';', IS \'comment on test0 collation\';',
regexp => regexp =>
qr/^COMMENT ON COLLATION public.test0 IS 'comment on test0 collation';/m, qr/^COMMENT ON COLLATION public.test0 IS 'comment on test0 collation';/m,
collation => 1, collation => 1,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'COMMENT ON LARGE OBJECT ...' => { 'COMMENT ON LARGE OBJECT ...' => {
create_order => 65, create_order => 65,
...@@ -943,9 +883,7 @@ qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversi ...@@ -943,9 +883,7 @@ qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversi
IS \'comment on publication\';', IS \'comment on publication\';',
regexp => regexp =>
qr/^COMMENT ON PUBLICATION pub1 IS 'comment on publication';/m, qr/^COMMENT ON PUBLICATION pub1 IS 'comment on publication';/m,
like => { like => { %full_runs, section_post_data => 1, }, },
%full_runs,
section_post_data => 1, }, },
'COMMENT ON SUBSCRIPTION sub1' => { 'COMMENT ON SUBSCRIPTION sub1' => {
create_order => 55, create_order => 55,
...@@ -953,9 +891,7 @@ qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversi ...@@ -953,9 +891,7 @@ qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversi
IS \'comment on subscription\';', IS \'comment on subscription\';',
regexp => regexp =>
qr/^COMMENT ON SUBSCRIPTION sub1 IS 'comment on subscription';/m, qr/^COMMENT ON SUBSCRIPTION sub1 IS 'comment on subscription';/m,
like => { like => { %full_runs, section_post_data => 1, }, },
%full_runs,
section_post_data => 1, }, },
'COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => { 'COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => {
create_order => 84, create_order => 84,
...@@ -964,12 +900,9 @@ qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversi ...@@ -964,12 +900,9 @@ qr/^COMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversi
IS \'comment on text search configuration\';', IS \'comment on text search configuration\';',
regexp => regexp =>
qr/^COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on text search configuration';/m, qr/^COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on text search configuration';/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => { 'COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => {
create_order => 84, create_order => 84,
...@@ -978,12 +911,9 @@ qr/^COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on t ...@@ -978,12 +911,9 @@ qr/^COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on t
IS \'comment on text search dictionary\';', IS \'comment on text search dictionary\';',
regexp => regexp =>
qr/^COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text search dictionary';/m, qr/^COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text search dictionary';/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1' => { 'COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1' => {
create_order => 84, create_order => 84,
...@@ -991,12 +921,9 @@ qr/^COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text ...@@ -991,12 +921,9 @@ qr/^COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text
IS \'comment on text search parser\';', IS \'comment on text search parser\';',
regexp => regexp =>
qr/^COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text search parser';/m, qr/^COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text search parser';/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => { 'COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => {
create_order => 84, create_order => 84,
...@@ -1004,61 +931,49 @@ qr/^COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text sear ...@@ -1004,61 +931,49 @@ qr/^COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text sear
IS \'comment on text search template\';', IS \'comment on text search template\';',
regexp => regexp =>
qr/^COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text search template';/m, qr/^COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text search template';/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TYPE dump_test.planets - ENUM' => { 'COMMENT ON TYPE dump_test.planets - ENUM' => {
create_order => 68, create_order => 68,
create_sql => 'COMMENT ON TYPE dump_test.planets create_sql => 'COMMENT ON TYPE dump_test.planets
IS \'comment on enum type\';', IS \'comment on enum type\';',
regexp => qr/^COMMENT ON TYPE dump_test.planets IS 'comment on enum type';/m, regexp =>
like => { qr/^COMMENT ON TYPE dump_test.planets IS 'comment on enum type';/m,
%full_runs, like =>
%dump_test_schema_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
section_pre_data => 1, }, unlike => { exclude_dump_test_schema => 1, }, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TYPE dump_test.textrange - RANGE' => { 'COMMENT ON TYPE dump_test.textrange - RANGE' => {
create_order => 69, create_order => 69,
create_sql => 'COMMENT ON TYPE dump_test.textrange create_sql => 'COMMENT ON TYPE dump_test.textrange
IS \'comment on range type\';', IS \'comment on range type\';',
regexp => qr/^COMMENT ON TYPE dump_test.textrange IS 'comment on range type';/m, regexp =>
like => { qr/^COMMENT ON TYPE dump_test.textrange IS 'comment on range type';/m,
%full_runs, like =>
%dump_test_schema_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
section_pre_data => 1, }, unlike => { exclude_dump_test_schema => 1, }, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TYPE dump_test.int42 - Regular' => { 'COMMENT ON TYPE dump_test.int42 - Regular' => {
create_order => 70, create_order => 70,
create_sql => 'COMMENT ON TYPE dump_test.int42 create_sql => 'COMMENT ON TYPE dump_test.int42
IS \'comment on regular type\';', IS \'comment on regular type\';',
regexp => qr/^COMMENT ON TYPE dump_test.int42 IS 'comment on regular type';/m, regexp =>
like => { qr/^COMMENT ON TYPE dump_test.int42 IS 'comment on regular type';/m,
%full_runs, like =>
%dump_test_schema_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
section_pre_data => 1, }, unlike => { exclude_dump_test_schema => 1, }, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COMMENT ON TYPE dump_test.undefined - Undefined' => { 'COMMENT ON TYPE dump_test.undefined - Undefined' => {
create_order => 71, create_order => 71,
create_sql => 'COMMENT ON TYPE dump_test.undefined create_sql => 'COMMENT ON TYPE dump_test.undefined
IS \'comment on undefined type\';', IS \'comment on undefined type\';',
regexp => regexp =>
qr/^COMMENT ON TYPE dump_test.undefined IS 'comment on undefined type';/m, qr/^COMMENT ON TYPE dump_test.undefined IS 'comment on undefined type';/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'COPY test_table' => { 'COPY test_table' => {
create_order => 4, create_order => 4,
...@@ -1232,7 +1147,8 @@ qr/^COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text s ...@@ -1232,7 +1147,8 @@ qr/^COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text s
like => { column_inserts => 1, }, }, like => { column_inserts => 1, }, },
'INSERT INTO test_fourth_table' => { 'INSERT INTO test_fourth_table' => {
regexp => qr/^\QINSERT INTO dump_test.test_fourth_table DEFAULT VALUES;\E/m, regexp =>
qr/^\QINSERT INTO dump_test.test_fourth_table DEFAULT VALUES;\E/m,
like => { column_inserts => 1, }, }, like => { column_inserts => 1, }, },
'INSERT INTO test_fifth_table' => { 'INSERT INTO test_fifth_table' => {
...@@ -1260,9 +1176,7 @@ qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM V ...@@ -1260,9 +1176,7 @@ qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM V
'CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler;', 'CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler;',
regexp => regexp =>
qr/CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler;/m, qr/CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler;/m,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE COLLATION test0 FROM "C"' => { 'CREATE COLLATION test0 FROM "C"' => {
create_order => 76, create_order => 76,
...@@ -1270,9 +1184,7 @@ qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM V ...@@ -1270,9 +1184,7 @@ qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM V
regexp => qr/^ regexp => qr/^
\QCREATE COLLATION public.test0 (provider = libc, locale = 'C');\E/xm, \QCREATE COLLATION public.test0 (provider = libc, locale = 'C');\E/xm,
collation => 1, collation => 1,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE CAST FOR timestamptz' => { 'CREATE CAST FOR timestamptz' => {
create_order => 51, create_order => 51,
...@@ -1280,9 +1192,7 @@ qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM V ...@@ -1280,9 +1192,7 @@ qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM V
'CREATE CAST (timestamptz AS interval) WITH FUNCTION age(timestamptz) AS ASSIGNMENT;', 'CREATE CAST (timestamptz AS interval) WITH FUNCTION age(timestamptz) AS ASSIGNMENT;',
regexp => regexp =>
qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog\.age\(timestamp with time zone\) AS ASSIGNMENT;/m, qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog\.age\(timestamp with time zone\) AS ASSIGNMENT;/m,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE DATABASE postgres' => { 'CREATE DATABASE postgres' => {
regexp => qr/^ regexp => qr/^
...@@ -1302,6 +1212,7 @@ qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog ...@@ -1302,6 +1212,7 @@ qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E \QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E
/xm, /xm,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
...@@ -1328,8 +1239,7 @@ qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog ...@@ -1328,8 +1239,7 @@ qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog
%dump_test_schema_runs, %dump_test_schema_runs,
exclude_test_table => 1, exclude_test_table => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { exclude_dump_test_schema => 1, }, },
exclude_dump_test_schema => 1, }, },
'CREATE CONVERSION dump_test.test_conversion' => { 'CREATE CONVERSION dump_test.test_conversion' => {
create_order => 78, create_order => 78,
...@@ -1337,12 +1247,9 @@ qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog ...@@ -1337,12 +1247,9 @@ qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog
'CREATE DEFAULT CONVERSION dump_test.test_conversion FOR \'LATIN1\' TO \'UTF8\' FROM iso8859_1_to_utf8;', 'CREATE DEFAULT CONVERSION dump_test.test_conversion FOR \'LATIN1\' TO \'UTF8\' FROM iso8859_1_to_utf8;',
regexp => regexp =>
qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;\E/xm, qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;\E/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE DOMAIN dump_test.us_postal_code' => { 'CREATE DOMAIN dump_test.us_postal_code' => {
create_order => 29, create_order => 29,
...@@ -1358,12 +1265,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1358,12 +1265,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\$\Q'::text) OR (VALUE ~ '^\d{5}-\d{4}\E\$ \$\Q'::text) OR (VALUE ~ '^\d{5}-\d{4}\E\$
\Q'::text)));\E \Q'::text)));\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE FUNCTION dump_test.pltestlang_call_handler' => { 'CREATE FUNCTION dump_test.pltestlang_call_handler' => {
create_order => 17, create_order => 17,
...@@ -1377,12 +1281,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1377,12 +1281,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+AS\ \'\$ \n\s+AS\ \'\$
\Qlibdir\/plpgsql', 'plpgsql_call_handler';\E \Qlibdir\/plpgsql', 'plpgsql_call_handler';\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE FUNCTION dump_test.trigger_func' => { 'CREATE FUNCTION dump_test.trigger_func' => {
create_order => 30, create_order => 30,
...@@ -1395,12 +1296,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1395,12 +1296,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+AS\ \$\$ \n\s+AS\ \$\$
\Q BEGIN RETURN NULL; END;\E \Q BEGIN RETURN NULL; END;\E
\$\$;/xm, \$\$;/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE FUNCTION dump_test.event_trigger_func' => { 'CREATE FUNCTION dump_test.event_trigger_func' => {
create_order => 32, create_order => 32,
...@@ -1413,12 +1311,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1413,12 +1311,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+AS\ \$\$ \n\s+AS\ \$\$
\Q BEGIN RETURN; END;\E \Q BEGIN RETURN; END;\E
\$\$;/xm, \$\$;/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE OPERATOR FAMILY dump_test.op_family' => { 'CREATE OPERATOR FAMILY dump_test.op_family' => {
create_order => 73, create_order => 73,
...@@ -1427,12 +1322,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1427,12 +1322,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
regexp => qr/^ regexp => qr/^
\QCREATE OPERATOR FAMILY dump_test.op_family USING btree;\E \QCREATE OPERATOR FAMILY dump_test.op_family USING btree;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE OPERATOR CLASS dump_test.op_class' => { 'CREATE OPERATOR CLASS dump_test.op_class' => {
create_order => 74, create_order => 74,
...@@ -1457,12 +1349,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1457,12 +1349,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\QFUNCTION 1 (bigint, bigint) btint8cmp(bigint,bigint) ,\E\n\s+ \QFUNCTION 1 (bigint, bigint) btint8cmp(bigint,bigint) ,\E\n\s+
\QFUNCTION 2 (bigint, bigint) btint8sortsupport(internal);\E \QFUNCTION 2 (bigint, bigint) btint8sortsupport(internal);\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE EVENT TRIGGER test_event_trigger' => { 'CREATE EVENT TRIGGER test_event_trigger' => {
create_order => 33, create_order => 33,
...@@ -1474,9 +1363,7 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1474,9 +1363,7 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\QON ddl_command_start\E \QON ddl_command_start\E
\n\s+\QEXECUTE PROCEDURE dump_test.event_trigger_func();\E \n\s+\QEXECUTE PROCEDURE dump_test.event_trigger_func();\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, }, },
%full_runs,
section_post_data => 1, }, },
'CREATE TRIGGER test_trigger' => { 'CREATE TRIGGER test_trigger' => {
create_order => 31, create_order => 31,
...@@ -1508,10 +1395,8 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1508,10 +1395,8 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+'earth', \n\s+'earth',
\n\s+'mars' \n\s+'mars'
\n\);/xm, \n\);/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
binary_upgrade => 1, binary_upgrade => 1,
exclude_dump_test_schema => 1, }, }, exclude_dump_test_schema => 1, }, },
...@@ -1537,23 +1422,17 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1537,23 +1422,17 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+\Qsubtype = text,\E \n\s+\Qsubtype = text,\E
\n\s+\Qcollation = pg_catalog."C"\E \n\s+\Qcollation = pg_catalog."C"\E
\n\);/xm, \n\);/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TYPE dump_test.int42' => { 'CREATE TYPE dump_test.int42' => {
create_order => 39, create_order => 39,
create_sql => 'CREATE TYPE dump_test.int42;', create_sql => 'CREATE TYPE dump_test.int42;',
regexp => qr/^CREATE TYPE dump_test.int42;/m, regexp => qr/^CREATE TYPE dump_test.int42;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => { 'CREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => {
create_order => 80, create_order => 80,
...@@ -1562,12 +1441,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1562,12 +1441,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
regexp => qr/^ regexp => qr/^
\QCREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 (\E\n \QCREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 (\E\n
\s+\QPARSER = pg_catalog."default" );\E/xm, \s+\QPARSER = pg_catalog."default" );\E/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 ...' => { 'ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 ...' => {
regexp => qr/^ regexp => qr/^
...@@ -1629,12 +1505,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1629,12 +1505,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\s+\QADD MAPPING FOR uint WITH simple;\E\n \s+\QADD MAPPING FOR uint WITH simple;\E\n
\n \n
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => { 'CREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => {
create_order => 81, create_order => 81,
...@@ -1643,12 +1516,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1643,12 +1516,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
regexp => qr/^ regexp => qr/^
\QCREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 (\E\n \QCREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 (\E\n
\s+\QLEXIZE = dsimple_lexize );\E/xm, \s+\QLEXIZE = dsimple_lexize );\E/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TEXT SEARCH PARSER dump_test.alt_ts_prs1' => { 'CREATE TEXT SEARCH PARSER dump_test.alt_ts_prs1' => {
create_order => 82, create_order => 82,
...@@ -1661,12 +1531,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1661,12 +1531,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\s+\QEND = prsd_end,\E\n \s+\QEND = prsd_end,\E\n
\s+\QLEXTYPES = prsd_lextype );\E\n \s+\QLEXTYPES = prsd_lextype );\E\n
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => { 'CREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => {
create_order => 83, create_order => 83,
...@@ -1676,12 +1543,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1676,12 +1543,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\QCREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 (\E\n \QCREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 (\E\n
\s+\QTEMPLATE = pg_catalog.simple );\E\n \s+\QTEMPLATE = pg_catalog.simple );\E\n
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE FUNCTION dump_test.int42_in' => { 'CREATE FUNCTION dump_test.int42_in' => {
create_order => 40, create_order => 40,
...@@ -1693,12 +1557,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1693,12 +1557,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+\QLANGUAGE internal IMMUTABLE STRICT\E \n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
\n\s+AS\ \$\$int4in\$\$; \n\s+AS\ \$\$int4in\$\$;
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE FUNCTION dump_test.int42_out' => { 'CREATE FUNCTION dump_test.int42_out' => {
create_order => 41, create_order => 41,
...@@ -1706,16 +1567,13 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1706,16 +1567,13 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
RETURNS cstring AS \'int4out\' RETURNS cstring AS \'int4out\'
LANGUAGE internal STRICT IMMUTABLE;', LANGUAGE internal STRICT IMMUTABLE;',
regexp => qr/^ regexp => qr/^
\QCREATE FUNCTION dump_test.int42_out(dump_test.int42) RETURNS cstring\E \QCREATE FUNCTION dump_test.int42_out(dump_test.int42) RETURNS cstring\E
\n\s+\QLANGUAGE internal IMMUTABLE STRICT\E \n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
\n\s+AS\ \$\$int4out\$\$; \n\s+AS\ \$\$int4out\$\$;
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE PROCEDURE dump_test.ptest1' => { 'CREATE PROCEDURE dump_test.ptest1' => {
create_order => 41, create_order => 41,
...@@ -1726,12 +1584,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1726,12 +1584,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+\QLANGUAGE sql\E \n\s+\QLANGUAGE sql\E
\n\s+AS\ \$\$\Q INSERT INTO dump_test.test_table (col1) VALUES (a) \E\$\$; \n\s+AS\ \$\$\Q INSERT INTO dump_test.test_table (col1) VALUES (a) \E\$\$;
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TYPE dump_test.int42 populated' => { 'CREATE TYPE dump_test.int42 populated' => {
create_order => 42, create_order => 42,
...@@ -1752,12 +1607,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1752,12 +1607,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+\QSTORAGE = plain,\E \n\s+\QSTORAGE = plain,\E
\n\s+PASSEDBYVALUE\n\); \n\s+PASSEDBYVALUE\n\);
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TYPE dump_test.composite' => { 'CREATE TYPE dump_test.composite' => {
create_order => 43, create_order => 43,
...@@ -1771,39 +1623,29 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1771,39 +1623,29 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\n\s+\Qf2 dump_test.int42\E \n\s+\Qf2 dump_test.int42\E
\n\); \n\);
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TYPE dump_test.undefined' => { 'CREATE TYPE dump_test.undefined' => {
create_order => 39, create_order => 39,
create_sql => 'CREATE TYPE dump_test.undefined;', create_sql => 'CREATE TYPE dump_test.undefined;',
regexp => qr/^CREATE TYPE dump_test.undefined;/m, regexp => qr/^CREATE TYPE dump_test.undefined;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE FOREIGN DATA WRAPPER dummy' => { 'CREATE FOREIGN DATA WRAPPER dummy' => {
create_order => 35, create_order => 35,
create_sql => 'CREATE FOREIGN DATA WRAPPER dummy;', create_sql => 'CREATE FOREIGN DATA WRAPPER dummy;',
regexp => qr/CREATE FOREIGN DATA WRAPPER dummy;/m, regexp => qr/CREATE FOREIGN DATA WRAPPER dummy;/m,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy' => { 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy' => {
create_order => 36, create_order => 36,
create_sql => 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;', create_sql => 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;',
regexp => qr/CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;/m, regexp => qr/CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;/m,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE FOREIGN TABLE dump_test.foreign_table SERVER s1' => { 'CREATE FOREIGN TABLE dump_test.foreign_table SERVER s1' => {
create_order => 88, create_order => 88,
...@@ -1819,12 +1661,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1819,12 +1661,9 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
\s+\Qschema_name 'x1'\E\n \s+\Qschema_name 'x1'\E\n
\Q);\E\n \Q);\E\n
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1' => { 'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1' => {
create_order => 86, create_order => 86,
...@@ -1832,9 +1671,7 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1832,9 +1671,7 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1;', 'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1;',
regexp => regexp =>
qr/CREATE USER MAPPING FOR regress_dump_test_role SERVER s1;/m, qr/CREATE USER MAPPING FOR regress_dump_test_role SERVER s1;/m,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE TRANSFORM FOR int' => { 'CREATE TRANSFORM FOR int' => {
create_order => 34, create_order => 34,
...@@ -1842,9 +1679,7 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' ...@@ -1842,9 +1679,7 @@ qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8'
'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION varchar_transform(internal), TO SQL WITH FUNCTION int4recv(internal));', 'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION varchar_transform(internal), TO SQL WITH FUNCTION int4recv(internal));',
regexp => regexp =>
qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog\.varchar_transform\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m, qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog\.varchar_transform\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
like => { like => { %full_runs, section_pre_data => 1, }, },
%full_runs,
section_pre_data => 1, }, },
'CREATE LANGUAGE pltestlang' => { 'CREATE LANGUAGE pltestlang' => {
create_order => 18, create_order => 18,
...@@ -1854,11 +1689,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -1854,11 +1689,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\QCREATE PROCEDURAL LANGUAGE pltestlang \E \QCREATE PROCEDURAL LANGUAGE pltestlang \E
\QHANDLER dump_test.pltestlang_call_handler;\E \QHANDLER dump_test.pltestlang_call_handler;\E
/xm, /xm,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE MATERIALIZED VIEW matview' => { 'CREATE MATERIALIZED VIEW matview' => {
create_order => 20, create_order => 20,
...@@ -1870,12 +1702,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -1870,12 +1702,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\QFROM dump_test.test_table\E \n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E \n\s+\QWITH NO DATA;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE MATERIALIZED VIEW matview_second' => { 'CREATE MATERIALIZED VIEW matview_second' => {
create_order => 21, create_order => 21,
...@@ -1888,12 +1717,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -1888,12 +1717,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\QFROM dump_test.matview\E \n\s+\QFROM dump_test.matview\E
\n\s+\QWITH NO DATA;\E \n\s+\QWITH NO DATA;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE MATERIALIZED VIEW matview_third' => { 'CREATE MATERIALIZED VIEW matview_third' => {
create_order => 58, create_order => 58,
...@@ -1906,12 +1732,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -1906,12 +1732,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\QFROM dump_test.matview_second\E \n\s+\QFROM dump_test.matview_second\E
\n\s+\QWITH NO DATA;\E \n\s+\QWITH NO DATA;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE MATERIALIZED VIEW matview_fourth' => { 'CREATE MATERIALIZED VIEW matview_fourth' => {
create_order => 59, create_order => 59,
...@@ -1924,12 +1747,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -1924,12 +1747,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\QFROM dump_test.matview_third\E \n\s+\QFROM dump_test.matview_third\E
\n\s+\QWITH NO DATA;\E \n\s+\QWITH NO DATA;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE POLICY p1 ON test_table' => { 'CREATE POLICY p1 ON test_table' => {
create_order => 22, create_order => 22,
...@@ -2040,9 +1860,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2040,9 +1860,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QCREATE PUBLICATION pub1 WITH (publish = 'insert, update, delete, truncate');\E \QCREATE PUBLICATION pub1 WITH (publish = 'insert, update, delete, truncate');\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, }, },
%full_runs,
section_post_data => 1, }, },
'CREATE PUBLICATION pub2' => { 'CREATE PUBLICATION pub2' => {
create_order => 50, create_order => 50,
...@@ -2052,9 +1870,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2052,9 +1870,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish = '');\E \QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish = '');\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, }, },
%full_runs,
section_post_data => 1, }, },
'CREATE SUBSCRIPTION sub1' => { 'CREATE SUBSCRIPTION sub1' => {
create_order => 50, create_order => 50,
...@@ -2064,9 +1880,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2064,9 +1880,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub1');\E \QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub1');\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, }, },
%full_runs,
section_post_data => 1, }, },
'ALTER PUBLICATION pub1 ADD TABLE test_table' => { 'ALTER PUBLICATION pub1 ADD TABLE test_table' => {
create_order => 51, create_order => 51,
...@@ -2075,9 +1889,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2075,9 +1889,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_table;\E \QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_table;\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, },
%full_runs,
section_post_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
exclude_test_table => 1, }, }, exclude_test_table => 1, }, },
...@@ -2089,14 +1901,12 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2089,14 +1901,12 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_second_table;\E \QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_second_table;\E
/xm, /xm,
like => { like => { %full_runs, section_post_data => 1, },
%full_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE SCHEMA public' => { 'CREATE SCHEMA public' => {
regexp => qr/^CREATE SCHEMA public;/m, regexp => qr/^CREATE SCHEMA public;/m,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
...@@ -2104,12 +1914,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2104,12 +1914,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
create_order => 2, create_order => 2,
create_sql => 'CREATE SCHEMA dump_test;', create_sql => 'CREATE SCHEMA dump_test;',
regexp => qr/^CREATE SCHEMA dump_test;/m, regexp => qr/^CREATE SCHEMA dump_test;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE SCHEMA dump_test_second_schema' => { 'CREATE SCHEMA dump_test_second_schema' => {
create_order => 9, create_order => 9,
...@@ -2157,12 +1964,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2157,12 +1964,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\Qcol1 integer NOT NULL\E \n\s+\Qcol1 integer NOT NULL\E
\n\); \n\);
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TABLE test_second_table' => { 'CREATE TABLE test_second_table' => {
create_order => 6, create_order => 6,
...@@ -2176,12 +1980,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2176,12 +1980,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\Qcol2 text\E \n\s+\Qcol2 text\E
\n\); \n\);
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE UNLOGGED TABLE test_third_table WITH OIDS' => { 'CREATE UNLOGGED TABLE test_third_table WITH OIDS' => {
create_order => 11, create_order => 11,
...@@ -2204,6 +2005,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2204,6 +2005,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => {
# FIXME figure out why/how binary upgrade drops OIDs. # FIXME figure out why/how binary upgrade drops OIDs.
binary_upgrade => 1, }, }, binary_upgrade => 1, }, },
...@@ -2226,10 +2028,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2226,10 +2028,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\)\n \)\n
\QPARTITION BY RANGE (logdate);\E\n \QPARTITION BY RANGE (logdate);\E\n
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
binary_upgrade => 1, binary_upgrade => 1,
exclude_dump_test_schema => 1, }, }, exclude_dump_test_schema => 1, }, },
...@@ -2250,8 +2050,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2250,8 +2050,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { binary_upgrade => 1, }, },
binary_upgrade => 1, }, },
'CREATE TABLE test_fourth_table_zero_col' => { 'CREATE TABLE test_fourth_table_zero_col' => {
create_order => 6, create_order => 6,
...@@ -2261,12 +2060,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2261,12 +2060,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\QCREATE TABLE dump_test.test_fourth_table (\E \QCREATE TABLE dump_test.test_fourth_table (\E
\n\); \n\);
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TABLE test_fifth_table' => { 'CREATE TABLE test_fifth_table' => {
create_order => 53, create_order => 53,
...@@ -2286,12 +2082,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2286,12 +2082,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\Qcol5 double precision\E \n\s+\Qcol5 double precision\E
\n\); \n\);
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE TABLE test_table_identity' => { 'CREATE TABLE test_table_identity' => {
create_order => 3, create_order => 3,
...@@ -2314,12 +2107,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2314,12 +2107,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\s+\QCACHE 1\E\n \s+\QCACHE 1\E\n
\); \);
/xms, /xms,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE STATISTICS extended_stats_no_options' => { 'CREATE STATISTICS extended_stats_no_options' => {
create_order => 97, create_order => 97,
...@@ -2328,12 +2118,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2328,12 +2118,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QCREATE STATISTICS dump_test.test_ext_stats_no_options ON col1, col2 FROM dump_test.test_fifth_table;\E \QCREATE STATISTICS dump_test.test_ext_stats_no_options ON col1, col2 FROM dump_test.test_fifth_table;\E
/xms, /xms,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE STATISTICS extended_stats_options' => { 'CREATE STATISTICS extended_stats_options' => {
create_order => 97, create_order => 97,
...@@ -2342,12 +2129,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2342,12 +2129,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QCREATE STATISTICS dump_test.test_ext_stats_opts (ndistinct) ON col1, col2 FROM dump_test.test_fifth_table;\E \QCREATE STATISTICS dump_test.test_ext_stats_opts (ndistinct) ON col1, col2 FROM dump_test.test_fifth_table;\E
/xms, /xms,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE SEQUENCE test_table_col1_seq' => { 'CREATE SEQUENCE test_table_col1_seq' => {
regexp => qr/^ regexp => qr/^
...@@ -2364,8 +2148,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2364,8 +2148,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
%dump_test_schema_runs, %dump_test_schema_runs,
only_dump_test_table => 1, only_dump_test_table => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { exclude_dump_test_schema => 1, }, },
exclude_dump_test_schema => 1, }, },
'CREATE SEQUENCE test_third_table_col1_seq' => { 'CREATE SEQUENCE test_third_table_col1_seq' => {
regexp => qr/^ regexp => qr/^
...@@ -2397,7 +2180,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2397,7 +2180,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
'CREATE INDEX ON ONLY measurement' => { 'CREATE INDEX ON ONLY measurement' => {
create_order => 92, create_order => 92,
create_sql => 'CREATE INDEX ON dump_test.measurement (city_id, logdate);', create_sql =>
'CREATE INDEX ON dump_test.measurement (city_id, logdate);',
regexp => qr/^ regexp => qr/^
\QCREATE INDEX measurement_city_id_logdate_idx ON ONLY dump_test.measurement USING\E \QCREATE INDEX measurement_city_id_logdate_idx ON ONLY dump_test.measurement USING\E
/xm, /xm,
...@@ -2430,17 +2214,15 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2430,17 +2214,15 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
all_runs => 1, all_runs => 1,
catch_all => 'CREATE ... commands', catch_all => 'CREATE ... commands',
create_order => 93, create_order => 93,
create_sql => 'ALTER TABLE dump_test.measurement ADD PRIMARY KEY (city_id, logdate);', create_sql =>
'ALTER TABLE dump_test.measurement ADD PRIMARY KEY (city_id, logdate);',
regexp => qr/^ regexp => qr/^
\QALTER TABLE ONLY dump_test.measurement\E \n^\s+ \QALTER TABLE ONLY dump_test.measurement\E \n^\s+
\QADD CONSTRAINT measurement_pkey PRIMARY KEY (city_id, logdate);\E \QADD CONSTRAINT measurement_pkey PRIMARY KEY (city_id, logdate);\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'CREATE INDEX ... ON measurement_y2006_m2' => { 'CREATE INDEX ... ON measurement_y2006_m2' => {
regexp => qr/^ regexp => qr/^
...@@ -2501,12 +2283,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2501,12 +2283,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
\n\s+\QSELECT test_table.col1\E \n\s+\QSELECT test_table.col1\E
\n\s+\QFROM dump_test.test_table\E \n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH LOCAL CHECK OPTION;\E/xm, \n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
'ALTER VIEW test_view SET DEFAULT' => { 'ALTER VIEW test_view SET DEFAULT' => {
create_order => 62, create_order => 62,
...@@ -2514,12 +2293,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2514,12 +2293,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
'ALTER VIEW dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;', 'ALTER VIEW dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;',
regexp => qr/^ regexp => qr/^
\QALTER TABLE ONLY dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;\E/xm, \QALTER TABLE ONLY dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;\E/xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs, unlike => { exclude_dump_test_schema => 1, }, },
section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1, }, },
# FIXME # FIXME
'DROP SCHEMA public (for testing without public schema)' => { 'DROP SCHEMA public (for testing without public schema)' => {
...@@ -2531,16 +2307,19 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2531,16 +2307,19 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
'DROP SCHEMA public' => { 'DROP SCHEMA public' => {
regexp => qr/^DROP SCHEMA public;/m, regexp => qr/^DROP SCHEMA public;/m,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
'DROP SCHEMA IF EXISTS public' => { 'DROP SCHEMA IF EXISTS public' => {
regexp => qr/^DROP SCHEMA IF EXISTS public;/m, regexp => qr/^DROP SCHEMA IF EXISTS public;/m,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
'DROP EXTENSION plpgsql' => { 'DROP EXTENSION plpgsql' => {
regexp => qr/^DROP EXTENSION plpgsql;/m, regexp => qr/^DROP EXTENSION plpgsql;/m,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
...@@ -2578,6 +2357,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2578,6 +2357,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
'DROP EXTENSION IF EXISTS plpgsql' => { 'DROP EXTENSION IF EXISTS plpgsql' => {
regexp => qr/^DROP EXTENSION IF EXISTS plpgsql;/m, regexp => qr/^DROP EXTENSION IF EXISTS plpgsql;/m,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
...@@ -2623,6 +2403,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2623,6 +2403,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QDROP ROLE pg_\E.*; \QDROP ROLE pg_\E.*;
/xm, /xm,
# this shouldn't ever get emitted anywhere # this shouldn't ever get emitted anywhere
like => {}, }, like => {}, },
...@@ -2637,8 +2418,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2637,8 +2418,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT USAGE ON FOREIGN DATA WRAPPER dummy' => { 'GRANT USAGE ON FOREIGN DATA WRAPPER dummy' => {
create_order => 85, create_order => 85,
...@@ -2647,11 +2427,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2647,11 +2427,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON FOREIGN DATA WRAPPER dummy TO regress_dump_test_role;\E \QGRANT ALL ON FOREIGN DATA WRAPPER dummy TO regress_dump_test_role;\E
/xm, /xm,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
'GRANT USAGE ON FOREIGN SERVER s1' => { 'GRANT USAGE ON FOREIGN SERVER s1' => {
create_order => 85, create_order => 85,
...@@ -2660,11 +2437,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2660,11 +2437,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON FOREIGN SERVER s1 TO regress_dump_test_role;\E \QGRANT ALL ON FOREIGN SERVER s1 TO regress_dump_test_role;\E
/xm, /xm,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
'GRANT USAGE ON DOMAIN dump_test.us_postal_code' => { 'GRANT USAGE ON DOMAIN dump_test.us_postal_code' => {
create_order => 72, create_order => 72,
...@@ -2673,10 +2447,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2673,10 +2447,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON TYPE dump_test.us_postal_code TO regress_dump_test_role;\E \QGRANT ALL ON TYPE dump_test.us_postal_code TO regress_dump_test_role;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
...@@ -2688,10 +2460,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2688,10 +2460,8 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON TYPE dump_test.int42 TO regress_dump_test_role;\E \QGRANT ALL ON TYPE dump_test.int42 TO regress_dump_test_role;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
...@@ -2703,24 +2473,21 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2703,24 +2473,21 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON TYPE dump_test.planets TO regress_dump_test_role;\E \QGRANT ALL ON TYPE dump_test.planets TO regress_dump_test_role;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
'GRANT USAGE ON TYPE dump_test.textrange - RANGE' => { 'GRANT USAGE ON TYPE dump_test.textrange - RANGE' => {
create_order => 67, create_order => 67,
create_sql => 'GRANT USAGE ON TYPE dump_test.textrange TO regress_dump_test_role;', create_sql =>
'GRANT USAGE ON TYPE dump_test.textrange TO regress_dump_test_role;',
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON TYPE dump_test.textrange TO regress_dump_test_role;\E \QGRANT ALL ON TYPE dump_test.textrange TO regress_dump_test_role;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
...@@ -2739,7 +2506,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog ...@@ -2739,7 +2506,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
create_sql => 'GRANT SELECT ON TABLE dump_test.test_table create_sql => 'GRANT SELECT ON TABLE dump_test.test_table
TO regress_dump_test_role;', TO regress_dump_test_role;',
regexp => regexp =>
qr/^GRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;/m, qr/^GRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;/m,
like => { like => {
%full_runs, %full_runs,
%dump_test_schema_runs, %dump_test_schema_runs,
...@@ -2761,8 +2528,7 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2761,8 +2528,7 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT ALL ON SEQUENCE test_third_table_col1_seq' => { 'GRANT ALL ON SEQUENCE test_third_table_col1_seq' => {
create_order => 28, create_order => 28,
...@@ -2776,8 +2542,7 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2776,8 +2542,7 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT SELECT ON TABLE measurement' => { 'GRANT SELECT ON TABLE measurement' => {
create_order => 91, create_order => 91,
...@@ -2785,11 +2550,9 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2785,11 +2550,9 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
TABLE dump_test.measurement TABLE dump_test.measurement
TO regress_dump_test_role;', TO regress_dump_test_role;',
regexp => regexp =>
qr/^GRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;/m, qr/^GRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
...@@ -2799,13 +2562,13 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2799,13 +2562,13 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
create_sql => 'GRANT SELECT ON create_sql => 'GRANT SELECT ON
TABLE dump_test_second_schema.measurement_y2006m2 TABLE dump_test_second_schema.measurement_y2006m2
TO regress_dump_test_role;', TO regress_dump_test_role;',
regexp => qr/^GRANT SELECT ON TABLE dump_test_second_schema.measurement_y2006m2 TO regress_dump_test_role;/m, regexp =>
qr/^GRANT SELECT ON TABLE dump_test_second_schema.measurement_y2006m2 TO regress_dump_test_role;/m,
like => { like => {
%full_runs, %full_runs,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT ALL ON LARGE OBJECT ...' => { 'GRANT ALL ON LARGE OBJECT ...' => {
create_order => 60, create_order => 60,
...@@ -2839,10 +2602,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2839,10 +2602,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
regexp => qr/^ regexp => qr/^
\QGRANT INSERT(col1) ON TABLE dump_test.test_second_table TO regress_dump_test_role;\E \QGRANT INSERT(col1) ON TABLE dump_test.test_second_table TO regress_dump_test_role;\E
/xm, /xm,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
%dump_test_schema_runs,
section_pre_data => 1, },
unlike => { unlike => {
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
no_privs => 1, }, }, no_privs => 1, }, },
...@@ -2854,11 +2615,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2854,11 +2615,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
regexp => qr/^ regexp => qr/^
\QGRANT ALL ON FUNCTION pg_catalog.pg_sleep(double precision) TO regress_dump_test_role;\E \QGRANT ALL ON FUNCTION pg_catalog.pg_sleep(double precision) TO regress_dump_test_role;\E
/xm, /xm,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
'GRANT SELECT (proname ...) ON TABLE pg_proc TO public' => { 'GRANT SELECT (proname ...) ON TABLE pg_proc TO public' => {
create_order => 46, create_order => 46,
...@@ -2925,26 +2683,22 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2925,26 +2683,22 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
\QGRANT SELECT(probin) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.* \QGRANT SELECT(probin) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proconfig) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.* \QGRANT SELECT(proconfig) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proacl) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E/xms, \QGRANT SELECT(proacl) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E/xms,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
'GRANT USAGE ON SCHEMA public TO public' => { 'GRANT USAGE ON SCHEMA public TO public' => {
regexp => qr/^ regexp => qr/^
\Q--\E\n\n \Q--\E\n\n
\QGRANT USAGE ON SCHEMA public TO PUBLIC;\E \QGRANT USAGE ON SCHEMA public TO PUBLIC;\E
/xm, /xm,
# this shouldn't ever get emitted anymore # this shouldn't ever get emitted anymore
like => {}, }, like => {}, },
'REFRESH MATERIALIZED VIEW matview' => { 'REFRESH MATERIALIZED VIEW matview' => {
regexp => qr/^REFRESH MATERIALIZED VIEW dump_test.matview;/m, regexp => qr/^REFRESH MATERIALIZED VIEW dump_test.matview;/m,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
%dump_test_schema_runs,
section_post_data => 1, },
unlike => { unlike => {
binary_upgrade => 1, binary_upgrade => 1,
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
...@@ -2956,10 +2710,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2956,10 +2710,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
\n.* \n.*
\QREFRESH MATERIALIZED VIEW dump_test.matview_second;\E \QREFRESH MATERIALIZED VIEW dump_test.matview_second;\E
/xms, /xms,
like => { like =>
%full_runs, { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
%dump_test_schema_runs,
section_post_data => 1, },
unlike => { unlike => {
binary_upgrade => 1, binary_upgrade => 1,
exclude_dump_test_schema => 1, exclude_dump_test_schema => 1,
...@@ -2996,21 +2748,16 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -2996,21 +2748,16 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
regexp => qr/^ regexp => qr/^
\QREVOKE ALL ON FUNCTION pg_catalog.pg_sleep(double precision) FROM PUBLIC;\E \QREVOKE ALL ON FUNCTION pg_catalog.pg_sleep(double precision) FROM PUBLIC;\E
/xm, /xm,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
'REVOKE SELECT ON TABLE pg_proc FROM public' => { 'REVOKE SELECT ON TABLE pg_proc FROM public' => {
create_order => 45, create_order => 45,
create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;', create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;',
regexp => qr/^REVOKE SELECT ON TABLE pg_catalog.pg_proc FROM PUBLIC;/m, regexp =>
like => { qr/^REVOKE SELECT ON TABLE pg_catalog.pg_proc FROM PUBLIC;/m,
%full_runs, like => { %full_runs, section_pre_data => 1, },
section_pre_data => 1, }, unlike => { no_privs => 1, }, },
unlike => {
no_privs => 1, }, },
'REVOKE CREATE ON SCHEMA public FROM public' => { 'REVOKE CREATE ON SCHEMA public FROM public' => {
create_order => 16, create_order => 16,
...@@ -3019,11 +2766,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -3019,11 +2766,8 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
\QREVOKE ALL ON SCHEMA public FROM PUBLIC;\E \QREVOKE ALL ON SCHEMA public FROM PUBLIC;\E
\n\QGRANT USAGE ON SCHEMA public TO PUBLIC;\E \n\QGRANT USAGE ON SCHEMA public TO PUBLIC;\E
/xm, /xm,
like => { like => { %full_runs, section_pre_data => 1, },
%full_runs, unlike => { no_privs => 1, }, },
section_pre_data => 1, },
unlike => {
no_privs => 1, }, },
'REVOKE USAGE ON LANGUAGE plpgsql FROM public' => { 'REVOKE USAGE ON LANGUAGE plpgsql FROM public' => {
create_order => 16, create_order => 16,
...@@ -3035,8 +2779,7 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du ...@@ -3035,8 +2779,7 @@ qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_du
only_dump_test_table => 1, only_dump_test_table => 1,
role => 1, role => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
); );
...@@ -3121,8 +2864,9 @@ foreach my $run (sort keys %pgdump_runs) ...@@ -3121,8 +2864,9 @@ foreach my $run (sort keys %pgdump_runs)
next; next;
} }
# If there is a like entry, but no unlike entry, then we will test the like case # 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 ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{ {
$num_tests++; $num_tests++;
} }
...@@ -3283,18 +3027,18 @@ foreach my $run (sort keys %pgdump_runs) ...@@ -3283,18 +3027,18 @@ foreach my $run (sort keys %pgdump_runs)
# Run the test listed as a like, unless it is specifically noted # Run the test listed as a like, unless it is specifically noted
# as an unlike (generally due to an explicit exclusion or similar). # 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"); diag("Review $run results in $tempdir");
} }
} }
else else
{ {
if (!ok( if (!ok($output_file !~ $tests{$test}->{regexp},
$output_file !~
$tests{$test}->{regexp},
"$run: should not dump $test")) "$run: should not dump $test"))
{ {
diag("Review $run results in $tempdir"); diag("Review $run results in $tempdir");
......
...@@ -13,14 +13,14 @@ my $node = get_new_node('main'); ...@@ -13,14 +13,14 @@ my $node = get_new_node('main');
$node->init; $node->init;
command_like([ 'pg_resetwal', '-n', $node->data_dir ], command_like([ 'pg_resetwal', '-n', $node->data_dir ],
qr/checkpoint/, qr/checkpoint/, 'pg_resetwal -n produces output');
'pg_resetwal -n produces output');
# Permissions on PGDATA should be default # Permissions on PGDATA should be default
SKIP: 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), ok(check_mode_recursive($node->data_dir, 0700, 0600),
'check PGDATA permissions'); 'check PGDATA permissions');
......
...@@ -27,10 +27,13 @@ binmode $fh; ...@@ -27,10 +27,13 @@ binmode $fh;
print $fh pack("x[$size]"); print $fh pack("x[$size]");
close $fh; close $fh;
command_checks_all([ 'pg_resetwal', '-n', $node->data_dir ], command_checks_all(
[ 'pg_resetwal', '-n', $node->data_dir ],
0, 0,
[ qr/pg_control version number/ ], [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'); 'processes corrupted pg_control all zeroes');
# Put in the previously saved header data. This uses a different code # Put in the previously saved header data. This uses a different code
...@@ -40,8 +43,11 @@ binmode $fh; ...@@ -40,8 +43,11 @@ binmode $fh;
print $fh $data, pack("x[" . ($size - 16) . "]"); print $fh $data, pack("x[" . ($size - 16) . "]");
close $fh; close $fh;
command_checks_all([ 'pg_resetwal', '-n', $node->data_dir ], command_checks_all(
[ 'pg_resetwal', '-n', $node->data_dir ],
0, 0,
[ qr/pg_control version number/ ], [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'); 'processes zero WAL segment size');
...@@ -119,12 +119,14 @@ sub setup_cluster ...@@ -119,12 +119,14 @@ sub setup_cluster
my $extra = shift; # Extra params for initdb my $extra = shift; # Extra params for initdb
# Initialize master, data checksums are mandatory # Initialize master, data checksums are mandatory
$node_master = get_new_node('master' . ($extra_name ? "_${extra_name}" : '')); $node_master =
$node_master->init( get_new_node('master' . ($extra_name ? "_${extra_name}" : ''));
allows_streaming => 1, extra => $extra); $node_master->init(allows_streaming => 1, extra => $extra);
# Set wal_keep_segments to prevent WAL segment recycling after enforced # Set wal_keep_segments to prevent WAL segment recycling after enforced
# checkpoints in the tests. # checkpoints in the tests.
$node_master->append_conf('postgresql.conf', qq( $node_master->append_conf(
'postgresql.conf', qq(
wal_keep_segments = 20 wal_keep_segments = 20
)); ));
} }
...@@ -141,7 +143,8 @@ sub create_standby ...@@ -141,7 +143,8 @@ sub create_standby
{ {
my $extra_name = shift; 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_master->backup('my_backup');
$node_standby->init_from_backup($node_master, 'my_backup'); $node_standby->init_from_backup($node_master, 'my_backup');
my $connstr_master = $node_master->connstr(); my $connstr_master = $node_master->connstr();
...@@ -239,7 +242,8 @@ sub run_pg_rewind ...@@ -239,7 +242,8 @@ sub run_pg_rewind
"$tmp_folder/master-postgresql.conf.tmp", "$tmp_folder/master-postgresql.conf.tmp",
"$master_pgdata/postgresql.conf"); "$master_pgdata/postgresql.conf");
chmod($node_master->group_access() ? 0640 : 0600, chmod(
$node_master->group_access() ? 0640 : 0600,
"$master_pgdata/postgresql.conf") "$master_pgdata/postgresql.conf")
or BAIL_OUT( or BAIL_OUT(
"unable to set permissions for $master_pgdata/postgresql.conf"); "unable to set permissions for $master_pgdata/postgresql.conf");
......
...@@ -89,7 +89,8 @@ in master, before promotion ...@@ -89,7 +89,8 @@ in master, before promotion
# Permissions on PGDATA should be default # Permissions on PGDATA should be default
SKIP: 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), ok(check_mode_recursive($node_master->data_dir(), 0700, 0600),
'check PGDATA permissions'); 'check PGDATA permissions');
......
...@@ -45,7 +45,8 @@ template1 ...@@ -45,7 +45,8 @@ template1
# Permissions on PGDATA should have group permissions # Permissions on PGDATA should have group permissions
SKIP: 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), ok(check_mode_recursive($node_master->data_dir(), 0750, 0640),
'check PGDATA permissions'); 'check PGDATA permissions');
......
...@@ -81,8 +81,10 @@ pgbench( ...@@ -81,8 +81,10 @@ pgbench(
# Initialize pgbench tables scale 1 # Initialize pgbench tables scale 1
pgbench( pgbench(
'-i', 0, [qr{^$}], '-i', 0,
[ qr{creating tables}, qr{vacuuming}, qr{creating primary keys}, qr{done\.} ], [qr{^$}],
[ qr{creating tables}, qr{vacuuming},
qr{creating primary keys}, qr{done\.} ],
'pgbench scale 1 initialization',); 'pgbench scale 1 initialization',);
# Again, with all possible options # Again, with all possible options
...@@ -100,8 +102,9 @@ pgbench( ...@@ -100,8 +102,9 @@ pgbench(
# Test interaction of --init-steps with legacy step-selection options # Test interaction of --init-steps with legacy step-selection options
pgbench( pgbench(
'--initialize --init-steps=dtpvgvv --no-vacuum --foreign-keys --unlogged-tables', '--initialize --init-steps=dtpvgvv --no-vacuum --foreign-keys --unlogged-tables',
0, [qr{^$}], 0,
[qr{^$}],
[ qr{dropping old tables}, [ qr{dropping old tables},
qr{creating tables}, qr{creating tables},
qr{creating primary keys}, qr{creating primary keys},
...@@ -218,10 +221,11 @@ COMMIT; ...@@ -218,10 +221,11 @@ COMMIT;
# test expressions # test expressions
# command 1..3 and 23 depend on random seed which is used to call srandom. # command 1..3 and 23 depend on random seed which is used to call srandom.
pgbench( 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, 0,
[ qr{type: .*/001_pgbench_expressions}, qr{processed: 1/1} ], [ qr{type: .*/001_pgbench_expressions}, qr{processed: 1/1} ],
[ qr{setting random seed to 5432\b}, [ qr{setting random seed to 5432\b},
# After explicit seeding, the four * random checks (1-3,20) should be # After explicit seeding, the four * random checks (1-3,20) should be
# deterministic, but not necessarily portable. # deterministic, but not necessarily portable.
qr{command=1.: int 1\d\b}, # uniform random: 12 on linux qr{command=1.: int 1\d\b}, # uniform random: 12 on linux
...@@ -411,13 +415,15 @@ SELECT :v0, :v1, :v2, :v3; ...@@ -411,13 +415,15 @@ SELECT :v0, :v1, :v2, :v3;
# random determinism when seeded # random determinism when seeded
$node->safe_psql('postgres', $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 # same value to check for determinism
my $seed = int(rand(1000000000)); my $seed = int(rand(1000000000));
for my $i (1, 2) for my $i (1, 2)
{ {
pgbench("--random-seed=$seed -t 1", pgbench(
"--random-seed=$seed -t 1",
0, 0,
[qr{processed: 1/1}], [qr{processed: 1/1}],
[qr{setting random seed to $seed\b}], [qr{setting random seed to $seed\b}],
...@@ -436,16 +442,20 @@ INSERT INTO seeded_random(seed, rand, val) VALUES ...@@ -436,16 +442,20 @@ INSERT INTO seeded_random(seed, rand, val) VALUES
} }
# check that all runs generated the same 4 values # check that all runs generated the same 4 values
my ($ret, $out, $err) = my ($ret, $out, $err) = $node->psql('postgres',
$node->psql('postgres', 'SELECT seed, rand, val, COUNT(*) FROM seeded_random GROUP BY seed, rand, val'
'SELECT seed, rand, val, COUNT(*) FROM seeded_random GROUP BY seed, rand, val'); );
ok($ret == 0, "psql seeded_random count ok"); ok($ret == 0, "psql seeded_random count ok");
ok($err eq '', "psql seeded_random count stderr is empty"); 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\|uniform\|1\d\d\d\|2/,
ok($out =~ /\b$seed\|exponential\|2\d\d\d\|2/, "psql seeded_random count exponential"); "psql seeded_random count uniform");
ok($out =~ /\b$seed\|gaussian\|3\d\d\d\|2/, "psql seeded_random count gaussian"); ok( $out =~ /\b$seed\|exponential\|2\d\d\d\|2/,
ok($out =~ /\b$seed\|zipfian\|4\d\d\d\|2/, "psql seeded_random count zipfian"); "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;'); $node->safe_psql('postgres', 'DROP TABLE seeded_random;');
...@@ -481,8 +491,8 @@ my @errors = ( ...@@ -481,8 +491,8 @@ my @errors = (
# SQL # SQL
[ 'sql syntax error', [ 'sql syntax error',
0, 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 q{-- SQL syntax error
SELECT 1 + ; SELECT 1 + ;
} ], } ],
...@@ -567,42 +577,24 @@ SELECT LEAST(:i, :i, :i, :i, :i, :i, :i, :i, :i, :i, :i); ...@@ -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)} ], q{\set i random_zipfian(0, 10, 1000000)} ],
[ 'set non numeric value', 0, [ 'set non numeric value', 0,
[qr{malformed variable "foo" value: "bla"}], q{\set i :foo + 1} ], [qr{malformed variable "foo" value: "bla"}], q{\set i :foo + 1} ],
[ 'set no expression', [ 'set no expression', 1, [qr{syntax error}], q{\set i} ],
1, [ 'set missing argument', 1, [qr{missing argument}i], q{\set} ],
[qr{syntax error}], [ 'set not a bool', 0,
q{\set i} ], [qr{cannot coerce double to boolean}], q{\set b NOT 0.0} ],
[ 'set missing argument', [ 'set not an int', 0,
1, [qr{cannot coerce boolean to int}], q{\set i TRUE + 2} ],
[qr{missing argument}i], [ 'set not a double', 0,
q{\set} ], [qr{cannot coerce boolean to double}], q{\set d ln(TRUE)} ],
[ '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', [ 'set case error',
1, 1,
[ qr{syntax error in command "set"} ], [qr{syntax error in command "set"}],
q{\set i CASE TRUE THEN 1 ELSE 0 END} ], q{\set i CASE TRUE THEN 1 ELSE 0 END} ],
[ 'set random error', [ 'set random error', 0,
0, [qr{cannot coerce boolean to int}], q{\set b random(FALSE, TRUE)} ],
[ qr{cannot coerce boolean to int} ], [ 'set number of args mismatch', 1,
q{\set b random(FALSE, TRUE)} ], [qr{unexpected number of arguments}], q{\set d ln(1.0, 2.0))} ],
[ 'set number of args mismatch', [ 'set at least one arg', 1,
1, [qr{at least one argument expected}], q{\set i greatest())} ],
[ 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
[ 'setshell not an int', 0, [ 'setshell not an int', 0,
...@@ -625,8 +617,8 @@ SELECT LEAST(:i, :i, :i, :i, :i, :i, :i, :i, :i, :i, :i); ...@@ -625,8 +617,8 @@ SELECT LEAST(:i, :i, :i, :i, :i, :i, :i, :i, :i, :i, :i);
[ 'misc invalid backslash command', 1, [ 'misc invalid backslash command', 1,
[qr{invalid command .* "nosuchcommand"}], q{\nosuchcommand} ], [qr{invalid command .* "nosuchcommand"}], q{\nosuchcommand} ],
[ 'misc empty script', 1, [qr{empty command list for script}], q{} ], [ '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) for my $e (@errors)
...@@ -635,7 +627,7 @@ for my $e (@errors) ...@@ -635,7 +627,7 @@ for my $e (@errors)
my $n = '001_pgbench_error_' . $name; my $n = '001_pgbench_error_' . $name;
$n =~ s/ /_/g; $n =~ s/ /_/g;
pgbench( 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,
[ $status ? qr{^$} : qr{processed: 0/1} ], [ $status ? qr{^$} : qr{processed: 0/1} ],
$re, $re,
...@@ -647,7 +639,7 @@ for my $e (@errors) ...@@ -647,7 +639,7 @@ for my $e (@errors)
pgbench( pgbench(
'-t 1', 0, '-t 1', 0,
[ qr{processed: 1/1}, qr{zipfian cache array overflowed 1 time\(s\)} ], [ qr{processed: 1/1}, qr{zipfian cache array overflowed 1 time\(s\)} ],
[ qr{^} ], [qr{^}],
'pgbench zipfian array overflow on random_zipfian', 'pgbench zipfian array overflow on random_zipfian',
{ '001_pgbench_random_zipfian' => q{ { '001_pgbench_random_zipfian' => q{
\set i random_zipfian(1, 100, 0.5) \set i random_zipfian(1, 100, 0.5)
......
...@@ -15,8 +15,7 @@ $testname =~ s/\.pl$//; ...@@ -15,8 +15,7 @@ $testname =~ s/\.pl$//;
my $testdir = "$TestLib::tmp_check/t_${testname}_stuff"; my $testdir = "$TestLib::tmp_check/t_${testname}_stuff";
mkdir $testdir mkdir $testdir
or or BAIL_OUT("could not create test directory \"${testdir}\": $!");
BAIL_OUT("could not create test directory \"${testdir}\": $!");
# invoke pgbench # invoke pgbench
sub pgbench sub pgbench
...@@ -38,8 +37,10 @@ sub pgbench_scripts ...@@ -38,8 +37,10 @@ sub pgbench_scripts
for my $fn (sort keys %$files) for my $fn (sort keys %$files)
{ {
my $filename = $testdir . '/' . $fn; my $filename = $testdir . '/' . $fn;
# cleanup file weight if any # cleanup file weight if any
$filename =~ s/\@\d+$//; $filename =~ s/\@\d+$//;
# cleanup from prior runs # cleanup from prior runs
unlink $filename; unlink $filename;
append_to_file($filename, $$files{$fn}); append_to_file($filename, $$files{$fn});
...@@ -105,13 +106,16 @@ my @options = ( ...@@ -105,13 +106,16 @@ my @options = (
[ 'ambiguous builtin', '-b s', [qr{ambiguous}] ], [ 'ambiguous builtin', '-b s', [qr{ambiguous}] ],
[ '--progress-timestamp => --progress', '--progress-timestamp', [ '--progress-timestamp => --progress', '--progress-timestamp',
[qr{allowed only under}] ], [qr{allowed only under}] ],
[ '-I without init option', '-I dtg', [ '-I without init option',
'-I dtg',
[qr{cannot be used in benchmarking mode}] ], [qr{cannot be used in benchmarking mode}] ],
[ 'invalid init step', '-i -I dta', [ 'invalid init step',
[qr{unrecognized initialization step}, '-i -I dta',
qr{allowed steps are} ] ], [ qr{unrecognized initialization step}, qr{allowed steps are} ] ],
[ 'bad random seed', '--random-seed=one', [ 'bad random seed',
[qr{unrecognized random seed option "one": expecting an unsigned integer, "time" or "rand"}, '--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{error while setting random seed from --random-seed option} ] ],
# loging sub-options # loging sub-options
...@@ -161,23 +165,44 @@ pgbench( ...@@ -161,23 +165,44 @@ pgbench(
'pgbench builtin list'); 'pgbench builtin list');
my @script_tests = ( my @script_tests = (
# name, err, { file => contents } # name, err, { file => contents }
[ 'missing endif', [qr{\\if without matching \\endif}], {'if-noendif.sql' => '\if 1'} ], [ 'missing endif',
[ 'missing if on elif', [qr{\\elif without matching \\if}], {'elif-noif.sql' => '\elif 1'} ], [qr{\\if without matching \\endif}],
[ 'missing if on else', [qr{\\else without matching \\if}], {'else-noif.sql' => '\else'} ], { 'if-noendif.sql' => '\if 1' } ],
[ 'missing if on endif', [qr{\\endif without matching \\if}], {'endif-noif.sql' => '\endif'} ], [ 'missing if on elif',
[ 'elif after else', [qr{\\elif after \\else}], {'else-elif.sql' => "\\if 1\n\\else\n\\elif 0\n\\endif"} ], [qr{\\elif without matching \\if}],
[ 'else after else', [qr{\\else after \\else}], {'else-else.sql' => "\\if 1\n\\else\n\\else\n\\endif"} ], { 'elif-noif.sql' => '\elif 1' } ],
[ 'if syntax error', [qr{syntax error in command "if"}], {'if-bad.sql' => "\\if\n\\endif\n"} ], [ 'missing if on else',
[ 'elif syntax error', [qr{syntax error in command "elif"}], {'elif-bad.sql' => "\\if 0\n\\elif +\n\\endif\n"} ], [qr{\\else without matching \\if}],
[ 'else syntax error', [qr{unexpected argument in command "else"}], {'else-bad.sql' => "\\if 0\n\\else BAD\n\\endif\n"} ], { 'else-noif.sql' => '\else' } ],
[ 'endif syntax error', [qr{unexpected argument in command "endif"}], {'endif-bad.sql' => "\\if 0\n\\endif BAD\n"} ], [ '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) for my $t (@script_tests)
{ {
my ($name, $err, $files) = @$t; 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(); done_testing();
...@@ -16,4 +16,5 @@ $node->init; ...@@ -16,4 +16,5 @@ $node->init;
$node->start; $node->start;
# use a long timeout for the benefit of very slow buildfarm machines # 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( ...@@ -36,13 +36,17 @@ $node->issues_sql_like(
$node->command_ok([qw(vacuumdb -Z --table=pg_am dbname=template1)], $node->command_ok([qw(vacuumdb -Z --table=pg_am dbname=template1)],
'vacuumdb with connection string'); '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'); 'trailing command in "-t", without COLUMNS');
# Unwanted; better if it failed. # 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'); 'trailing command in "-t", with COLUMNS');
$node->safe_psql('postgres', q| $node->safe_psql(
'postgres', q|
CREATE TABLE "need""q(uot" (")x" text); CREATE TABLE "need""q(uot" (")x" text);
CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1'; CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
...@@ -53,5 +57,6 @@ $node->safe_psql('postgres', q| ...@@ -53,5 +57,6 @@ $node->safe_psql('postgres', q|
|); |);
$node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|], $node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|],
'column list'); 'column list');
$node->command_fails([qw|vacuumdb -Zt funcidx postgres|], $node->command_fails(
[qw|vacuumdb -Zt funcidx postgres|],
'unqualifed name via functional index'); 'unqualifed name via functional index');
...@@ -73,7 +73,7 @@ foreach my $datfile (@input_files) ...@@ -73,7 +73,7 @@ foreach my $datfile (@input_files)
my $header = "$1.h"; my $header = "$1.h";
die "There in no header file corresponding to $datfile" die "There in no header file corresponding to $datfile"
if ! -e $header; if !-e $header;
my $catalog = Catalog::ParseHeader($header); my $catalog = Catalog::ParseHeader($header);
my $catname = $catalog->{catname}; my $catname = $catalog->{catname};
...@@ -186,7 +186,7 @@ sub strip_default_values ...@@ -186,7 +186,7 @@ sub strip_default_values
{ {
my $attname = $column->{name}; my $attname = $column->{name};
die "strip_default_values: $catname.$attname undefined\n" die "strip_default_values: $catname.$attname undefined\n"
if ! defined $row->{$attname}; if !defined $row->{$attname};
# Delete values that match defaults. # Delete values that match defaults.
if (defined $column->{default} if (defined $column->{default}
...@@ -196,8 +196,9 @@ sub strip_default_values ...@@ -196,8 +196,9 @@ sub strip_default_values
} }
# Also delete pg_proc.pronargs, since that can be recomputed. # Also delete pg_proc.pronargs, since that can be recomputed.
if ($catname eq 'pg_proc' && $attname eq 'pronargs' && if ( $catname eq 'pg_proc'
defined($row->{proargtypes})) && $attname eq 'pronargs'
&& defined($row->{proargtypes}))
{ {
delete $row->{$attname}; delete $row->{$attname};
} }
......
...@@ -62,13 +62,16 @@ my $keytab = "${TestLib::tmp_check}/krb5.keytab"; ...@@ -62,13 +62,16 @@ my $keytab = "${TestLib::tmp_check}/krb5.keytab";
note "setting up Kerberos"; note "setting up Kerberos";
my ($stdout, $krb5_version); 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/; 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; $krb5_version = $1;
append_to_file($krb5_conf, append_to_file(
qq![logging] $krb5_conf,
qq![logging]
default = FILE:$krb5_log default = FILE:$krb5_log
kdc = FILE:$kdc_log kdc = FILE:$kdc_log
...@@ -80,27 +83,32 @@ $realm = { ...@@ -80,27 +83,32 @@ $realm = {
kdc = localhost:$kdc_port kdc = localhost:$kdc_port
}!); }!);
append_to_file($kdc_conf, append_to_file(
qq![kdcdefaults] $kdc_conf,
qq![kdcdefaults]
!); !);
# For new-enough versions of krb5, use the _listen settings rather # For new-enough versions of krb5, use the _listen settings rather
# than the _ports settings so that we can bind to localhost only. # than the _ports settings so that we can bind to localhost only.
if ($krb5_version >= 1.15) if ($krb5_version >= 1.15)
{ {
append_to_file($kdc_conf, append_to_file(
qq!kdc_listen = localhost:$kdc_port $kdc_conf,
qq!kdc_listen = localhost:$kdc_port
kdc_tcp_listen = localhost:$kdc_port kdc_tcp_listen = localhost:$kdc_port
!); !);
} }
else else
{ {
append_to_file($kdc_conf, append_to_file(
qq!kdc_ports = $kdc_port $kdc_conf,
qq!kdc_ports = $kdc_port
kdc_tcp_ports = $kdc_port kdc_tcp_ports = $kdc_port
!); !);
} }
append_to_file($kdc_conf, append_to_file(
qq! $kdc_conf,
qq!
[realms] [realms]
$realm = { $realm = {
database_name = $kdc_datadir/principal database_name = $kdc_datadir/principal
...@@ -148,8 +156,11 @@ sub test_access ...@@ -148,8 +156,11 @@ sub test_access
my ($node, $role, $expected_res, $test_name) = @_; my ($node, $role, $expected_res, $test_name) = @_;
# need to connect over TCP/IP for Kerberos # need to connect over TCP/IP for Kerberos
my $res = $node->psql('postgres', 'SELECT 1', my $res = $node->psql(
extra_params => [ '-d', $node->connstr('postgres').' host=localhost', 'postgres',
'SELECT 1',
extra_params => [
'-d', $node->connstr('postgres') . ' host=localhost',
'-U', $role ]); '-U', $role ]);
is($res, $expected_res, $test_name); is($res, $expected_res, $test_name);
} }
...@@ -171,7 +182,8 @@ test_access($node, 'test1', 0, 'succeeds with mapping'); ...@@ -171,7 +182,8 @@ test_access($node, 'test1', 0, 'succeeds with mapping');
truncate($node->data_dir . '/pg_ident.conf', 0); truncate($node->data_dir . '/pg_ident.conf', 0);
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
test_access($node, 'test1', 0, 'succeeds with include_realm=0'); test_access($node, 'test1', 0, 'succeeds with include_realm=0');
...@@ -59,8 +59,9 @@ my $ldap_pwfile = "${TestLib::tmp_check}/ldappassword"; ...@@ -59,8 +59,9 @@ my $ldap_pwfile = "${TestLib::tmp_check}/ldappassword";
note "setting up slapd"; note "setting up slapd";
append_to_file($slapd_conf, append_to_file(
qq{include $ldap_schema_dir/core.schema $slapd_conf,
qq{include $ldap_schema_dir/core.schema
include $ldap_schema_dir/cosine.schema include $ldap_schema_dir/cosine.schema
include $ldap_schema_dir/nis.schema include $ldap_schema_dir/nis.schema
include $ldap_schema_dir/inetorgperson.schema include $ldap_schema_dir/inetorgperson.schema
...@@ -84,16 +85,23 @@ rootdn "$ldap_rootdn" ...@@ -84,16 +85,23 @@ rootdn "$ldap_rootdn"
rootpw $ldap_rootpw}); rootpw $ldap_rootpw});
# don't bother to check the server's cert (though perhaps we should) # don't bother to check the server's cert (though perhaps we should)
append_to_file($ldap_conf, append_to_file(
qq{TLS_REQCERT never $ldap_conf,
qq{TLS_REQCERT never
}); });
mkdir $ldap_datadir or die; mkdir $ldap_datadir or die;
mkdir $slapd_certs 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",
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout", "$slapd_certs/server.key", "-out", "$slapd_certs/server.csr", "-subj", "/cn=server"; "$slapd_certs/ca.key", "-x509", "-out", "$slapd_certs/ca.crt", "-subj",
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"; "/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"; system_or_bail $slapd, '-f', $slapd_conf, '-h', "$ldap_url $ldaps_url";
...@@ -112,8 +120,10 @@ $ENV{'LDAPCONF'} = $ldap_conf; ...@@ -112,8 +120,10 @@ $ENV{'LDAPCONF'} = $ldap_conf;
note "loading LDAP data"; note "loading LDAP data";
system_or_bail 'ldapadd', '-x', '-y', $ldap_pwfile, '-f', 'authdata.ldif'; 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', 'secret1',
system_or_bail 'ldappasswd', '-x', '-y', $ldap_pwfile, '-s', 'secret2', 'uid=test2,dc=example,dc=net'; '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"; note "setting up PostgreSQL instance";
...@@ -131,50 +141,66 @@ sub test_access ...@@ -131,50 +141,66 @@ sub test_access
{ {
my ($node, $role, $expected_res, $test_name) = @_; 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); is($res, $expected_res, $test_name);
} }
note "simple bind"; note "simple bind";
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'wrong'; $ENV{"PGPASSWORD"} = 'wrong';
test_access($node, 'test0', 2, 'simple bind authentication fails if user not found in LDAP'); test_access($node, 'test0', 2,
test_access($node, 'test1', 2, 'simple bind authentication fails with wrong password'); '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'; $ENV{"PGPASSWORD"} = 'secret1';
test_access($node, 'test1', 0, 'simple bind authentication succeeds'); test_access($node, 'test1', 0, 'simple bind authentication succeeds');
note "search+bind"; note "search+bind";
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'wrong'; $ENV{"PGPASSWORD"} = 'wrong';
test_access($node, 'test0', 2, 'search+bind authentication fails if user not found in LDAP'); test_access($node, 'test0', 2,
test_access($node, 'test1', 2, 'search+bind authentication fails with wrong password'); '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'; $ENV{"PGPASSWORD"} = 'secret1';
test_access($node, 'test1', 0, 'search+bind authentication succeeds'); test_access($node, 'test1', 0, 'search+bind authentication succeeds');
note "LDAP URLs"; note "LDAP URLs";
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'wrong'; $ENV{"PGPASSWORD"} = 'wrong';
test_access($node, 'test0', 2, 'search+bind with LDAP URL authentication fails if user not found in LDAP'); test_access($node, 'test0', 2,
test_access($node, 'test1', 2, 'search+bind with LDAP URL authentication fails with wrong password'); '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'; $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"; note "search filters";
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -185,7 +211,9 @@ test_access($node, 'test2@example.net', 0, 'search filter finds by mail'); ...@@ -185,7 +211,9 @@ test_access($node, 'test2@example.net', 0, 'search filter finds by mail');
note "search filters in LDAP URLs"; note "search filters in LDAP URLs";
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -197,7 +225,9 @@ test_access($node, 'test2@example.net', 0, 'search filter finds by mail'); ...@@ -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 # settings. ldapurl is always parsed first, then the other settings
# override. It might be useful in a case like this. # override. It might be useful in a case like this.
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -207,7 +237,9 @@ note "diagnostic message"; ...@@ -207,7 +237,9 @@ note "diagnostic message";
# note bad ldapprefix with a question mark that triggers a diagnostic message # note bad ldapprefix with a question mark that triggers a diagnostic message
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -217,7 +249,9 @@ note "TLS"; ...@@ -217,7 +249,9 @@ note "TLS";
# request StartTLS with ldaptls=1 # request StartTLS with ldaptls=1
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -225,7 +259,9 @@ test_access($node, 'test1', 0, 'StartTLS'); ...@@ -225,7 +259,9 @@ test_access($node, 'test1', 0, 'StartTLS');
# request LDAPS with ldapscheme=ldaps # request LDAPS with ldapscheme=ldaps
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -233,7 +269,9 @@ test_access($node, 'test1', 0, 'LDAPS'); ...@@ -233,7 +269,9 @@ test_access($node, 'test1', 0, 'LDAPS');
# request LDAPS with ldapurl=ldaps://... # request LDAPS with ldapurl=ldaps://...
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
...@@ -241,7 +279,9 @@ test_access($node, 'test1', 0, 'LDAPS with URL'); ...@@ -241,7 +279,9 @@ test_access($node, 'test1', 0, 'LDAPS with URL');
# bad combination of LDAPS and StartTLS # bad combination of LDAPS and StartTLS
unlink($node->data_dir . '/pg_hba.conf'); 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; $node->restart;
$ENV{"PGPASSWORD"} = 'secret1'; $ENV{"PGPASSWORD"} = 'secret1';
......
...@@ -15,25 +15,27 @@ $node->start; ...@@ -15,25 +15,27 @@ $node->start;
$node->safe_psql('postgres', 'create extension pageinspect'); $node->safe_psql('postgres', 'create extension pageinspect');
# Create a table with an autosummarizing BRIN index # 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 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); create index brin_wi_idx on brin_wi using brin (a) with (pages_per_range=1, autosummarize=on);
' '
); );
my $count = $node->safe_psql('postgres', 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"); is($count, '1', "initial index state is correct");
$node->safe_psql('postgres', $node->safe_psql('postgres',
'insert into brin_wi select * from generate_series(1, 100)'); 'insert into brin_wi select * from generate_series(1, 100)');
$node->poll_query_until('postgres', $node->poll_query_until(
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)", 'postgres',
"select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)",
't'); 't');
$count = $node->safe_psql('postgres', $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"); is($count, 't', "index got summarized");
$node->stop; $node->stop;
...@@ -184,8 +184,7 @@ my %full_runs = ( ...@@ -184,8 +184,7 @@ my %full_runs = (
createdb => 1, createdb => 1,
defaults => 1, defaults => 1,
no_privs => 1, no_privs => 1,
no_owner => 1, no_owner => 1,);
);
my %tests = ( my %tests = (
'ALTER EXTENSION test_pg_dump' => { 'ALTER EXTENSION test_pg_dump' => {
...@@ -209,8 +208,7 @@ my %tests = ( ...@@ -209,8 +208,7 @@ my %tests = (
%full_runs, %full_runs,
schema_only => 1, schema_only => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { binary_upgrade => 1, }, },
binary_upgrade => 1, }, },
'CREATE ROLE regress_dump_test_role' => { 'CREATE ROLE regress_dump_test_role' => {
create_order => 1, create_order => 1,
...@@ -307,8 +305,7 @@ my %tests = ( ...@@ -307,8 +305,7 @@ my %tests = (
%full_runs, %full_runs,
schema_only => 1, schema_only => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT SELECT ON TABLE regress_pg_dump_table' => { 'GRANT SELECT ON TABLE regress_pg_dump_table' => {
regexp => qr/^ regexp => qr/^
...@@ -326,8 +323,9 @@ my %tests = ( ...@@ -326,8 +323,9 @@ my %tests = (
\n/xms, \n/xms,
like => { binary_upgrade => 1, }, }, like => { binary_upgrade => 1, }, },
'GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role' => 'GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role'
{ create_order => 4, => {
create_order => 4,
create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table
TO regress_dump_test_role;', TO regress_dump_test_role;',
regexp => qr/^ regexp => qr/^
...@@ -337,8 +335,7 @@ my %tests = ( ...@@ -337,8 +335,7 @@ my %tests = (
%full_runs, %full_runs,
schema_only => 1, schema_only => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role'
=> { => {
...@@ -352,8 +349,7 @@ my %tests = ( ...@@ -352,8 +349,7 @@ my %tests = (
%full_runs, %full_runs,
schema_only => 1, schema_only => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => { 'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
regexp => qr/^ regexp => qr/^
...@@ -372,8 +368,7 @@ my %tests = ( ...@@ -372,8 +368,7 @@ my %tests = (
%full_runs, %full_runs,
schema_only => 1, schema_only => 1,
section_pre_data => 1, }, section_pre_data => 1, },
unlike => { unlike => { no_privs => 1, }, },
no_privs => 1, }, },
# Objects included in extension part of a schema created by this extension */ # Objects included in extension part of a schema created by this extension */
'CREATE TABLE regress_pg_dump_schema.test_table' => { 'CREATE TABLE regress_pg_dump_schema.test_table' => {
...@@ -469,8 +464,7 @@ my %tests = ( ...@@ -469,8 +464,7 @@ my %tests = (
like => { like => {
%full_runs, %full_runs,
schema_only => 1, schema_only => 1,
section_pre_data => 1, }, }, section_pre_data => 1, }, },);
);
######################################### #########################################
# Create a PG instance to test actually dumping from # Create a PG instance to test actually dumping from
...@@ -504,8 +498,9 @@ foreach my $run (sort keys %pgdump_runs) ...@@ -504,8 +498,9 @@ foreach my $run (sort keys %pgdump_runs)
# Then count all the tests run against each run # Then count all the tests run against each run
foreach my $test (sort keys %tests) foreach my $test (sort keys %tests)
{ {
# If there is a like entry, but no unlike entry, then we will test the like case # 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 ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{ {
$num_tests++; $num_tests++;
} }
...@@ -585,18 +580,18 @@ foreach my $run (sort keys %pgdump_runs) ...@@ -585,18 +580,18 @@ foreach my $run (sort keys %pgdump_runs)
{ {
# Run the test listed as a like, unless it is specifically noted # Run the test listed as a like, unless it is specifically noted
# as an unlike (generally due to an explicit exclusion or similar). # 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"); diag("Review $run results in $tempdir");
} }
} }
else else
{ {
if (!ok( if (!ok($output_file !~ $tests{$test}->{regexp},
$output_file !~
$tests{$test}->{regexp},
"$run: should not dump $test")) "$run: should not dump $test"))
{ {
diag("Review $run results in $tempdir"); diag("Review $run results in $tempdir");
......
...@@ -1535,7 +1535,7 @@ sub wait_for_catchup ...@@ -1535,7 +1535,7 @@ sub wait_for_catchup
} }
else else
{ {
$lsn_expr = 'pg_current_wal_lsn()' $lsn_expr = 'pg_current_wal_lsn()';
} }
print "Waiting for replication conn " print "Waiting for replication conn "
. $standby_name . "'s " . $standby_name . "'s "
...@@ -1686,8 +1686,8 @@ to check for timeout. retval is undef on timeout. ...@@ -1686,8 +1686,8 @@ to check for timeout. retval is undef on timeout.
sub pg_recvlogical_upto 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 ($stdout, $stderr);
my $timeout_exception = 'pg_recvlogical timed out'; my $timeout_exception = 'pg_recvlogical timed out';
......
...@@ -174,6 +174,7 @@ sub real_dir ...@@ -174,6 +174,7 @@ sub real_dir
return $dir unless $Config{osname} eq 'msys'; return $dir unless $Config{osname} eq 'msys';
my $here = cwd; my $here = cwd;
chdir $dir; chdir $dir;
# this odd way of calling 'pwd -W' is the only way that seems to work. # this odd way of calling 'pwd -W' is the only way that seems to work.
$dir = qx{sh -c "pwd -W"}; $dir = qx{sh -c "pwd -W"};
chomp $dir; chomp $dir;
...@@ -254,12 +255,9 @@ sub check_mode_recursive ...@@ -254,12 +255,9 @@ sub check_mode_recursive
# Result defaults to true # Result defaults to true
my $result = 1; my $result = 1;
find find(
( { follow_fast => 1,
{follow_fast => 1, wanted => sub {
wanted =>
sub
{
my $file_stat = stat($File::Find::name); my $file_stat = stat($File::Find::name);
# Is file in the ignore list? # Is file in the ignore list?
...@@ -281,7 +279,8 @@ sub check_mode_recursive ...@@ -281,7 +279,8 @@ sub check_mode_recursive
{ {
if ($file_mode != $expected_file_mode) if ($file_mode != $expected_file_mode)
{ {
print(*STDERR, print(
*STDERR,
sprintf("$File::Find::name mode must be %04o\n", sprintf("$File::Find::name mode must be %04o\n",
$expected_file_mode)); $expected_file_mode));
...@@ -289,12 +288,14 @@ sub check_mode_recursive ...@@ -289,12 +288,14 @@ sub check_mode_recursive
return; return;
} }
} }
# Else a directory? # Else a directory?
elsif (S_ISDIR($file_stat->mode)) elsif (S_ISDIR($file_stat->mode))
{ {
if ($file_mode != $expected_dir_mode) if ($file_mode != $expected_dir_mode)
{ {
print(*STDERR, print(
*STDERR,
sprintf("$File::Find::name mode must be %04o\n", sprintf("$File::Find::name mode must be %04o\n",
$expected_dir_mode)); $expected_dir_mode));
...@@ -302,14 +303,15 @@ sub check_mode_recursive ...@@ -302,14 +303,15 @@ sub check_mode_recursive
return; return;
} }
} }
# Else something we can't handle # Else something we can't handle
else else
{ {
die "unknown file type for $File::Find::name"; die "unknown file type for $File::Find::name";
} }
}}, }
$dir },
); $dir);
return $result; return $result;
} }
...@@ -319,23 +321,21 @@ sub chmod_recursive ...@@ -319,23 +321,21 @@ sub chmod_recursive
{ {
my ($dir, $dir_mode, $file_mode) = @_; my ($dir, $dir_mode, $file_mode) = @_;
find find(
( { follow_fast => 1,
{follow_fast => 1, wanted => sub {
wanted =>
sub
{
my $file_stat = stat($File::Find::name); my $file_stat = stat($File::Find::name);
if (defined($file_stat)) if (defined($file_stat))
{ {
chmod(S_ISDIR($file_stat->mode) ? $dir_mode : $file_mode, chmod(
$File::Find::name) S_ISDIR($file_stat->mode) ? $dir_mode : $file_mode,
or die "unable to chmod $File::Find::name"; $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 # Check presence of a given regexp within pg_config.h for the installation
...@@ -351,7 +351,7 @@ sub check_pg_config ...@@ -351,7 +351,7 @@ sub check_pg_config
chomp($stdout); chomp($stdout);
open my $pg_config_h, '<', "$stdout/pg_config.h" or die "$!"; 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; close $pg_config_h;
return $match; return $match;
} }
......
...@@ -80,8 +80,7 @@ is($stdout_recv, $expected, ...@@ -80,8 +80,7 @@ is($stdout_recv, $expected,
$node_master->poll_query_until('postgres', $node_master->poll_query_until('postgres',
"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'test_slot' AND active_pid IS NULL)" "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( $stdout_recv = $node_master->pg_recvlogical_upto(
'postgres', 'test_slot', $endpos, 10, 'postgres', 'test_slot', $endpos, 10,
......
...@@ -30,7 +30,8 @@ $node->init(allows_streaming => 1); ...@@ -30,7 +30,8 @@ $node->init(allows_streaming => 1);
$node->start(); $node->start();
# by default PostgresNode doesn't doesn't restart after a crash # 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; q[ALTER SYSTEM SET restart_after_crash = 1;
ALTER SYSTEM SET log_connections = 1; ALTER SYSTEM SET log_connections = 1;
SELECT pg_reload_conf();]); SELECT pg_reload_conf();]);
...@@ -107,7 +108,11 @@ is($ret, 0, "killed process with SIGQUIT"); ...@@ -107,7 +108,11 @@ is($ret, 0, "killed process with SIGQUIT");
$killme_stdin .= q[ $killme_stdin .= q[
SELECT 1; 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"); "psql query died successfully after SIGQUIT");
$killme_stderr = ''; $killme_stderr = '';
$killme_stdout = ''; $killme_stdout = '';
...@@ -116,13 +121,21 @@ $killme->finish; ...@@ -116,13 +121,21 @@ $killme->finish;
# Wait till server restarts - we should get the WARNING here, but # Wait till server restarts - we should get the WARNING here, but
# sometimes the server is unable to send that, if interrupted while # sometimes the server is unable to send that, if interrupted while
# sending. # 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"); "psql monitor died successfully after SIGQUIT");
$monitor->finish; $monitor->finish;
# Wait till server restarts # Wait till server restarts
is($node->poll_query_until('postgres', 'SELECT $$restarted after sigquit$$;', 'restarted after sigquit'), is( $node->poll_query_until(
"1", "reconnected after SIGQUIT"); 'postgres',
'SELECT $$restarted after sigquit$$;',
'restarted after sigquit'),
"1",
"reconnected after SIGQUIT");
# restart psql processes, now that the crash cycle finished # restart psql processes, now that the crash cycle finished
...@@ -179,35 +192,51 @@ is($ret, 0, "killed process with KILL"); ...@@ -179,35 +192,51 @@ is($ret, 0, "killed process with KILL");
$killme_stdin .= q[ $killme_stdin .= q[
SELECT 1; 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"); "psql query died successfully after SIGKILL");
$killme->finish; $killme->finish;
# Wait till server restarts - we should get the WARNING here, but # Wait till server restarts - we should get the WARNING here, but
# sometimes the server is unable to send that, if interrupted while # sometimes the server is unable to send that, if interrupted while
# sending. # 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"); "psql monitor died successfully after SIGKILL");
$monitor->finish; $monitor->finish;
# Wait till server restarts # 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 # Make sure the committed rows survived, in-progress ones not
is($node->safe_psql('postgres', 'SELECT * FROM alive'), is( $node->safe_psql('postgres', 'SELECT * FROM alive'),
"committed-before-sigquit\ncommitted-before-sigkill", 'data survived'); "committed-before-sigquit\ncommitted-before-sigkill",
'data survived');
is($node->safe_psql('postgres', 'INSERT INTO alive VALUES($$before-orderly-restart$$) RETURNING status'), is( $node->safe_psql(
'before-orderly-restart', 'can still write after crash restart'); '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 # Just to be sure, check that an orderly restart now still works
$node->restart(); $node->restart();
is($node->safe_psql('postgres', 'SELECT * FROM alive'), is( $node->safe_psql('postgres', 'SELECT * FROM alive'),
"committed-before-sigquit\ncommitted-before-sigkill\nbefore-orderly-restart", 'data survived'); "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'), is( $node->safe_psql(
'after-orderly-restart', 'can still write after orderly restart'); 'postgres',
'INSERT INTO alive VALUES($$after-orderly-restart$$) RETURNING status'
),
'after-orderly-restart',
'can still write after orderly restart');
$node->stop(); $node->stop();
...@@ -221,7 +250,7 @@ sub pump_until ...@@ -221,7 +250,7 @@ sub pump_until
if ($psql_timeout->is_expired) if ($psql_timeout->is_expired)
{ {
diag("aborting wait: program timed out"); diag("aborting wait: program timed out");
diag("stream contents: >>", $$stream,"<<"); diag("stream contents: >>", $$stream, "<<");
diag("pattern searched for: ", $untl); diag("pattern searched for: ", $untl);
return 0; return 0;
...@@ -229,7 +258,7 @@ sub pump_until ...@@ -229,7 +258,7 @@ sub pump_until
if (not $proc->pumpable()) if (not $proc->pumpable())
{ {
diag("aborting wait: program died"); diag("aborting wait: program died");
diag("stream contents: >>", $$stream,"<<"); diag("stream contents: >>", $$stream, "<<");
diag("pattern searched for: ", $untl); diag("pattern searched for: ", $untl);
return 0; return 0;
...@@ -239,4 +268,4 @@ sub pump_until ...@@ -239,4 +268,4 @@ sub pump_until
} }
return 1; return 1;
}; }
...@@ -32,8 +32,7 @@ my $tablespaceDir = TestLib::tempdir; ...@@ -32,8 +32,7 @@ my $tablespaceDir = TestLib::tempdir;
my $realTSDir = TestLib::real_dir($tablespaceDir); my $realTSDir = TestLib::real_dir($tablespaceDir);
$node->safe_psql('postgres', $node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
"CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
$node->safe_psql('postgres', $node->safe_psql('postgres',
'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1'); 'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1');
...@@ -64,11 +63,9 @@ unlink("$pgdata/${ts1UnloggedPath}") ...@@ -64,11 +63,9 @@ unlink("$pgdata/${ts1UnloggedPath}")
$node->start; $node->start;
# check unlogged table in base # check unlogged table in base
ok(-f "$pgdata/${baseUnloggedPath}_init", ok(-f "$pgdata/${baseUnloggedPath}_init", 'init fork in base still exists');
'init fork in base still exists'); ok(-f "$pgdata/$baseUnloggedPath", 'main fork in base recreated at startup');
ok(-f "$pgdata/$baseUnloggedPath", ok(!-f "$pgdata/${baseUnloggedPath}_vm",
'main fork in base recreated at startup');
ok( !-f "$pgdata/${baseUnloggedPath}_vm",
'vm fork in base removed at startup'); 'vm fork in base removed at startup');
ok( !-f "$pgdata/${baseUnloggedPath}_fsm", ok( !-f "$pgdata/${baseUnloggedPath}_fsm",
'fsm fork in base removed at startup'); 'fsm fork in base removed at startup');
......
...@@ -41,7 +41,8 @@ sub test_connect_ok ...@@ -41,7 +41,8 @@ sub test_connect_ok
my ($common_connstr, $connstr, $test_name) = @_; my ($common_connstr, $connstr, $test_name) = @_;
my $cmd = [ my $cmd = [
'psql', '-X', '-A', '-t', '-c', "SELECT \$\$connected with $connstr\$\$", 'psql', '-X', '-A', '-t', '-c',
"SELECT \$\$connected with $connstr\$\$",
'-d', "$common_connstr $connstr" ]; '-d', "$common_connstr $connstr" ];
command_ok($cmd, $test_name); command_ok($cmd, $test_name);
...@@ -52,7 +53,8 @@ sub test_connect_fails ...@@ -52,7 +53,8 @@ sub test_connect_fails
my ($common_connstr, $connstr, $expected_stderr, $test_name) = @_; my ($common_connstr, $connstr, $expected_stderr, $test_name) = @_;
my $cmd = [ my $cmd = [
'psql', '-X', '-A', '-t', '-c', "SELECT \$\$connected with $connstr\$\$", '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); command_fails_like($cmd, $expected_stderr, $test_name);
...@@ -89,9 +91,11 @@ sub configure_test_server_for_ssl ...@@ -89,9 +91,11 @@ sub configure_test_server_for_ssl
if (defined($password)) if (defined($password))
{ {
$node->psql('postgres', $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', $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. # enable logging etc.
......
...@@ -53,25 +53,27 @@ configure_test_server_for_ssl($node, $SERVERHOSTADDR, 'trust'); ...@@ -53,25 +53,27 @@ configure_test_server_for_ssl($node, $SERVERHOSTADDR, 'trust');
note "testing password-protected keys"; note "testing password-protected keys";
open my $sslconf, '>', $node->data_dir."/sslconfig.conf"; open my $sslconf, '>', $node->data_dir . "/sslconfig.conf";
print $sslconf "ssl=on\n"; print $sslconf "ssl=on\n";
print $sslconf "ssl_cert_file='server-cn-only.crt'\n"; print $sslconf "ssl_cert_file='server-cn-only.crt'\n";
print $sslconf "ssl_key_file='server-password.key'\n"; print $sslconf "ssl_key_file='server-password.key'\n";
print $sslconf "ssl_passphrase_command='echo wrongpassword'\n"; print $sslconf "ssl_passphrase_command='echo wrongpassword'\n";
close $sslconf; close $sslconf;
command_fails(['pg_ctl', '-D', $node->data_dir, '-l', $node->logfile, 'restart'], command_fails(
[ 'pg_ctl', '-D', $node->data_dir, '-l', $node->logfile, 'restart' ],
'restart fails with password-protected key file with wrong password'); 'restart fails with password-protected key file with wrong password');
$node->_update_pid(0); $node->_update_pid(0);
open $sslconf, '>', $node->data_dir."/sslconfig.conf"; open $sslconf, '>', $node->data_dir . "/sslconfig.conf";
print $sslconf "ssl=on\n"; print $sslconf "ssl=on\n";
print $sslconf "ssl_cert_file='server-cn-only.crt'\n"; print $sslconf "ssl_cert_file='server-cn-only.crt'\n";
print $sslconf "ssl_key_file='server-password.key'\n"; print $sslconf "ssl_key_file='server-password.key'\n";
print $sslconf "ssl_passphrase_command='echo secret1'\n"; print $sslconf "ssl_passphrase_command='echo secret1'\n";
close $sslconf; close $sslconf;
command_ok(['pg_ctl', '-D', $node->data_dir, '-l', $node->logfile, 'restart'], command_ok(
[ 'pg_ctl', '-D', $node->data_dir, '-l', $node->logfile, 'restart' ],
'restart succeeds with password-protected key file'); 'restart succeeds with password-protected key file');
$node->_update_pid(1); $node->_update_pid(1);
...@@ -89,18 +91,25 @@ $common_connstr = ...@@ -89,18 +91,25 @@ $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test"; "user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test";
# The server should not accept non-SSL connections. # The server should not accept non-SSL connections.
test_connect_fails($common_connstr, "sslmode=disable", test_connect_fails(
$common_connstr, "sslmode=disable",
qr/\Qno pg_hba.conf entry\E/, qr/\Qno pg_hba.conf entry\E/,
"server doesn't accept non-SSL connections"); "server doesn't accept non-SSL connections");
# Try without a root cert. In sslmode=require, this should work. In verify-ca # Try without a root cert. In sslmode=require, this should work. In verify-ca
# or verify-full mode it should fail. # or verify-full mode it should fail.
test_connect_ok($common_connstr, "sslrootcert=invalid sslmode=require", test_connect_ok(
$common_connstr,
"sslrootcert=invalid sslmode=require",
"connect without server root cert sslmode=require"); "connect without server root cert sslmode=require");
test_connect_fails($common_connstr, "sslrootcert=invalid sslmode=verify-ca", test_connect_fails(
$common_connstr,
"sslrootcert=invalid sslmode=verify-ca",
qr/root certificate file "invalid" does not exist/, qr/root certificate file "invalid" does not exist/,
"connect without server root cert sslmode=verify-ca"); "connect without server root cert sslmode=verify-ca");
test_connect_fails($common_connstr, "sslrootcert=invalid sslmode=verify-full", test_connect_fails(
$common_connstr,
"sslrootcert=invalid sslmode=verify-full",
qr/root certificate file "invalid" does not exist/, qr/root certificate file "invalid" does not exist/,
"connect without server root cert sslmode=verify-full"); "connect without server root cert sslmode=verify-full");
...@@ -108,60 +117,64 @@ test_connect_fails($common_connstr, "sslrootcert=invalid sslmode=verify-full", ...@@ -108,60 +117,64 @@ test_connect_fails($common_connstr, "sslrootcert=invalid sslmode=verify-full",
# root, but the server's key is signed by the server CA.) # root, but the server's key is signed by the server CA.)
test_connect_fails($common_connstr, test_connect_fails($common_connstr,
"sslrootcert=ssl/client_ca.crt sslmode=require", "sslrootcert=ssl/client_ca.crt sslmode=require",
qr/SSL error/, qr/SSL error/, "connect with wrong server root cert sslmode=require");
"connect with wrong server root cert sslmode=require");
test_connect_fails($common_connstr, test_connect_fails($common_connstr,
"sslrootcert=ssl/client_ca.crt sslmode=verify-ca", "sslrootcert=ssl/client_ca.crt sslmode=verify-ca",
qr/SSL error/, qr/SSL error/, "connect with wrong server root cert sslmode=verify-ca");
"connect with wrong server root cert sslmode=verify-ca");
test_connect_fails($common_connstr, test_connect_fails($common_connstr,
"sslrootcert=ssl/client_ca.crt sslmode=verify-full", "sslrootcert=ssl/client_ca.crt sslmode=verify-full",
qr/SSL error/, qr/SSL error/, "connect with wrong server root cert sslmode=verify-full");
"connect with wrong server root cert sslmode=verify-full");
# Try with just the server CA's cert. This fails because the root file # Try with just the server CA's cert. This fails because the root file
# must contain the whole chain up to the root CA. # must contain the whole chain up to the root CA.
test_connect_fails($common_connstr, test_connect_fails($common_connstr,
"sslrootcert=ssl/server_ca.crt sslmode=verify-ca", "sslrootcert=ssl/server_ca.crt sslmode=verify-ca",
qr/SSL error/, qr/SSL error/, "connect with server CA cert, without root CA");
"connect with server CA cert, without root CA");
# And finally, with the correct root cert. # And finally, with the correct root cert.
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=require", "sslrootcert=ssl/root+server_ca.crt sslmode=require",
"connect with correct server CA cert file sslmode=require"); "connect with correct server CA cert file sslmode=require");
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca", "sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca",
"connect with correct server CA cert file sslmode=verify-ca"); "connect with correct server CA cert file sslmode=verify-ca");
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-full", "sslrootcert=ssl/root+server_ca.crt sslmode=verify-full",
"connect with correct server CA cert file sslmode=verify-full"); "connect with correct server CA cert file sslmode=verify-full");
# Test with cert root file that contains two certificates. The client should # Test with cert root file that contains two certificates. The client should
# be able to pick the right one, regardless of the order in the file. # be able to pick the right one, regardless of the order in the file.
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/both-cas-1.crt sslmode=verify-ca", "sslrootcert=ssl/both-cas-1.crt sslmode=verify-ca",
"cert root file that contains two certificates, order 1"); "cert root file that contains two certificates, order 1");
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/both-cas-2.crt sslmode=verify-ca", "sslrootcert=ssl/both-cas-2.crt sslmode=verify-ca",
"cert root file that contains two certificates, order 2"); "cert root file that contains two certificates, order 2");
# CRL tests # CRL tests
# Invalid CRL filename is the same as no CRL, succeeds # Invalid CRL filename is the same as no CRL, succeeds
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=invalid", "sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=invalid",
"sslcrl option with invalid file name"); "sslcrl option with invalid file name");
# A CRL belonging to a different CA is not accepted, fails # A CRL belonging to a different CA is not accepted, fails
test_connect_fails($common_connstr, test_connect_fails(
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/client.crl", $common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/client.crl",
qr/SSL error/, qr/SSL error/,
"CRL belonging to a different CA"); "CRL belonging to a different CA");
# With the correct CRL, succeeds (this cert is not revoked) # With the correct CRL, succeeds (this cert is not revoked)
test_connect_ok($common_connstr, test_connect_ok(
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl", $common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl",
"CRL with a non-revoked cert"); "CRL with a non-revoked cert");
# Check that connecting with verify-full fails, when the hostname doesn't # Check that connecting with verify-full fails, when the hostname doesn't
...@@ -169,12 +182,18 @@ test_connect_ok($common_connstr, ...@@ -169,12 +182,18 @@ test_connect_ok($common_connstr,
$common_connstr = $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR"; "user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
test_connect_ok($common_connstr, "sslmode=require host=wronghost.test", test_connect_ok(
$common_connstr,
"sslmode=require host=wronghost.test",
"mismatch between host name and server certificate sslmode=require"); "mismatch between host name and server certificate sslmode=require");
test_connect_ok($common_connstr, "sslmode=verify-ca host=wronghost.test", test_connect_ok(
$common_connstr,
"sslmode=verify-ca host=wronghost.test",
"mismatch between host name and server certificate sslmode=verify-ca"); "mismatch between host name and server certificate sslmode=verify-ca");
test_connect_fails($common_connstr, "sslmode=verify-full host=wronghost.test", test_connect_fails(
qr/\Qserver certificate for "common-name.pg-ssltest.test" does not match host name "wronghost.test"\E/, $common_connstr,
"sslmode=verify-full host=wronghost.test",
qr/\Qserver certificate for "common-name.pg-ssltest.test" does not match host name "wronghost.test"\E/,
"mismatch between host name and server certificate sslmode=verify-full"); "mismatch between host name and server certificate sslmode=verify-full");
# Test Subject Alternative Names. # Test Subject Alternative Names.
...@@ -183,19 +202,28 @@ switch_server_cert($node, 'server-multiple-alt-names'); ...@@ -183,19 +202,28 @@ switch_server_cert($node, 'server-multiple-alt-names');
$common_connstr = $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full"; "user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
test_connect_ok($common_connstr, "host=dns1.alt-name.pg-ssltest.test", test_connect_ok(
$common_connstr,
"host=dns1.alt-name.pg-ssltest.test",
"host name matching with X.509 Subject Alternative Names 1"); "host name matching with X.509 Subject Alternative Names 1");
test_connect_ok($common_connstr, "host=dns2.alt-name.pg-ssltest.test", test_connect_ok(
$common_connstr,
"host=dns2.alt-name.pg-ssltest.test",
"host name matching with X.509 Subject Alternative Names 2"); "host name matching with X.509 Subject Alternative Names 2");
test_connect_ok($common_connstr, "host=foo.wildcard.pg-ssltest.test", test_connect_ok(
$common_connstr,
"host=foo.wildcard.pg-ssltest.test",
"host name matching with X.509 Subject Alternative Names wildcard"); "host name matching with X.509 Subject Alternative Names wildcard");
test_connect_fails($common_connstr, "host=wronghost.alt-name.pg-ssltest.test", test_connect_fails(
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "wronghost.alt-name.pg-ssltest.test"\E/, $common_connstr,
"host=wronghost.alt-name.pg-ssltest.test",
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "wronghost.alt-name.pg-ssltest.test"\E/,
"host name not matching with X.509 Subject Alternative Names"); "host name not matching with X.509 Subject Alternative Names");
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"host=deep.subdomain.wildcard.pg-ssltest.test", "host=deep.subdomain.wildcard.pg-ssltest.test",
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/, qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 2 other names) does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/,
"host name not matching with X.509 Subject Alternative Names wildcard"); "host name not matching with X.509 Subject Alternative Names wildcard");
# Test certificate with a single Subject Alternative Name. (this gives a # Test certificate with a single Subject Alternative Name. (this gives a
...@@ -205,16 +233,22 @@ switch_server_cert($node, 'server-single-alt-name'); ...@@ -205,16 +233,22 @@ switch_server_cert($node, 'server-single-alt-name');
$common_connstr = $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full"; "user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
test_connect_ok($common_connstr, "host=single.alt-name.pg-ssltest.test", test_connect_ok(
$common_connstr,
"host=single.alt-name.pg-ssltest.test",
"host name matching with a single X.509 Subject Alternative Name"); "host name matching with a single X.509 Subject Alternative Name");
test_connect_fails($common_connstr, "host=wronghost.alt-name.pg-ssltest.test", test_connect_fails(
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "wronghost.alt-name.pg-ssltest.test"\E/, $common_connstr,
"host=wronghost.alt-name.pg-ssltest.test",
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "wronghost.alt-name.pg-ssltest.test"\E/,
"host name not matching with a single X.509 Subject Alternative Name"); "host name not matching with a single X.509 Subject Alternative Name");
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"host=deep.subdomain.wildcard.pg-ssltest.test", "host=deep.subdomain.wildcard.pg-ssltest.test",
qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/, qr/\Qserver certificate for "single.alt-name.pg-ssltest.test" does not match host name "deep.subdomain.wildcard.pg-ssltest.test"\E/,
"host name not matching with a single X.509 Subject Alternative Name wildcard"); "host name not matching with a single X.509 Subject Alternative Name wildcard"
);
# Test server certificate with a CN and SANs. Per RFCs 2818 and 6125, the CN # Test server certificate with a CN and SANs. Per RFCs 2818 and 6125, the CN
# should be ignored when the certificate has both. # should be ignored when the certificate has both.
...@@ -223,12 +257,18 @@ switch_server_cert($node, 'server-cn-and-alt-names'); ...@@ -223,12 +257,18 @@ switch_server_cert($node, 'server-cn-and-alt-names');
$common_connstr = $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full"; "user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR sslmode=verify-full";
test_connect_ok($common_connstr, "host=dns1.alt-name.pg-ssltest.test", test_connect_ok(
$common_connstr,
"host=dns1.alt-name.pg-ssltest.test",
"certificate with both a CN and SANs 1"); "certificate with both a CN and SANs 1");
test_connect_ok($common_connstr, "host=dns2.alt-name.pg-ssltest.test", test_connect_ok(
$common_connstr,
"host=dns2.alt-name.pg-ssltest.test",
"certificate with both a CN and SANs 2"); "certificate with both a CN and SANs 2");
test_connect_fails($common_connstr, "host=common-name.pg-ssltest.test", test_connect_fails(
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 1 other name) does not match host name "common-name.pg-ssltest.test"\E/, $common_connstr,
"host=common-name.pg-ssltest.test",
qr/\Qserver certificate for "dns1.alt-name.pg-ssltest.test" (and 1 other name) does not match host name "common-name.pg-ssltest.test"\E/,
"certificate with both a CN and SANs ignores CN"); "certificate with both a CN and SANs ignores CN");
# Finally, test a server certificate that has no CN or SANs. Of course, that's # Finally, test a server certificate that has no CN or SANs. Of course, that's
...@@ -237,10 +277,12 @@ switch_server_cert($node, 'server-no-names'); ...@@ -237,10 +277,12 @@ switch_server_cert($node, 'server-no-names');
$common_connstr = $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR"; "user=ssltestuser dbname=trustdb sslcert=invalid sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslmode=verify-ca host=common-name.pg-ssltest.test", "sslmode=verify-ca host=common-name.pg-ssltest.test",
"server certificate without CN or SANs sslmode=verify-ca"); "server certificate without CN or SANs sslmode=verify-ca");
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"sslmode=verify-full host=common-name.pg-ssltest.test", "sslmode=verify-full host=common-name.pg-ssltest.test",
qr/could not get server's host name from server certificate/, qr/could not get server's host name from server certificate/,
"server certificate without CN or SANs sslmode=verify-full"); "server certificate without CN or SANs sslmode=verify-full");
...@@ -252,11 +294,13 @@ $common_connstr = ...@@ -252,11 +294,13 @@ $common_connstr =
"user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test"; "user=ssltestuser dbname=trustdb sslcert=invalid hostaddr=$SERVERHOSTADDR host=common-name.pg-ssltest.test";
# Without the CRL, succeeds. With it, fails. # Without the CRL, succeeds. With it, fails.
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca", "sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca",
"connects without client-side CRL"); "connects without client-side CRL");
test_connect_fails($common_connstr, test_connect_fails(
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl", $common_connstr,
"sslrootcert=ssl/root+server_ca.crt sslmode=verify-ca sslcrl=ssl/root+server.crl",
qr/SSL error/, qr/SSL error/,
"does not connect with client-side CRL"); "does not connect with client-side CRL");
...@@ -270,31 +314,36 @@ $common_connstr = ...@@ -270,31 +314,36 @@ $common_connstr =
"sslrootcert=ssl/root+server_ca.crt sslmode=require dbname=certdb hostaddr=$SERVERHOSTADDR"; "sslrootcert=ssl/root+server_ca.crt sslmode=require dbname=certdb hostaddr=$SERVERHOSTADDR";
# no client cert # no client cert
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"user=ssltestuser sslcert=invalid", "user=ssltestuser sslcert=invalid",
qr/connection requires a valid client certificate/, qr/connection requires a valid client certificate/,
"certificate authorization fails without client cert"); "certificate authorization fails without client cert");
# correct client cert # correct client cert
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key", "user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
"certificate authorization succeeds with correct client cert"); "certificate authorization succeeds with correct client cert");
# client key with wrong permissions # client key with wrong permissions
test_connect_fails($common_connstr, test_connect_fails(
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_wrongperms_tmp.key", $common_connstr,
qr!\Qprivate key file "ssl/client_wrongperms_tmp.key" has group or world access\E!, "user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_wrongperms_tmp.key",
qr!\Qprivate key file "ssl/client_wrongperms_tmp.key" has group or world access\E!,
"certificate authorization fails because of file permissions"); "certificate authorization fails because of file permissions");
# client cert belonging to another user # client cert belonging to another user
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"user=anotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key", "user=anotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
qr/certificate authentication failed for user "anotheruser"/, qr/certificate authentication failed for user "anotheruser"/,
"certificate authorization fails with client cert belonging to another user"); "certificate authorization fails with client cert belonging to another user");
# revoked client cert # revoked client cert
test_connect_fails($common_connstr, test_connect_fails(
"user=ssltestuser sslcert=ssl/client-revoked.crt sslkey=ssl/client-revoked_tmp.key", $common_connstr,
"user=ssltestuser sslcert=ssl/client-revoked.crt sslkey=ssl/client-revoked_tmp.key",
qr/SSL error/, qr/SSL error/,
"certificate authorization fails with revoked client cert"); "certificate authorization fails with revoked client cert");
...@@ -303,14 +352,13 @@ switch_server_cert($node, 'server-cn-only', 'root_ca'); ...@@ -303,14 +352,13 @@ switch_server_cert($node, 'server-cn-only', 'root_ca');
$common_connstr = $common_connstr =
"user=ssltestuser dbname=certdb sslkey=ssl/client_tmp.key sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR"; "user=ssltestuser dbname=certdb sslkey=ssl/client_tmp.key sslrootcert=ssl/root+server_ca.crt hostaddr=$SERVERHOSTADDR";
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"sslmode=require sslcert=ssl/client+client_ca.crt", "sslmode=require sslcert=ssl/client+client_ca.crt",
"intermediate client certificate is provided by client"); "intermediate client certificate is provided by client");
test_connect_fails($common_connstr, "sslmode=require sslcert=ssl/client.crt", test_connect_fails($common_connstr, "sslmode=require sslcert=ssl/client.crt",
qr/SSL error/, qr/SSL error/, "intermediate client certificate is missing");
"intermediate client certificate is missing");
# clean up # clean up
unlink("ssl/client_tmp.key", unlink("ssl/client_tmp.key", "ssl/client_wrongperms_tmp.key",
"ssl/client_wrongperms_tmp.key",
"ssl/client-revoked_tmp.key"); "ssl/client-revoked_tmp.key");
...@@ -43,34 +43,37 @@ configure_test_server_for_ssl($node, $SERVERHOSTADDR, "scram-sha-256", ...@@ -43,34 +43,37 @@ configure_test_server_for_ssl($node, $SERVERHOSTADDR, "scram-sha-256",
switch_server_cert($node, 'server-cn-only'); switch_server_cert($node, 'server-cn-only');
$ENV{PGPASSWORD} = "pass"; $ENV{PGPASSWORD} = "pass";
$common_connstr = $common_connstr =
"user=ssltestuser dbname=trustdb sslmode=require hostaddr=$SERVERHOSTADDR"; "user=ssltestuser dbname=trustdb sslmode=require hostaddr=$SERVERHOSTADDR";
# Default settings # Default settings
test_connect_ok($common_connstr, '', test_connect_ok($common_connstr, '',
"SCRAM authentication with default channel binding"); "SCRAM authentication with default channel binding");
# Channel binding settings # Channel binding settings
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"scram_channel_binding=tls-unique", "scram_channel_binding=tls-unique",
"SCRAM authentication with tls-unique as channel binding"); "SCRAM authentication with tls-unique as channel binding");
test_connect_ok($common_connstr, test_connect_ok($common_connstr, "scram_channel_binding=''",
"scram_channel_binding=''",
"SCRAM authentication without channel binding"); "SCRAM authentication without channel binding");
if ($supports_tls_server_end_point) if ($supports_tls_server_end_point)
{ {
test_connect_ok($common_connstr, test_connect_ok(
$common_connstr,
"scram_channel_binding=tls-server-end-point", "scram_channel_binding=tls-server-end-point",
"SCRAM authentication with tls-server-end-point as channel binding"); "SCRAM authentication with tls-server-end-point as channel binding");
} }
else else
{ {
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"scram_channel_binding=tls-server-end-point", "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"); "SCRAM authentication with tls-server-end-point as channel binding");
$number_of_tests++; $number_of_tests++;
} }
test_connect_fails($common_connstr, test_connect_fails(
$common_connstr,
"scram_channel_binding=not-exists", "scram_channel_binding=not-exists",
qr/unsupported SCRAM channel-binding type/, qr/unsupported SCRAM channel-binding type/,
"SCRAM authentication with invalid channel binding"); "SCRAM authentication with invalid channel binding");
......
...@@ -32,7 +32,8 @@ $node_publisher->safe_psql('postgres', ...@@ -32,7 +32,8 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres',
"INSERT INTO tab_mixed (a, b) VALUES (1, 'foo')"); "INSERT INTO tab_mixed (a, b) VALUES (1, 'foo')");
$node_publisher->safe_psql('postgres', $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 # Setup structure on subscriber
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_notrep (a int)"); $node_subscriber->safe_psql('postgres', "CREATE TABLE tab_notrep (a int)");
...@@ -48,7 +49,8 @@ $node_subscriber->safe_psql('postgres', ...@@ -48,7 +49,8 @@ $node_subscriber->safe_psql('postgres',
# replication of the table with included index # replication of the table with included index
$node_subscriber->safe_psql('postgres', $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 # Setup logical replication
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
...@@ -97,7 +99,8 @@ $node_publisher->safe_psql('postgres', ...@@ -97,7 +99,8 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres',
"INSERT INTO tab_include SELECT generate_series(1,50)"); "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->safe_psql('postgres', "UPDATE tab_include SET a = -a");
$node_publisher->wait_for_catchup($appname); $node_publisher->wait_for_catchup($appname);
...@@ -117,7 +120,8 @@ is( $result, qq(|foo|1 ...@@ -117,7 +120,8 @@ is( $result, qq(|foo|1
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab_include"); "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 # insert some duplicate rows
$node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres',
......
...@@ -34,7 +34,7 @@ $node_publisher->wait_for_catchup($appname); ...@@ -34,7 +34,7 @@ $node_publisher->wait_for_catchup($appname);
# Wait for initial sync to finish as well # Wait for initial sync to finish as well
my $synced_query = 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) $node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data"; or die "Timed out while waiting for subscriber to synchronize data";
......
...@@ -30,15 +30,16 @@ $node_publisher->wait_for_catchup($appname); ...@@ -30,15 +30,16 @@ $node_publisher->wait_for_catchup($appname);
# Wait for initial sync to finish as well # Wait for initial sync to finish as well
my $synced_query = 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) $node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data"; 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); $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 qq(1|one
2|two), 2|two),
'initial data replicated to subscriber'); 'initial data replicated to subscriber');
...@@ -50,11 +51,12 @@ $node_publisher->safe_psql('postgres', $ddl2); ...@@ -50,11 +51,12 @@ $node_publisher->safe_psql('postgres', $ddl2);
$node_publisher->wait_for_catchup($appname); $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); $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 qq(1|one|0
2|two|0 2|two|0
3|three|33), 3|three|33),
......
...@@ -28,7 +28,8 @@ $node_subscriber->safe_psql('postgres', ...@@ -28,7 +28,8 @@ $node_subscriber->safe_psql('postgres',
$node_publisher->wait_for_catchup($appname); $node_publisher->wait_for_catchup($appname);
$node_subscriber->safe_psql('postgres', q{ $node_subscriber->safe_psql(
'postgres', q{
BEGIN; BEGIN;
ALTER SUBSCRIPTION mysub DISABLE; ALTER SUBSCRIPTION mysub DISABLE;
ALTER SUBSCRIPTION mysub SET (slot_name = NONE); ALTER SUBSCRIPTION mysub SET (slot_name = NONE);
......
...@@ -22,11 +22,14 @@ $node_publisher->safe_psql('postgres', ...@@ -22,11 +22,14 @@ $node_publisher->safe_psql('postgres',
"INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')"); "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
# Setup structure on subscriber # 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 # Setup logical replication
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; 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'; my $appname = 'tap_sub';
$node_subscriber->safe_psql('postgres', $node_subscriber->safe_psql('postgres',
...@@ -42,7 +45,8 @@ $node_subscriber->poll_query_until('postgres', $synced_query) ...@@ -42,7 +45,8 @@ $node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data"; or die "Timed out while waiting for subscriber to synchronize data";
my $result = 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'); 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 # 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)"); ...@@ -52,19 +56,25 @@ $node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = md5(b)");
$node_publisher->wait_for_catchup($appname); $node_publisher->wait_for_catchup($appname);
$result = $result =
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab"); $node_subscriber->safe_psql('postgres',
is($result, qq(2|2|2|2), 'check extra columns contain local defaults after copy'); "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, # Change the local values of the extra columns on the subscriber,
# update publisher, and check that subscriber retains the expected # update publisher, and check that subscriber retains the expected
# values # values
$node_subscriber->safe_psql('postgres', "UPDATE test_tab SET c = 'epoch'::timestamptz + 987654321 * interval '1s'"); $node_subscriber->safe_psql('postgres',
$node_publisher->safe_psql('postgres', "UPDATE test_tab SET b = md5(a::text)"); "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); $node_publisher->wait_for_catchup($appname);
$result = $result = $node_subscriber->safe_psql('postgres',
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab"); "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'); is($result, qq(2|2|2), 'check extra columns contain locally changed data');
# Another insert # Another insert
...@@ -74,8 +84,10 @@ $node_publisher->safe_psql('postgres', ...@@ -74,8 +84,10 @@ $node_publisher->safe_psql('postgres',
$node_publisher->wait_for_catchup($appname); $node_publisher->wait_for_catchup($appname);
$result = $result =
$node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab"); $node_subscriber->safe_psql('postgres',
is($result, qq(3|3|3|3), 'check extra columns contain local defaults after apply'); "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_subscriber->stop;
$node_publisher->stop; $node_publisher->stop;
...@@ -22,10 +22,13 @@ $node_subscriber->safe_psql('postgres', ...@@ -22,10 +22,13 @@ $node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;" "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',
$node_publisher->safe_psql('postgres', q{INSERT INTO test1 (a, b) VALUES (1, 'one'), (2, 'two');}); 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); $node_publisher->wait_for_catchup($appname);
...@@ -34,8 +37,10 @@ $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) # need to make sure they are properly ignored. (bug #15044)
# create a MV with some data # 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); $node_publisher->wait_for_catchup($appname);
# There is no equivalent relation on the subscriber, but MV data is # There is no equivalent relation on the subscriber, but MV data is
# not replicated, so this does not hang. # not replicated, so this does not hang.
......
...@@ -42,11 +42,8 @@ $node_subscriber->safe_psql('postgres', ...@@ -42,11 +42,8 @@ $node_subscriber->safe_psql('postgres',
"CREATE TABLE tab4 (x int PRIMARY KEY, y int REFERENCES tab3)"); "CREATE TABLE tab4 (x int PRIMARY KEY, y int REFERENCES tab3)");
$node_subscriber->safe_psql('postgres', $node_subscriber->safe_psql('postgres',
"CREATE SEQUENCE seq1 OWNED BY tab1.a" "CREATE SEQUENCE seq1 OWNED BY tab1.a");
); $node_subscriber->safe_psql('postgres', "ALTER SEQUENCE seq1 START 101");
$node_subscriber->safe_psql('postgres',
"ALTER SEQUENCE seq1 START 101"
);
$node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub1 FOR TABLE tab1"); "CREATE PUBLICATION pub1 FOR TABLE tab1");
...@@ -55,11 +52,14 @@ $node_publisher->safe_psql('postgres', ...@@ -55,11 +52,14 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub3 FOR TABLE tab3, tab4"); "CREATE PUBLICATION pub3 FOR TABLE tab3, tab4");
$node_subscriber->safe_psql('postgres', $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', $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', $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 # Wait for initial sync of all subscriptions
my $synced_query = my $synced_query =
...@@ -69,7 +69,8 @@ $node_subscriber->poll_query_until('postgres', $synced_query) ...@@ -69,7 +69,8 @@ $node_subscriber->poll_query_until('postgres', $synced_query)
# insert data to truncate # 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'); $node_publisher->wait_for_catchup('sub1');
...@@ -81,13 +82,10 @@ $node_publisher->wait_for_catchup('sub1'); ...@@ -81,13 +82,10 @@ $node_publisher->wait_for_catchup('sub1');
my $result = $node_subscriber->safe_psql('postgres', my $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab1"); "SELECT count(*), min(a), max(a) FROM tab1");
is($result, qq(0||), is($result, qq(0||), 'truncate replicated');
'truncate replicated');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres', "SELECT nextval('seq1')");
"SELECT nextval('seq1')"); is($result, qq(1), 'sequence not restarted');
is($result, qq(1),
'sequence not restarted');
# truncate with restart identity # truncate with restart identity
...@@ -95,14 +93,13 @@ $node_publisher->safe_psql('postgres', "TRUNCATE tab1 RESTART IDENTITY"); ...@@ -95,14 +93,13 @@ $node_publisher->safe_psql('postgres', "TRUNCATE tab1 RESTART IDENTITY");
$node_publisher->wait_for_catchup('sub1'); $node_publisher->wait_for_catchup('sub1');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres', "SELECT nextval('seq1')");
"SELECT nextval('seq1')"); is($result, qq(101), 'truncate restarted identities');
is($result, qq(101),
'truncate restarted identities');
# test publication that does not replicate truncate # 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"); $node_publisher->safe_psql('postgres', "TRUNCATE tab2");
...@@ -110,8 +107,7 @@ $node_publisher->wait_for_catchup('sub2'); ...@@ -110,8 +107,7 @@ $node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab2"); "SELECT count(*), min(a), max(a) FROM tab2");
is($result, qq(3|1|3), is($result, qq(3|1|3), 'truncate not replicated');
'truncate not replicated');
$node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres',
"ALTER PUBLICATION pub2 SET (publish = 'insert, truncate')"); "ALTER PUBLICATION pub2 SET (publish = 'insert, truncate')");
...@@ -122,13 +118,14 @@ $node_publisher->wait_for_catchup('sub2'); ...@@ -122,13 +118,14 @@ $node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab2"); "SELECT count(*), min(a), max(a) FROM tab2");
is($result, qq(0||), is($result, qq(0||), 'truncate replicated after publication change');
'truncate replicated after publication change');
# test multiple tables connected by foreign keys # test multiple tables connected by foreign keys
$node_subscriber->safe_psql('postgres', "INSERT INTO tab3 VALUES (1), (2), (3)"); $node_subscriber->safe_psql('postgres',
$node_subscriber->safe_psql('postgres', "INSERT INTO tab4 VALUES (11, 1), (111, 1), (22, 2)"); "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"); $node_publisher->safe_psql('postgres', "TRUNCATE tab3, tab4");
...@@ -136,20 +133,20 @@ $node_publisher->wait_for_catchup('sub3'); ...@@ -136,20 +133,20 @@ $node_publisher->wait_for_catchup('sub3');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab3"); "SELECT count(*), min(a), max(a) FROM tab3");
is($result, qq(0||), is($result, qq(0||), 'truncate of multiple tables replicated');
'truncate of multiple tables replicated');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(x), max(x) FROM tab4"); "SELECT count(*), min(x), max(x) FROM tab4");
is($result, qq(0||), is($result, qq(0||), 'truncate of multiple tables replicated');
'truncate of multiple tables replicated');
# test truncate of multiple tables, some of which are not published # test truncate of multiple tables, some of which are not published
$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION sub2"); $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION sub2");
$node_publisher->safe_psql('postgres', "DROP PUBLICATION pub2"); $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',
$node_subscriber->safe_psql('postgres', "INSERT INTO tab2 VALUES (1), (2), (3)"); "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"); $node_publisher->safe_psql('postgres', "TRUNCATE tab1, tab2");
...@@ -157,9 +154,7 @@ $node_publisher->wait_for_catchup('sub1'); ...@@ -157,9 +154,7 @@ $node_publisher->wait_for_catchup('sub1');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab1"); "SELECT count(*), min(a), max(a) FROM tab1");
is($result, qq(0||), is($result, qq(0||), 'truncate of multiple tables some not published');
'truncate of multiple tables some not published');
$result = $node_subscriber->safe_psql('postgres', $result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab2"); "SELECT count(*), min(a), max(a) FROM tab2");
is($result, qq(3|1|3), is($result, qq(3|1|3), 'truncate of multiple tables some not published');
'truncate of multiple tables some not published');
...@@ -102,7 +102,7 @@ my %rel_tags; ...@@ -102,7 +102,7 @@ my %rel_tags;
{ {
my $commit = $1; my $commit = $1;
my $tag = $2; my $tag = $2;
if ($tag =~ /^REL_\d+_\d+$/ if ( $tag =~ /^REL_\d+_\d+$/
|| $tag =~ /^REL\d+_\d+$/ || $tag =~ /^REL\d+_\d+$/
|| $tag =~ /^REL\d+_\d+_\d+$/) || $tag =~ /^REL\d+_\d+_\d+$/)
{ {
......
...@@ -530,11 +530,12 @@ sub mkvcbuild ...@@ -530,11 +530,12 @@ sub mkvcbuild
my $perl_path = $solution->{options}->{perl} . '\lib\CORE\*perl*'; my $perl_path = $solution->{options}->{perl} . '\lib\CORE\*perl*';
# ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a # ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a
# Starting with ActivePerl 5.24, both perlnn.lib and libperlnn.a are provided. # Starting with ActivePerl 5.24, both perlnn.lib and libperlnn.a are provided.
# In this case, prefer .lib. # In this case, prefer .lib.
my @perl_libs = 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) if (@perl_libs > 0)
{ {
$plperl->AddLibrary($perl_libs[0]); $plperl->AddLibrary($perl_libs[0]);
......
...@@ -176,8 +176,7 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c ...@@ -176,8 +176,7 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c
"\n"; "\n";
print $o "#define RELSEG_SIZE ", print $o "#define RELSEG_SIZE ",
(1024 / $self->{options}->{blocksize}) * (1024 / $self->{options}->{blocksize}) *
$self->{options}->{segsize} * $self->{options}->{segsize} * 1024, "\n";
1024, "\n";
print $o "#define XLOG_BLCKSZ ", print $o "#define XLOG_BLCKSZ ",
1024 * $self->{options}->{wal_blocksize}, "\n"; 1024 * $self->{options}->{wal_blocksize}, "\n";
...@@ -267,16 +266,13 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c ...@@ -267,16 +266,13 @@ s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, c
chdir('src/backend/utils'); chdir('src/backend/utils');
my $pg_language_dat = '../../../src/include/catalog/pg_language.dat'; my $pg_language_dat = '../../../src/include/catalog/pg_language.dat';
my $pg_proc_dat = '../../../src/include/catalog/pg_proc.dat'; my $pg_proc_dat = '../../../src/include/catalog/pg_proc.dat';
if (IsNewer( if ( IsNewer('fmgrtab.c', $pg_language_dat)
'fmgrtab.c', $pg_language_dat) || IsNewer('fmgrtab.c', $pg_proc_dat)
|| IsNewer( || IsNewer('fmgrtab.c', '../../../src/include/access/transam.h'))
'fmgrtab.c', $pg_proc_dat)
|| IsNewer(
'fmgrtab.c', '../../../src/include/access/transam.h')
)
{ {
system( 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('../../..'); chdir('../../..');
...@@ -471,6 +467,7 @@ EOF ...@@ -471,6 +467,7 @@ EOF
$mf =~ /^POSTGRES_BKI_DATA\s*:?=[^,]+,(.*)\)$/gm $mf =~ /^POSTGRES_BKI_DATA\s*:?=[^,]+,(.*)\)$/gm
|| croak "Could not find POSTGRES_BKI_DATA in Makefile\n"; || croak "Could not find POSTGRES_BKI_DATA in Makefile\n";
my @bki_data = split /\s+/, $1; my @bki_data = split /\s+/, $1;
foreach my $bki (@bki_srcs, @bki_data) foreach my $bki (@bki_srcs, @bki_data)
{ {
next if $bki eq ""; next if $bki eq "";
...@@ -480,7 +477,8 @@ EOF ...@@ -480,7 +477,8 @@ EOF
{ {
chdir('src/backend/catalog'); chdir('src/backend/catalog');
my $bki_srcs = join(' ../../../src/include/catalog/', @bki_srcs); 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('../../..'); chdir('../../..');
# Copy generated headers to include directory. # Copy generated headers to include directory.
......
...@@ -53,8 +53,10 @@ sub CreateSolution ...@@ -53,8 +53,10 @@ sub CreateSolution
{ {
return new VS2015Solution(@_); 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(@_); return new VS2017Solution(@_);
} }
...@@ -98,8 +100,10 @@ sub CreateProject ...@@ -98,8 +100,10 @@ sub CreateProject
{ {
return new VC2015Project(@_); 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(@_); return new VC2017Project(@_);
} }
...@@ -132,7 +136,8 @@ sub DetermineVisualStudioVersion ...@@ -132,7 +136,8 @@ sub DetermineVisualStudioVersion
sub _GetVisualStudioVersion sub _GetVisualStudioVersion
{ {
my ($major, $minor) = @_; 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) if ($major > 14)
{ {
carp carp
......
...@@ -254,13 +254,16 @@ sub plcheck ...@@ -254,13 +254,16 @@ sub plcheck
{ {
next unless -d "$dir/sql" && -d "$dir/expected"; next unless -d "$dir/sql" && -d "$dir/expected";
my $lang; my $lang;
if ($dir eq 'plpgsql/src') { if ($dir eq 'plpgsql/src')
{
$lang = 'plpgsql'; $lang = 'plpgsql';
} }
elsif ($dir eq 'tcl') { elsif ($dir eq 'tcl')
{
$lang = 'pltcl'; $lang = 'pltcl';
} }
else { else
{
$lang = $dir; $lang = $dir;
} }
if ($lang eq 'plpython') if ($lang eq 'plpython')
......
...@@ -59,8 +59,7 @@ $excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns" ...@@ -59,8 +59,7 @@ $excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns"
# easier to configure. Note that the typedefs need trailing newlines. # easier to configure. Note that the typedefs need trailing newlines.
my @whitelist = ("bool\n"); my @whitelist = ("bool\n");
my %blacklist = map { +"$_\n" => 1 } my %blacklist = map { +"$_\n" => 1 } qw( FD_SET date interval timestamp ANY
qw( FD_SET date interval timestamp ANY
abs allocfunc iterator other pointer printfunc reference string type ); abs allocfunc iterator other pointer printfunc reference string type );
# globals # globals
...@@ -135,7 +134,7 @@ sub load_typedefs ...@@ -135,7 +134,7 @@ sub load_typedefs
push(@typedefs, @whitelist); push(@typedefs, @whitelist);
# remove blacklisted entries # remove blacklisted entries
@typedefs = grep { ! $blacklist{$_} } @typedefs; @typedefs = grep { !$blacklist{$_} } @typedefs;
# write filtered typedefs # write filtered typedefs
my $filter_typedefs_fh = new File::Temp(TEMPLATE => "pgtypedefXXXXX"); 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