Commit 6af8b89a authored by Stephen Frost's avatar Stephen Frost

perltidy pg_dump TAP tests

The pg_dump TAP tests have gotten pretty far from what perltidy thinks
they should be, so fix that, and in passing use long-form argument names
with arguments passed via "=" in a similar vein to 58da8334.

No functional changes here, just whitespace and changing runs from
"-f" to "--file=", and similar.
parent 58da8334
......@@ -49,11 +49,9 @@ command_exit_is(
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
);
command_exit_is(
[ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
command_exit_is([ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
1,
'pg_restore: options -d/--dbname and -f/--file cannot be used together'
);
'pg_restore: options -d/--dbname and -f/--file cannot be used together');
command_exit_is(
[ 'pg_dump', '-c', '-a' ],
......@@ -63,7 +61,7 @@ command_exit_is(
command_exit_is(
[ 'pg_restore', '-c', '-a' ],
1,
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
command_exit_is(
[ 'pg_dump', '--inserts', '-o' ],
......@@ -80,8 +78,10 @@ command_exit_is([ 'pg_dump', '-j' ],
command_exit_is([ 'pg_dump', '-j3' ],
1, 'pg_dump: parallel backup only supported by the directory format');
command_exit_is([ 'pg_restore', '--single-transaction', '-j3' ],
1, 'pg_restore: cannot specify both --single-transaction and multiple jobs');
command_exit_is(
[ 'pg_restore', '--single-transaction', '-j3' ],
1,
'pg_restore: cannot specify both --single-transaction and multiple jobs');
command_exit_is([ 'pg_restore', '--if-exists' ],
1, 'pg_restore: option --if-exists requires option -c/--clean');
......
......@@ -39,7 +39,7 @@ my %pgdump_runs = (
binary_upgrade => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/binary_upgrade.sql",
"--file=$tempdir/binary_upgrade.sql",
'--schema-only',
'--binary-upgrade',
'-d', 'postgres', # alternative way to specify database
......@@ -47,34 +47,34 @@ my %pgdump_runs = (
clean => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/clean.sql",
"--file=$tempdir/clean.sql",
'-c',
'-d', 'postgres', # alternative way to specify database
], },
clean_if_exists => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/clean_if_exists.sql",
"--file=$tempdir/clean_if_exists.sql",
'-c',
'--if-exists',
'-E', 'UTF8', # no-op, just tests that option is accepted
'--encoding=UTF8', # no-op, just tests that option is accepted
'postgres', ], },
column_inserts => {
dump_cmd => [
'pg_dump', '-f',
"$tempdir/column_inserts.sql", '-a',
'--column-inserts', 'postgres', ], },
'pg_dump', "--file=$tempdir/column_inserts.sql",
'-a', '--column-inserts',
'postgres', ], },
createdb => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/createdb.sql",
"--file=$tempdir/createdb.sql",
'-C',
'-R', # no-op, just for testing
'postgres', ], },
data_only => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/data_only.sql",
"--file=$tempdir/data_only.sql",
'-a',
'-v', # no-op, just make sure it works
'postgres', ], },
......@@ -84,110 +84,113 @@ my %pgdump_runs = (
defaults_custom_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Fc', '-Z6', '-f',
"$tempdir/defaults_custom_format.dump", 'postgres', ],
'pg_dump', '-Fc', '-Z6',
"--file=$tempdir/defaults_custom_format.dump", 'postgres', ],
restore_cmd => [
'pg_restore',
'-Fc', '-f',
"$tempdir/defaults_custom_format.sql",
'pg_restore', '-Fc',
"--file=$tempdir/defaults_custom_format.sql",
"$tempdir/defaults_custom_format.dump", ], },
defaults_dir_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Fd', '-f', "$tempdir/defaults_dir_format",
'postgres', ],
'pg_dump', '-Fd',
"--file=$tempdir/defaults_dir_format", 'postgres', ],
restore_cmd => [
'pg_restore',
'-Fd', '-f',
"$tempdir/defaults_dir_format.sql",
'pg_restore', '-Fd',
"--file=$tempdir/defaults_dir_format.sql",
"$tempdir/defaults_dir_format", ], },
defaults_parallel => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Fd', '-j2', '-f', "$tempdir/defaults_parallel",
'pg_dump', '-Fd', '-j2', "--file=$tempdir/defaults_parallel",
'postgres', ],
restore_cmd => [
'pg_restore', '-f',
"$tempdir/defaults_parallel.sql", "$tempdir/defaults_parallel", ],
},
'pg_restore',
"--file=$tempdir/defaults_parallel.sql",
"$tempdir/defaults_parallel", ], },
defaults_tar_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Ft', '-f', "$tempdir/defaults_tar_format.tar",
'postgres', ],
'pg_dump', '-Ft',
"--file=$tempdir/defaults_tar_format.tar", 'postgres', ],
restore_cmd => [
'pg_restore',
'-Ft', '-f',
"$tempdir/defaults_tar_format.sql",
'pg_restore', '-Ft',
"--file=$tempdir/defaults_tar_format.sql",
"$tempdir/defaults_tar_format.tar", ], },
exclude_dump_test_schema => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/exclude_dump_test_schema.sql",
'-N', 'dump_test', 'postgres', ], },
'pg_dump', "--file=$tempdir/exclude_dump_test_schema.sql",
'--exclude-schema=dump_test', 'postgres', ], },
exclude_test_table => {
dump_cmd => [
'pg_dump', '-f',
"$tempdir/exclude_test_table.sql", '-T',
'dump_test.test_table', 'postgres', ], },
'pg_dump',
"--file=$tempdir/exclude_test_table.sql",
'--exclude-table=dump_test.test_table',
'postgres', ], },
exclude_test_table_data => {
dump_cmd => [
'pg_dump', '-f',
"$tempdir/exclude_test_table_data.sql",
'--exclude-table-data=dump_test.test_table', 'postgres', ], },
'pg_dump',
"--file=$tempdir/exclude_test_table_data.sql",
'--exclude-table-data=dump_test.test_table',
'postgres', ], },
pg_dumpall_globals => {
dump_cmd =>
[ 'pg_dumpall', '-v', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
dump_cmd => [
'pg_dumpall', '-v',
"--file=$tempdir/pg_dumpall_globals.sql", '-g', ], },
pg_dumpall_globals_clean => {
dump_cmd => [
'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals_clean.sql",
'pg_dumpall', "--file=$tempdir/pg_dumpall_globals_clean.sql",
'-g', '-c', ], },
pg_dumpall_dbprivs => {
dump_cmd =>
[ 'pg_dumpall', '-f', "$tempdir/pg_dumpall_dbprivs.sql", ], },
[ 'pg_dumpall', "--file=$tempdir/pg_dumpall_dbprivs.sql", ], },
no_blobs => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/no_blobs.sql", '-B', 'postgres', ], },
[ 'pg_dump', "--file=$tempdir/no_blobs.sql", '-B', 'postgres', ], },
no_privs => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/no_privs.sql", '-x', 'postgres', ], },
[ 'pg_dump', "--file=$tempdir/no_privs.sql", '-x', 'postgres', ], },
no_owner => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/no_owner.sql", '-O', 'postgres', ], },
[ 'pg_dump', "--file=$tempdir/no_owner.sql", '-O', 'postgres', ], },
only_dump_test_schema => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/only_dump_test_schema.sql",
'-n', 'dump_test', 'postgres', ], },
'pg_dump', "--file=$tempdir/only_dump_test_schema.sql",
'--schema=dump_test', 'postgres', ], },
only_dump_test_table => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/only_dump_test_table.sql",
'-t', 'dump_test.test_table', '--lock-wait-timeout=1000000',
'pg_dump',
"--file=$tempdir/only_dump_test_table.sql",
'--table=dump_test.test_table',
'--lock-wait-timeout=1000000',
'postgres', ], },
role => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/role.sql",
'pg_dump',
"--file=$tempdir/role.sql",
'--role=regress_dump_test_role',
'--schema=dump_test_second_schema', 'postgres', ], },
'--schema=dump_test_second_schema',
'postgres', ], },
schema_only => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/schema_only.sql", '-s', 'postgres', ],
[ 'pg_dump', "--file=$tempdir/schema_only.sql", '-s', 'postgres', ],
},
section_pre_data => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/section_pre_data.sql",
'pg_dump', "--file=$tempdir/section_pre_data.sql",
'--section=pre-data', 'postgres', ], },
section_data => {
dump_cmd => [
'pg_dump', '-f',
"$tempdir/section_data.sql", '--section=data',
'postgres', ], },
'pg_dump', "--file=$tempdir/section_data.sql",
'--section=data', 'postgres', ], },
section_post_data => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/section_post_data.sql",
'pg_dump', "--file=$tempdir/section_post_data.sql",
'--section=post-data', 'postgres', ], },
test_schema_plus_blobs => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/test_schema_plus_blobs.sql",
'-n', 'dump_test', '-b', '-B', 'postgres', ], },);
'pg_dump', "--file=$tempdir/test_schema_plus_blobs.sql",
'--schema=dump_test', '-b', '-B', 'postgres', ], },);
###############################################################
# Definition of the tests to run.
......@@ -301,7 +304,8 @@ my %tests = (
'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^
\QALTER FUNCTION dump_test.pltestlang_call_handler() \E
\QOWNER TO \E
......@@ -358,7 +362,8 @@ my %tests = (
'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .*;/m,
like => {
binary_upgrade => 1,
......@@ -382,7 +387,8 @@ my %tests = (
'ALTER SCHEMA dump_test OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^ALTER SCHEMA dump_test OWNER TO .*;/m,
like => {
binary_upgrade => 1,
......@@ -406,7 +412,8 @@ my %tests = (
'ALTER SCHEMA dump_test_second_schema OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^ALTER SCHEMA dump_test_second_schema OWNER TO .*;/m,
like => {
binary_upgrade => 1,
......@@ -524,7 +531,8 @@ my %tests = (
'ALTER TABLE test_table OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^ALTER TABLE test_table OWNER TO .*;/m,
like => {
binary_upgrade => 1,
......@@ -577,7 +585,8 @@ my %tests = (
'ALTER TABLE test_second_table OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^ALTER TABLE test_second_table OWNER TO .*;/m,
like => {
binary_upgrade => 1,
......@@ -601,7 +610,8 @@ my %tests = (
'ALTER TABLE test_third_table OWNER TO' => {
all_runs => 1,
catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
catch_all =>
'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
regexp => qr/^ALTER TABLE test_third_table OWNER TO .*;/m,
like => {
binary_upgrade => 1,
......@@ -652,7 +662,8 @@ my %tests = (
'BLOB create (using lo_from_bytea)' => {
all_runs => 1,
create_order => 50,
create_sql => 'SELECT pg_catalog.lo_from_bytea(0, \'\\x310a320a330a340a350a360a370a380a390a\');',
create_sql =>
'SELECT pg_catalog.lo_from_bytea(0, \'\\x310a320a330a340a350a360a370a380a390a\');',
regexp => qr/^SELECT pg_catalog\.lo_create\('\d+'\);/m,
like => {
clean => 1,
......@@ -668,8 +679,7 @@ my %tests = (
no_owner => 1,
pg_dumpall_dbprivs => 1,
section_pre_data => 1,
test_schema_plus_blobs => 1,
},
test_schema_plus_blobs => 1, },
unlike => {
binary_upgrade => 1,
no_blobs => 1,
......@@ -680,9 +690,7 @@ my %tests = (
role => 1,
schema_only => 1,
section_data => 1,
section_post_data => 1,
},
},
section_post_data => 1, }, },
'BLOB load (using lo_from_bytea)' => {
all_runs => 1,
regexp => qr/^
......@@ -705,8 +713,7 @@ my %tests = (
no_privs => 1,
pg_dumpall_dbprivs => 1,
section_data => 1,
test_schema_plus_blobs => 1,
},
test_schema_plus_blobs => 1, },
unlike => {
binary_upgrade => 1,
no_blobs => 1,
......@@ -717,9 +724,7 @@ my %tests = (
role => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1,
},
},
section_post_data => 1, }, },
'COMMENT ON DATABASE postgres' => {
all_runs => 1,
......@@ -941,7 +946,7 @@ my %tests = (
\n(?:\d\n){5}\\\.\n
/xms,
like => { data_only => 1, },
unlike => { }, },
unlike => {}, },
'COPY test_second_table' => {
all_runs => 1,
......@@ -1025,7 +1030,7 @@ my %tests = (
(?:INSERT\ INTO\ test_table\ \(col1\)\ VALUES\ \(\d\);\n){9}
/xm,
like => { column_inserts => 1, },
unlike => { }, },
unlike => {}, },
'INSERT INTO test_second_table' => {
all_runs => 1,
......@@ -1034,7 +1039,7 @@ my %tests = (
(?:INSERT\ INTO\ test_second_table\ \(col1,\ col2\)
\ VALUES\ \(\d,\ '\d'\);\n){9}/xm,
like => { column_inserts => 1, },
unlike => { }, },
unlike => {}, },
'INSERT INTO test_third_table' => {
all_runs => 1,
......@@ -1043,13 +1048,13 @@ my %tests = (
(?:INSERT\ INTO\ test_third_table\ \(col1\)
\ VALUES\ \(\d\);\n){9}/xm,
like => { column_inserts => 1, },
unlike => { }, },
unlike => {}, },
# INSERT INTO catch-all
'INSERT INTO ...' => {
all_runs => 0, # catch-all
regexp => qr/^INSERT INTO .* VALUES .*;/xm,
like => { }, # use more-specific options above
like => {}, # use more-specific options above
unlike => {
binary_upgrade => 1,
clean => 1,
......@@ -1110,8 +1115,10 @@ my %tests = (
'CREATE CAST FOR timestamptz' => {
create_order => 51,
create_sql => 'CREATE CAST (timestamptz AS interval) WITH FUNCTION age(timestamptz) AS ASSIGNMENT;',
regexp => qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog\.age\(timestamp with time zone\) AS ASSIGNMENT;/m,
create_sql =>
'CREATE CAST (timestamptz AS interval) WITH FUNCTION age(timestamptz) AS ASSIGNMENT;',
regexp =>
qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog\.age\(timestamp with time zone\) AS ASSIGNMENT;/m,
like => {
binary_upgrade => 1,
clean => 1,
......@@ -1126,8 +1133,7 @@ my %tests = (
no_owner => 1,
pg_dumpall_dbprivs => 1,
schema_only => 1,
section_pre_data => 1,
},
section_pre_data => 1, },
unlike => {
only_dump_test_schema => 1,
only_dump_test_table => 1,
......@@ -1885,8 +1891,10 @@ my %tests = (
'CREATE TRANSFORM FOR int' => {
create_order => 34,
create_sql => 'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION varchar_transform(internal), TO SQL WITH FUNCTION int4recv(internal));',
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,
create_sql =>
'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION varchar_transform(internal), TO SQL WITH FUNCTION int4recv(internal));',
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,
like => {
binary_upgrade => 1,
clean => 1,
......@@ -1901,8 +1909,7 @@ my %tests = (
no_owner => 1,
pg_dumpall_dbprivs => 1,
schema_only => 1,
section_pre_data => 1,
},
section_pre_data => 1, },
unlike => {
only_dump_test_schema => 1,
only_dump_test_table => 1,
......@@ -2247,7 +2254,8 @@ my %tests = (
pg_dumpall_globals_clean => 1, }, },
'ALTER PUBLICATION pub1 ADD TABLE test_table' => {
create_order => 51,
create_sql => 'ALTER PUBLICATION pub1 ADD TABLE dump_test.test_table;',
create_sql =>
'ALTER PUBLICATION pub1 ADD TABLE dump_test.test_table;',
regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE test_table;\E
/xm,
......@@ -2732,7 +2740,7 @@ my %tests = (
regexp => qr/^
\QDROP ROLE pg_\E.*;
/xm,
like => { },
like => {},
unlike => {
clean => 1,
clean_if_exists => 1,
......@@ -3068,7 +3076,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
'GRANT commands' => { # catch-all for GRANT commands
all_runs => 0, # catch-all
regexp => qr/^GRANT /m,
like => { }, # use more-specific options above
like => {}, # use more-specific options above
unlike => {
column_inserts => 1,
data_only => 1,
......@@ -3440,21 +3448,24 @@ foreach my $run (sort keys %pgdump_runs)
$tests{$test}->{regexp},
"$run: does not dump $test");
}
# Complain if there isn't a like or unlike for this test, unless that is ok
if ($tests{$test}->{all_runs})
{
if (!defined($tests{$test}->{catch_all}))
{
ok (defined($tests{$test}->{like}->{$test_key}) || defined($tests{$test}->{unlike}->{$test_key}), "$run defined for `$test'");
ok( defined($tests{$test}->{like}->{$test_key})
|| defined($tests{$test}->{unlike}->{$test_key}),
"$run defined for `$test'");
}
else
{
my $catch_all = $tests{$test}->{catch_all};
ok (defined($tests{$test}->{like}->{$test_key}) ||
defined($tests{$catch_all}->{like}->{$test_key}) ||
defined($tests{$test}->{unlike}->{$test_key}) ||
defined($tests{$catch_all}->{unlike}->{$test_key}),
ok( defined($tests{$test}->{like}->{$test_key})
|| defined($tests{$catch_all}->{like}->{$test_key})
|| defined($tests{$test}->{unlike}->{$test_key})
|| defined($tests{$catch_all}->{unlike}->{$test_key}),
"$run defined for `$test' or `$catch_all'");
}
}
......
......@@ -16,21 +16,27 @@ $ENV{PGCLIENTENCODING} = 'LATIN1';
# characters, for use in a connection string by pg_dumpall. Skip ','
# because of pg_regress --create-role, skip [\n\r] because pg_dumpall
# does not allow them.
my $dbname1 = generate_ascii_string(1, 9) .
generate_ascii_string(11, 12) .
generate_ascii_string(14, 33) .
($TestLib::windows_os ? '' : '"x"') . # IPC::Run mishandles '"' on Windows
generate_ascii_string(35, 43) .
generate_ascii_string(45, 63); # contains '='
my $dbname2 = generate_ascii_string(67, 129); # skip 64-66 to keep length to 62
my $dbname1 =
generate_ascii_string(1, 9)
. generate_ascii_string(11, 12)
. generate_ascii_string(14, 33)
. ($TestLib::windows_os ? '' : '"x"')
. # IPC::Run mishandles '"' on Windows
generate_ascii_string(35, 43)
. generate_ascii_string(45, 63); # contains '='
my $dbname2 =
generate_ascii_string(67, 129); # skip 64-66 to keep length to 62
my $dbname3 = generate_ascii_string(130, 192);
my $dbname4 = generate_ascii_string(193, 255);
my $node = get_new_node('main');
$node->init(extra => ['--locale=C', '--encoding=LATIN1']);
$node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]);
# prep pg_hba.conf and pg_ident.conf
$node->run_log([$ENV{PG_REGRESS}, '--config-auth', $node->data_dir,
'--create-role', "$dbname1,$dbname2,$dbname3,$dbname4"]);
$node->run_log(
[ $ENV{PG_REGRESS}, '--config-auth',
$node->data_dir, '--create-role',
"$dbname1,$dbname2,$dbname3,$dbname4" ]);
$node->start;
my $backupdir = $node->backup_dir;
......@@ -40,61 +46,76 @@ my $dirfmt = "$backupdir/dirfmt";
foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase')
{
$node->run_log(['createdb', $dbname]);
$node->run_log(['createuser', '-s', $dbname]);
$node->run_log([ 'createdb', $dbname ]);
$node->run_log([ 'createuser', '-s', $dbname ]);
}
# For these tests, pg_dumpall -r is used because it produces a short
# dump.
$node->command_ok(['pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname1), '-U', $dbname4],
$node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname1),
'-U', $dbname4 ],
'pg_dumpall with long ASCII name 1');
$node->command_ok(['pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname2), '-U', $dbname3],
$node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname2),
'-U', $dbname3 ],
'pg_dumpall with long ASCII name 2');
$node->command_ok(['pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname3), '-U', $dbname2],
$node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname3),
'-U', $dbname2 ],
'pg_dumpall with long ASCII name 3');
$node->command_ok(['pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname4), '-U', $dbname1],
$node->command_ok(
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
$node->connstr($dbname4),
'-U', $dbname1 ],
'pg_dumpall with long ASCII name 4');
$node->command_ok(['pg_dumpall', '-r', '-l', 'dbname=template1'],
$node->command_ok(
[ 'pg_dumpall', '-r', '-l', 'dbname=template1' ],
'pg_dumpall -l accepts connection string');
$node->run_log(['createdb', "foo\n\rbar"]);
$node->run_log([ 'createdb', "foo\n\rbar" ]);
# not sufficient to use -r here
$node->command_fails(['pg_dumpall', '-f', $discard],
$node->command_fails(
[ 'pg_dumpall', '-f', $discard ],
'pg_dumpall with \n\r in database name');
$node->run_log(['dropdb', "foo\n\rbar"]);
$node->run_log([ 'dropdb', "foo\n\rbar" ]);
# make a table, so the parallel worker has something to dump
$node->safe_psql($dbname1, 'CREATE TABLE t0()');
# XXX no printed message when this fails, just SIGPIPE termination
$node->command_ok(['pg_dump', '-Fd', '-j2', '-f', $dirfmt,
'-U', $dbname1, $node->connstr($dbname1)],
$node->command_ok(
[ 'pg_dump', '-Fd', '-j2', '-f', $dirfmt,
'-U', $dbname1, $node->connstr($dbname1) ],
'parallel dump');
# recreate $dbname1 for restore test
$node->run_log(['dropdb', $dbname1]);
$node->run_log(['createdb', $dbname1]);
$node->run_log([ 'dropdb', $dbname1 ]);
$node->run_log([ 'createdb', $dbname1 ]);
$node->command_ok(['pg_restore', '-v', '-d', 'template1', '-j2',
'-U', $dbname1, $dirfmt],
$node->command_ok(
[ 'pg_restore', '-v', '-d', 'template1', '-j2', '-U', $dbname1, $dirfmt ],
'parallel restore');
$node->run_log(['dropdb', $dbname1]);
$node->run_log([ 'dropdb', $dbname1 ]);
$node->command_ok(['pg_restore', '-C', '-v', '-d', 'template1', '-j2',
'-U', $dbname1, $dirfmt],
$node->command_ok(
[ 'pg_restore', '-C', '-v', '-d',
'template1', '-j2', '-U', $dbname1,
$dirfmt ],
'parallel restore with create');
$node->command_ok(['pg_dumpall', '-f', $plain, '-U', $dbname1],
$node->command_ok([ 'pg_dumpall', '-f', $plain, '-U', $dbname1 ],
'take full dump');
system_log('cat', $plain);
my($stderr, $result);
my ($stderr, $result);
my $bootstrap_super = 'boot';
my $restore_super = qq{a'b\\c=d\\ne"f};
......@@ -103,22 +124,26 @@ my $restore_super = qq{a'b\\c=d\\ne"f};
# dbname/user connection parameters
my $envar_node = get_new_node('destination_envar');
$envar_node->init(extra => ['-U', $bootstrap_super,
'--locale=C', '--encoding=LATIN1']);
$envar_node->run_log([$ENV{PG_REGRESS},
'--config-auth', $envar_node->data_dir,
'--create-role', "$bootstrap_super,$restore_super"]);
$envar_node->init(
extra => [ '-U', $bootstrap_super, '--locale=C', '--encoding=LATIN1' ]);
$envar_node->run_log(
[ $ENV{PG_REGRESS}, '--config-auth',
$envar_node->data_dir, '--create-role',
"$bootstrap_super,$restore_super" ]);
$envar_node->start;
# make superuser for restore
$envar_node->run_log(['createuser', '-U', $bootstrap_super, '-s', $restore_super]);
$envar_node->run_log(
[ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]);
{
local $ENV{PGPORT} = $envar_node->port;
local $ENV{PGUSER} = $restore_super;
$result = run_log(['psql', '-X', '-f', $plain], '2>', \$stderr);
$result = run_log([ 'psql', '-X', '-f', $plain ], '2>', \$stderr);
}
ok($result, 'restore full dump using environment variables for connection parameters');
ok($result,
'restore full dump using environment variables for connection parameters'
);
is($stderr, '', 'no dump errors');
......@@ -126,17 +151,25 @@ is($stderr, '', 'no dump errors');
# dbname/user connection parameters. "\connect dbname=" forgets
# user/port from command line.
$restore_super =~ s/"//g if $TestLib::windows_os; # IPC::Run mishandles '"' on Windows
$restore_super =~ s/"//g
if $TestLib::windows_os; # IPC::Run mishandles '"' on Windows
my $cmdline_node = get_new_node('destination_cmdline');
$cmdline_node->init(extra => ['-U', $bootstrap_super,
'--locale=C', '--encoding=LATIN1']);
$cmdline_node->run_log([$ENV{PG_REGRESS},
'--config-auth', $cmdline_node->data_dir,
'--create-role', "$bootstrap_super,$restore_super"]);
$cmdline_node->init(
extra => [ '-U', $bootstrap_super, '--locale=C', '--encoding=LATIN1' ]);
$cmdline_node->run_log(
[ $ENV{PG_REGRESS}, '--config-auth',
$cmdline_node->data_dir, '--create-role',
"$bootstrap_super,$restore_super" ]);
$cmdline_node->start;
$cmdline_node->run_log(['createuser', '-U', $bootstrap_super, '-s', $restore_super]);
$cmdline_node->run_log(
[ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]);
{
$result = run_log(['psql', '-p', $cmdline_node->port, '-U', $restore_super, '-X', '-f', $plain], '2>', \$stderr);
$result = run_log(
[ 'psql', '-p', $cmdline_node->port, '-U',
$restore_super, '-X', '-f', $plain ],
'2>',
\$stderr);
}
ok($result, 'restore full dump with command-line options for connection parameters');
ok($result,
'restore full dump with command-line options for connection parameters');
is($stderr, '', 'no dump errors');
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