@ -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'" ) ;
}
}