From 8f91f323b4feef0371cd3db51be3007e44abd5e8 Mon Sep 17 00:00:00 2001 From: Stephen Frost Date: Fri, 18 Nov 2016 14:21:33 -0500 Subject: [PATCH] Clean up pg_dump tests, re-enable BLOB testing Add a loop to check that each test covers all of the pg_dump runs. We (I) had been a bit sloppy when adding new runs and not making sure to mark if they should be under like or unlike for each test, this loop makes sure that the test system will complain if any are forgotten in the future. The loop also correctly handles the 'catch all' cases, which are used to avoid running unnecessary specific checks when a single catch-all can be done (eg: a no-acl run should not have any GRANT commands). Also, re-enable the testing of blobs, but use lo_from_bytea() instead of trying to be cute and writing out to a file and then reading it back in with psql, which proved to be difficult for some buildfarm members. This allows us to add support for testing the --no-blobs option which will be getting added shortly, provided the buildfarm doesn't blow up on this. --- src/bin/pg_dump/t/002_pg_dump.pl | 900 ++++++++++++++++++++++++------- 1 file changed, 715 insertions(+), 185 deletions(-) diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 90f075bf4f..35ee85325b 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -225,6 +225,7 @@ my %pgdump_runs = ( my %tests = ( 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role' => { + all_runs => 1, create_order => 14, create_sql => 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test @@ -242,20 +243,26 @@ my %tests = ( defaults => 1, exclude_test_table => 1, exclude_test_table_data => 1, + no_owner => 1, only_dump_test_schema => 1, pg_dumpall_dbprivs => 1, schema_only => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, no_privs => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_pre_data => 1, section_data => 1, }, }, + 'ALTER ROLE regress_dump_test_role' => { + all_runs => 1, regexp => qr/^ \QALTER ROLE regress_dump_test_role WITH \E \QNOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB NOLOGIN \E @@ -269,7 +276,9 @@ my %tests = ( binary_upgrade => 1, clean => 1, clean_if_exists => 1, + column_inserts => 1, createdb => 1, + data_only => 1, defaults => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, @@ -278,11 +287,16 @@ my %tests = ( no_owner => 1, only_dump_test_schema => 1, only_dump_test_table => 1, + role => 1, schema_only => 1, section_pre_data => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ \QALTER FUNCTION dump_test.pltestlang_call_handler() \E \QOWNER TO \E @@ -303,8 +317,41 @@ my %tests = ( test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_table => 1, + role => 1, }, }, + + 'ALTER LARGE OBJECT ... OWNER TO' => { + all_runs => 1, + regexp => qr/^ALTER LARGE OBJECT \d+ OWNER TO .*;/m, + like => { + clean => 1, + clean_if_exists => 1, + column_inserts => 1, + createdb => 1, + data_only => 1, + defaults => 1, + exclude_dump_test_schema => 1, + exclude_test_table => 1, + exclude_test_table_data => 1, + no_privs => 1, + pg_dumpall_dbprivs => 1, + section_pre_data => 1, + test_schema_plus_blobs => 1, }, + unlike => { + binary_upgrade => 1, + no_owner => 1, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + role => 1, + schema_only => 1, + section_data => 1, + section_post_data => 1, }, }, + 'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .*;/m, like => { binary_upgrade => 1, @@ -322,8 +369,12 @@ my %tests = ( unlike => { only_dump_test_schema => 1, only_dump_test_table => 1, + role => 1, test_schema_plus_blobs => 1, }, }, + 'ALTER SCHEMA dump_test OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ALTER SCHEMA dump_test OWNER TO .*;/m, like => { binary_upgrade => 1, @@ -341,8 +392,12 @@ my %tests = ( test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_table => 1, + role => 1, }, }, + 'ALTER SCHEMA dump_test_second_schema OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ALTER SCHEMA dump_test_second_schema OWNER TO .*;/m, like => { binary_upgrade => 1, @@ -355,13 +410,16 @@ my %tests = ( exclude_test_table_data => 1, no_privs => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { only_dump_test_schema => 1, only_dump_test_table => 1, test_schema_plus_blobs => 1, }, }, + 'ALTER SEQUENCE test_table_col1_seq' => { + all_runs => 1, regexp => qr/^ \QALTER SEQUENCE test_table_col1_seq OWNED BY test_table.col1;\E /xm, @@ -381,12 +439,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_test_table => 1, exclude_dump_test_schema => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'ALTER SEQUENCE test_third_table_col1_seq' => { + all_runs => 1, regexp => qr/^ \QALTER SEQUENCE test_third_table_col1_seq OWNED BY test_third_table.col1;\E /xm, @@ -402,16 +466,23 @@ my %tests = ( no_privs => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { + column_inserts => 1, + data_only => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => { + all_runs => 1, + catch_all => 'ALTER TABLE ... commands', regexp => qr/^ \QALTER TABLE ONLY test_table\E \n^\s+ \QADD CONSTRAINT test_table_pkey PRIMARY KEY (col1);\E @@ -424,6 +495,7 @@ my %tests = ( defaults => 1, exclude_test_table_data => 1, no_privs => 1, + no_owner => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_dbprivs => 1, @@ -433,9 +505,13 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, exclude_test_table => 1, + role => 1, section_pre_data => 1, section_data => 1, }, }, + 'ALTER TABLE test_table OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ALTER TABLE test_table OWNER TO .*;/m, like => { binary_upgrade => 1, @@ -453,8 +529,12 @@ my %tests = ( test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - exclude_test_table => 1, }, }, + exclude_test_table => 1, + role => 1, }, }, + 'ALTER TABLE test_table ENABLE ROW LEVEL SECURITY' => { + all_runs => 1, + catch_all => 'ALTER TABLE ... commands', create_order => 23, create_sql => 'ALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;', @@ -467,6 +547,7 @@ my %tests = ( defaults => 1, exclude_test_table_data => 1, no_privs => 1, + no_owner => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_dbprivs => 1, @@ -476,8 +557,12 @@ my %tests = ( unlike => { section_pre_data => 1, exclude_dump_test_schema => 1, - exclude_test_table => 1, }, }, + exclude_test_table => 1, + role => 1, }, }, + 'ALTER TABLE test_second_table OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ALTER TABLE test_second_table OWNER TO .*;/m, like => { binary_upgrade => 1, @@ -495,8 +580,12 @@ my %tests = ( test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_table => 1, + role => 1, }, }, + 'ALTER TABLE test_third_table OWNER TO' => { + all_runs => 1, + catch_all => 'ALTER ... OWNER commands (except LARGE OBJECTs)', regexp => qr/^ALTER TABLE test_third_table OWNER TO .*;/m, like => { binary_upgrade => 1, @@ -509,6 +598,7 @@ my %tests = ( exclude_test_table_data => 1, no_privs => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -518,16 +608,22 @@ my %tests = ( # catch-all for ALTER ... OWNER (except LARGE OBJECTs) 'ALTER ... OWNER commands (except LARGE OBJECTs)' => { + all_runs => 0, # catch-all regexp => qr/^ALTER (?!LARGE OBJECT)(.*) OWNER TO .*;/m, like => {}, # use more-specific options above unlike => { - column_inserts => 1, - data_only => 1, - section_data => 1, }, }, + column_inserts => 1, + data_only => 1, + no_owner => 1, + pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + section_data => 1, + section_post_data => 1, }, }, - # catch-all for ALTER TABLE ... + # catch-all for ALTER TABLE ... (except OWNER TO) 'ALTER TABLE ... commands' => { - regexp => qr/^ALTER TABLE .*;/m, + all_runs => 0, # catch-all + regexp => qr/^ALTER TABLE .* (?!OWNER TO)(.*);/m, like => {}, # use more-specific options above unlike => { column_inserts => 1, @@ -536,52 +632,79 @@ my %tests = ( pg_dumpall_globals_clean => 1, section_data => 1, }, }, - # catch-all for ALTER ... OWNER - 'ALTER ... OWNER commands' => { - regexp => qr/^ALTER .* OWNER TO .*;/m, - like => {}, # use more-specific options above + 'BLOB create (using lo_from_bytea)' => { + all_runs => 1, + create_order => 50, + create_sql => 'SELECT pg_catalog.lo_from_bytea(0, \'\\x310a320a330a340a350a360a370a380a390a\');', + regexp => qr/^SELECT pg_catalog\.lo_create\('\d+'\);/m, + like => { + clean => 1, + clean_if_exists => 1, + column_inserts => 1, + createdb => 1, + data_only => 1, + defaults => 1, + exclude_dump_test_schema => 1, + exclude_test_table => 1, + exclude_test_table_data => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_dbprivs => 1, + section_pre_data => 1, + test_schema_plus_blobs => 1, + }, unlike => { - no_owner => 1, - pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, - section_post_data => 1, }, }, + binary_upgrade => 1, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + role => 1, + schema_only => 1, + section_data => 1, + section_post_data => 1, + }, + }, + 'BLOB load (using lo_from_bytea)' => { + all_runs => 1, + regexp => qr/^ + \QSELECT pg_catalog.lo_open\E \('\d+',\ \d+\);\n + \QSELECT pg_catalog.lowrite(0, \E + \Q'\x310a320a330a340a350a360a370a380a390a');\E\n + \QSELECT pg_catalog.lo_close(0);\E + /xm, + like => { + clean => 1, + clean_if_exists => 1, + column_inserts => 1, + createdb => 1, + defaults => 1, + data_only => 1, + exclude_dump_test_schema => 1, + exclude_test_table => 1, + exclude_test_table_data => 1, + no_owner => 1, + no_privs => 1, + pg_dumpall_dbprivs => 1, + section_data => 1, + test_schema_plus_blobs => 1, + }, + unlike => { + binary_upgrade => 1, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + role => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, + }, + }, - # 'BLOB load (contents are of test_table)' => { - # create_order => 14, - # create_sql => - # "\\o '$tempdir/large_object_test.sql'\n" - # . "table dump_test.test_table;\n" - # . "\\o\n" - # . "\\lo_import '$tempdir/large_object_test.sql'\n", - # regexp => qr/^ - # \QSELECT pg_catalog.lo_open\E \('\d+',\ \d+\);\n - # \QSELECT pg_catalog.lowrite(0, \E - # \Q'\x310a320a330a340a350a360a370a380a390a');\E\n - # \QSELECT pg_catalog.lo_close(0);\E - # /xm, - # like => { - # clean => 1, - # clean_if_exists => 1, - # createdb => 1, - # defaults => 1, - # exclude_dump_test_schema => 1, - # exclude_test_table => 1, - # exclude_test_table_data => 1, - # no_privs => 1, - # pg_dumpall_dbprivs => 1, - # section_data => 1, - # test_schema_plus_blobs => 1, - # }, - # unlike => { - # binary_upgrade => 1, - # only_dump_test_schema => 1, - # only_dump_test_table => 1, - # pg_dumpall_globals => 1, - # schema_only => 1, - # section_post_data => 1, - # }, - # }, 'COMMENT ON DATABASE postgres' => { + all_runs => 1, + catch_all => 'COMMENT commands', regexp => qr/^COMMENT ON DATABASE postgres IS .*;/m, like => { binary_upgrade => 1, @@ -598,9 +721,13 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, unlike => { - only_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_schema => 1, + only_dump_test_table => 1, + role => 1, + test_schema_plus_blobs => 1, }, }, 'COMMENT ON EXTENSION plpgsql' => { + all_runs => 1, + catch_all => 'COMMENT commands', regexp => qr/^COMMENT ON EXTENSION plpgsql IS .*;/m, like => { clean => 1, @@ -616,10 +743,14 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, unlike => { - binary_upgrade => 1, - only_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + binary_upgrade => 1, + only_dump_test_schema => 1, + only_dump_test_table => 1, + role => 1, + test_schema_plus_blobs => 1, }, }, 'COMMENT ON TABLE dump_test.test_table' => { + all_runs => 1, + catch_all => 'COMMENT commands', create_order => 36, create_sql => 'COMMENT ON TABLE dump_test.test_table IS \'comment on table\';', @@ -637,11 +768,15 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_dbprivs => 1, schema_only => 1, - section_pre_data => 1, }, + section_pre_data => 1, + test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - exclude_test_table => 1, }, }, + exclude_test_table => 1, + role => 1, }, }, 'COMMENT ON COLUMN dump_test.test_table.col1' => { + all_runs => 1, + catch_all => 'COMMENT commands', create_order => 36, create_sql => 'COMMENT ON COLUMN dump_test.test_table.col1 IS \'comment on column\';', @@ -661,11 +796,15 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_dbprivs => 1, schema_only => 1, - section_pre_data => 1, }, + section_pre_data => 1, + test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - exclude_test_table => 1, }, }, + exclude_test_table => 1, + role => 1, }, }, 'COMMENT ON COLUMN dump_test.composite.f1' => { + all_runs => 1, + catch_all => 'COMMENT commands', create_order => 44, create_sql => 'COMMENT ON COLUMN dump_test.composite.f1 IS \'comment on column of type\';', @@ -685,13 +824,16 @@ my %tests = ( only_dump_test_schema => 1, pg_dumpall_dbprivs => 1, schema_only => 1, - section_pre_data => 1, }, + section_pre_data => 1, + test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_table => 1, + role => 1, }, }, # catch-all for COMMENTs 'COMMENT commands' => { + all_runs => 0, # catch-all regexp => qr/^COMMENT ON /m, like => {}, # use more-specific options above unlike => { @@ -701,7 +843,10 @@ my %tests = ( pg_dumpall_globals_clean => 1, section_data => 1, section_post_data => 1, }, }, + 'COPY test_table' => { + all_runs => 1, + catch_all => 'COPY ... commands', create_order => 4, create_sql => 'INSERT INTO dump_test.test_table (col1) ' . 'SELECT generate_series FROM generate_series(1,9);', @@ -725,8 +870,12 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, exclude_test_table => 1, - exclude_test_table_data => 1, }, }, + exclude_test_table_data => 1, + role => 1, }, }, + 'COPY fk_reference_test_table' => { + all_runs => 1, + catch_all => 'COPY ... commands', create_order => 22, create_sql => 'INSERT INTO dump_test.fk_reference_test_table (col1) ' . 'SELECT generate_series FROM generate_series(1,5);', @@ -750,8 +899,15 @@ my %tests = ( test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_table => 1, + role => 1, }, }, + + # In a data-only dump, we do try to actually order according to FKs, + # so this check is just making sure that the referring table comes after + # the referred-to table. 'COPY fk_reference_test_table second' => { + all_runs => 0, # really only for data-only + catch_all => 'COPY ... commands', regexp => qr/^ \QCOPY test_table (col1) FROM stdin;\E \n(?:\d\n){9}\\\.\n.* @@ -759,11 +915,11 @@ my %tests = ( \n(?:\d\n){5}\\\.\n /xms, like => { data_only => 1, }, - unlike => { - exclude_dump_test_schema => 1, - exclude_test_table => 1, - exclude_test_table_data => 1, }, }, + unlike => { }, }, + 'COPY test_second_table' => { + all_runs => 1, + catch_all => 'COPY ... commands', create_order => 7, create_sql => 'INSERT INTO dump_test.test_second_table (col1, col2) ' . 'SELECT generate_series, generate_series::text ' @@ -788,8 +944,12 @@ my %tests = ( test_schema_plus_blobs => 1, }, unlike => { exclude_dump_test_schema => 1, - only_dump_test_table => 1, }, }, + only_dump_test_table => 1, + role => 1, }, }, + 'COPY test_third_table' => { + all_runs => 1, + catch_all => 'COPY ... commands', create_order => 12, create_sql => 'INSERT INTO dump_test_second_schema.test_third_table (col1) ' @@ -810,75 +970,15 @@ my %tests = ( no_privs => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, section_data => 1, }, unlike => { only_dump_test_schema => 1, only_dump_test_table => 1, test_schema_plus_blobs => 1, }, }, - 'INSERT INTO test_table' => { - regexp => qr/^ - (?:INSERT\ INTO\ test_table\ \(col1\)\ VALUES\ \(\d\);\n){9} - /xm, - like => { column_inserts => 1, }, - unlike => { - clean => 1, - clean_if_exists => 1, - createdb => 1, - data_only => 1, - defaults => 1, - exclude_dump_test_schema => 1, - exclude_test_table => 1, - exclude_test_table_data => 1, - no_privs => 1, - no_owner => 1, - pg_dumpall_dbprivs => 1, - section_data => 1, - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, - 'INSERT INTO test_second_table' => { - regexp => qr/^ - (?:INSERT\ INTO\ test_second_table\ \(col1,\ col2\) - \ VALUES\ \(\d,\ '\d'\);\n){9}/xm, - like => { column_inserts => 1, }, - unlike => { - clean => 1, - clean_if_exists => 1, - createdb => 1, - data_only => 1, - defaults => 1, - exclude_dump_test_schema => 1, - exclude_test_table => 1, - exclude_test_table_data => 1, - no_privs => 1, - no_owner => 1, - pg_dumpall_dbprivs => 1, - section_data => 1, - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, - 'INSERT INTO test_third_table' => { - regexp => qr/^ - (?:INSERT\ INTO\ test_third_table\ \(col1\) - \ VALUES\ \(\d\);\n){9}/xm, - like => { column_inserts => 1, }, - unlike => { - clean => 1, - clean_if_exists => 1, - createdb => 1, - data_only => 1, - defaults => 1, - exclude_dump_test_schema => 1, - exclude_test_table => 1, - exclude_test_table_data => 1, - no_privs => 1, - no_owner => 1, - pg_dumpall_dbprivs => 1, - section_data => 1, - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, + 'COPY ... commands' => { # catch-all for COPY + all_runs => 0, # catch-all regexp => qr/^COPY /m, like => {}, # use more-specific options above unlike => { @@ -887,8 +987,68 @@ my %tests = ( pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, schema_only => 1, + section_pre_data => 1, section_post_data => 1, }, }, + + 'INSERT INTO test_table' => { + all_runs => 1, + catch_all => 'INSERT INTO ...', + regexp => qr/^ + (?:INSERT\ INTO\ test_table\ \(col1\)\ VALUES\ \(\d\);\n){9} + /xm, + like => { column_inserts => 1, }, + unlike => { }, }, + + 'INSERT INTO test_second_table' => { + all_runs => 1, + catch_all => 'INSERT INTO ...', + regexp => qr/^ + (?:INSERT\ INTO\ test_second_table\ \(col1,\ col2\) + \ VALUES\ \(\d,\ '\d'\);\n){9}/xm, + like => { column_inserts => 1, }, + unlike => { }, }, + + 'INSERT INTO test_third_table' => { + all_runs => 1, + catch_all => 'INSERT INTO ...', + regexp => qr/^ + (?:INSERT\ INTO\ test_third_table\ \(col1\) + \ VALUES\ \(\d\);\n){9}/xm, + like => { column_inserts => 1, }, + unlike => { }, }, + + # INSERT INTO catch-all + 'INSERT INTO ...' => { + all_runs => 0, # catch-all + regexp => qr/^INSERT INTO .* VALUES .*;/xm, + like => { }, # use more-specific options above + unlike => { + binary_upgrade => 1, + clean => 1, + clean_if_exists => 1, + createdb => 1, + data_only => 1, + defaults => 1, + exclude_dump_test_schema => 1, + exclude_test_table => 1, + exclude_test_table_data => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_dbprivs => 1, + pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + section_data => 1, + only_dump_test_schema => 1, + only_dump_test_table => 1, + role => 1, + schema_only => 1, + section_pre_data => 1, + section_data => 1, + section_post_data => 1, + test_schema_plus_blobs => 1, }, }, + 'CREATE ROLE regress_dump_test_role' => { + all_runs => 1, create_order => 1, create_sql => 'CREATE ROLE regress_dump_test_role;', regexp => qr/^CREATE ROLE regress_dump_test_role;/m, @@ -900,7 +1060,9 @@ my %tests = ( binary_upgrade => 1, clean => 1, clean_if_exists => 1, + column_inserts => 1, createdb => 1, + data_only => 1, defaults => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, @@ -909,11 +1071,15 @@ my %tests = ( no_owner => 1, only_dump_test_schema => 1, only_dump_test_table => 1, + role => 1, schema_only => 1, section_pre_data => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE DATABASE postgres' => { + all_runs => 1, regexp => qr/^ \QCREATE DATABASE postgres WITH TEMPLATE = template0 \E .*;/xm, @@ -922,6 +1088,8 @@ my %tests = ( binary_upgrade => 1, clean => 1, clean_if_exists => 1, + column_inserts => 1, + data_only => 1, defaults => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, @@ -933,11 +1101,15 @@ my %tests = ( pg_dumpall_dbprivs => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, schema_only => 1, section_pre_data => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE DATABASE dump_test' => { + all_runs => 1, create_order => 47, create_sql => 'CREATE DATABASE dump_test;', regexp => qr/^ @@ -948,7 +1120,9 @@ my %tests = ( binary_upgrade => 1, clean => 1, clean_if_exists => 1, + column_inserts => 1, createdb => 1, + data_only => 1, defaults => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, @@ -959,11 +1133,15 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, schema_only => 1, section_pre_data => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE EXTENSION ... plpgsql' => { + all_runs => 1, regexp => qr/^ \QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E /xm, @@ -982,13 +1160,19 @@ my %tests = ( section_pre_data => 1, }, unlike => { binary_upgrade => 1, + column_inserts => 1, + data_only => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE AGGREGATE dump_test.newavg' => { + all_runs => 1, create_order => 25, create_sql => 'CREATE AGGREGATE dump_test.newavg ( sfunc = int4_avg_accum, @@ -1020,12 +1204,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE DOMAIN dump_test.us_postal_code' => { + all_runs => 1, create_order => 29, create_sql => 'CREATE DOMAIN dump_test.us_postal_code AS TEXT CHECK(VALUE ~ \'^\d{5}$\' OR @@ -1054,12 +1244,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE FUNCTION dump_test.pltestlang_call_handler' => { + all_runs => 1, create_order => 17, create_sql => 'CREATE FUNCTION dump_test.pltestlang_call_handler() RETURNS LANGUAGE_HANDLER AS \'$libdir/plpgsql\', @@ -1087,12 +1283,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE FUNCTION dump_test.trigger_func' => { + all_runs => 1, create_order => 30, create_sql => 'CREATE FUNCTION dump_test.trigger_func() RETURNS trigger LANGUAGE plpgsql @@ -1119,12 +1321,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE FUNCTION dump_test.event_trigger_func' => { + all_runs => 1, create_order => 32, create_sql => 'CREATE FUNCTION dump_test.event_trigger_func() RETURNS event_trigger LANGUAGE plpgsql @@ -1151,12 +1359,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE EVENT TRIGGER test_event_trigger' => { + all_runs => 1, create_order => 33, create_sql => 'CREATE EVENT TRIGGER test_event_trigger ON ddl_command_start @@ -1181,13 +1395,19 @@ my %tests = ( schema_only => 1, section_post_data => 1, }, unlike => { - section_pre_data => 1, + column_inserts => 1, + data_only => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_pre_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE TRIGGER test_trigger' => { + all_runs => 1, create_order => 31, create_sql => 'CREATE TRIGGER test_trigger BEFORE INSERT ON dump_test.test_table @@ -1214,12 +1434,18 @@ my %tests = ( section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { - section_pre_data => 1, + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, }, }, + pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_pre_data => 1, }, }, + 'CREATE TYPE dump_test.planets AS ENUM' => { + all_runs => 1, create_order => 37, create_sql => 'CREATE TYPE dump_test.planets AS ENUM ( \'venus\', \'earth\', \'mars\' );', @@ -1244,12 +1470,19 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + binary_upgrade => 1, + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE TYPE dump_test.planets AS ENUM pg_upgrade' => { + all_runs => 1, regexp => qr/^ \QCREATE TYPE planets AS ENUM (\E \n\);.*^ @@ -1263,7 +1496,9 @@ my %tests = ( unlike => { clean => 1, clean_if_exists => 1, + column_inserts => 1, createdb => 1, + data_only => 1, defaults => 1, exclude_test_table => 1, exclude_test_table_data => 1, @@ -1278,8 +1513,13 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_pre_data => 1, section_post_data => 1, }, }, + 'CREATE TYPE dump_test.textrange AS RANGE' => { + all_runs => 1, create_order => 38, create_sql => 'CREATE TYPE dump_test.textrange AS RANGE (subtype=text, collation="C");', @@ -1289,6 +1529,7 @@ my %tests = ( \n\s+\Qcollation = pg_catalog."C"\E \n\);/xm, like => { + binary_upgrade => 1, clean => 1, clean_if_exists => 1, createdb => 1, @@ -1303,16 +1544,23 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE TYPE dump_test.int42' => { + all_runs => 1, create_order => 39, create_sql => 'CREATE TYPE dump_test.int42;', regexp => qr/^CREATE TYPE int42;/m, like => { + binary_upgrade => 1, clean => 1, clean_if_exists => 1, createdb => 1, @@ -1327,12 +1575,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE FUNCTION dump_test.int42_in' => { + all_runs => 1, create_order => 40, create_sql => 'CREATE FUNCTION dump_test.int42_in(cstring) RETURNS dump_test.int42 AS \'int4in\' @@ -1358,12 +1612,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE FUNCTION dump_test.int42_out' => { + all_runs => 1, create_order => 41, create_sql => 'CREATE FUNCTION dump_test.int42_out(dump_test.int42) RETURNS cstring AS \'int4out\' @@ -1389,12 +1649,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE TYPE dump_test.int42 populated' => { + all_runs => 1, create_order => 42, create_sql => 'CREATE TYPE dump_test.int42 ( internallength = 4, @@ -1414,6 +1680,7 @@ my %tests = ( \n\s+PASSEDBYVALUE\n\); /xm, like => { + binary_upgrade => 1, clean => 1, clean_if_exists => 1, createdb => 1, @@ -1428,12 +1695,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE TYPE dump_test.composite' => { + all_runs => 1, create_order => 43, create_sql => 'CREATE TYPE dump_test.composite AS ( f1 int, @@ -1446,6 +1719,7 @@ my %tests = ( \n\); /xm, like => { + binary_upgrade => 1, clean => 1, clean_if_exists => 1, createdb => 1, @@ -1460,12 +1734,18 @@ my %tests = ( section_pre_data => 1, test_schema_plus_blobs => 1, }, unlike => { + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, }, }, + 'CREATE FOREIGN DATA WRAPPER dummy' => { + all_runs => 1, create_order => 35, create_sql => 'CREATE FOREIGN DATA WRAPPER dummy;', regexp => qr/CREATE FOREIGN DATA WRAPPER dummy;/m, @@ -1484,13 +1764,19 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, unlike => { + column_inserts => 1, + data_only => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy' => { + all_runs => 1, create_order => 36, create_sql => 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;', regexp => qr/CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;/m, @@ -1509,12 +1795,17 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, unlike => { + column_inserts => 1, + data_only => 1, only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + ####################################### # Currently broken. ####################################### @@ -1546,7 +1837,10 @@ my %tests = ( # test_schema_plus_blobs => 1, # }, # }, + 'CREATE LANGUAGE pltestlang' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 18, create_sql => 'CREATE LANGUAGE pltestlang HANDLER dump_test.pltestlang_call_handler;', @@ -1572,10 +1866,14 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, only_dump_test_schema => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE MATERIALIZED VIEW matview' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 20, create_sql => 'CREATE MATERIALIZED VIEW dump_test.matview (col1) AS SELECT * FROM dump_test.test_table;', @@ -1605,8 +1903,12 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE MATERIALIZED VIEW matview_second' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 21, create_sql => 'CREATE MATERIALIZED VIEW dump_test.matview_second (col1) AS @@ -1637,8 +1939,12 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE POLICY p1 ON test_table' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 22, create_sql => 'CREATE POLICY p1 ON dump_test.test_table USING (true) @@ -1663,12 +1969,16 @@ my %tests = ( section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { - section_pre_data => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, }, }, + pg_dumpall_globals_clean => 1, + role => 1, + section_pre_data => 1, }, }, + 'CREATE POLICY p2 ON test_table FOR SELECT' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 24, create_sql => 'CREATE POLICY p2 ON dump_test.test_table FOR SELECT TO regress_dump_test_role USING (true);', @@ -1692,12 +2002,16 @@ my %tests = ( section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { - section_pre_data => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, }, }, + pg_dumpall_globals_clean => 1, + role => 1, + section_pre_data => 1, }, }, + 'CREATE POLICY p3 ON test_table FOR INSERT' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 25, create_sql => 'CREATE POLICY p3 ON dump_test.test_table FOR INSERT TO regress_dump_test_role WITH CHECK (true);', @@ -1721,12 +2035,16 @@ my %tests = ( section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { - section_pre_data => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, }, }, + pg_dumpall_globals_clean => 1, + role => 1, + section_pre_data => 1, }, }, + 'CREATE POLICY p4 ON test_table FOR UPDATE' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 26, create_sql => 'CREATE POLICY p4 ON dump_test.test_table FOR UPDATE TO regress_dump_test_role USING (true) WITH CHECK (true);', @@ -1750,12 +2068,16 @@ my %tests = ( section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { - section_pre_data => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, }, }, + pg_dumpall_globals_clean => 1, + role => 1, + section_pre_data => 1, }, }, + 'CREATE POLICY p5 ON test_table FOR DELETE' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 27, create_sql => 'CREATE POLICY p5 ON dump_test.test_table FOR DELETE TO regress_dump_test_role USING (true);', @@ -1779,12 +2101,16 @@ my %tests = ( section_post_data => 1, test_schema_plus_blobs => 1, }, unlike => { - section_pre_data => 1, exclude_dump_test_schema => 1, exclude_test_table => 1, pg_dumpall_globals => 1, - pg_dumpall_globals_clean => 1, }, }, + pg_dumpall_globals_clean => 1, + role => 1, + section_pre_data => 1, }, }, + 'CREATE SCHEMA dump_test' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 2, create_sql => 'CREATE SCHEMA dump_test;', regexp => qr/^CREATE SCHEMA dump_test;/m, @@ -1808,8 +2134,12 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE SCHEMA dump_test_second_schema' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 9, create_sql => 'CREATE SCHEMA dump_test_second_schema;', regexp => qr/^CREATE SCHEMA dump_test_second_schema;/m, @@ -1825,6 +2155,7 @@ my %tests = ( no_privs => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -1834,7 +2165,10 @@ my %tests = ( pg_dumpall_globals_clean => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE TABLE test_table' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 3, create_sql => 'CREATE TABLE dump_test.test_table ( col1 serial primary key, @@ -1866,8 +2200,12 @@ my %tests = ( exclude_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE TABLE fk_reference_test_table' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 21, create_sql => 'CREATE TABLE dump_test.fk_reference_test_table ( col1 int primary key references dump_test.test_table @@ -1897,8 +2235,12 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE TABLE test_second_table' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 6, create_sql => 'CREATE TABLE dump_test.test_second_table ( col1 int, @@ -1930,8 +2272,12 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE TABLE test_third_table' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 11, create_sql => 'CREATE TABLE dump_test_second_schema.test_third_table ( col1 serial @@ -1953,6 +2299,7 @@ my %tests = ( no_privs => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -1962,7 +2309,10 @@ my %tests = ( pg_dumpall_globals_clean => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE SEQUENCE test_table_col1_seq' => { + all_runs => 1, + catch_all => 'CREATE ... commands', regexp => qr/^ \QCREATE SEQUENCE test_table_col1_seq\E \n\s+\QSTART WITH 1\E @@ -1991,8 +2341,12 @@ my %tests = ( exclude_dump_test_schema => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + role => 1, section_post_data => 1, }, }, + 'CREATE SEQUENCE test_third_table_col1_seq' => { + all_runs => 1, + catch_all => 'CREATE ... commands', regexp => qr/^ \QCREATE SEQUENCE test_third_table_col1_seq\E \n\s+\QSTART WITH 1\E @@ -2013,6 +2367,7 @@ my %tests = ( no_privs => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -2022,7 +2377,10 @@ my %tests = ( pg_dumpall_globals_clean => 1, section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE UNIQUE INDEX test_third_table_idx ON test_third_table' => { + all_runs => 1, + catch_all => 'CREATE ... commands', create_order => 13, create_sql => 'CREATE UNIQUE INDEX test_third_table_idx ON dump_test_second_schema.test_third_table (col1);', @@ -2042,6 +2400,7 @@ my %tests = ( no_privs => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_post_data => 1, }, unlike => { @@ -2049,86 +2408,143 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, pg_dumpall_globals_clean => 1, + section_pre_data => 1, test_schema_plus_blobs => 1, }, }, + 'CREATE ... commands' => { # catch-all for CREATE + all_runs => 0, # catch-all regexp => qr/^CREATE /m, like => {}, # use more-specific options above unlike => { column_inserts => 1, data_only => 1, section_data => 1, }, }, + 'DROP EXTENSION plpgsql' => { + all_runs => 1, + catch_all => 'DROP ... commands', regexp => qr/^DROP EXTENSION plpgsql;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP FUNCTION dump_test.pltestlang_call_handler()' => { regexp => qr/^DROP FUNCTION dump_test\.pltestlang_call_handler\(\);/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP LANGUAGE pltestlang' => { regexp => qr/^DROP PROCEDURAL LANGUAGE pltestlang;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP SCHEMA dump_test' => { regexp => qr/^DROP SCHEMA dump_test;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP SCHEMA dump_test_second_schema' => { regexp => qr/^DROP SCHEMA dump_test_second_schema;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE test_table' => { regexp => qr/^DROP TABLE dump_test\.test_table;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE fk_reference_test_table' => { regexp => qr/^DROP TABLE dump_test\.fk_reference_test_table;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE test_second_table' => { regexp => qr/^DROP TABLE dump_test\.test_second_table;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE test_third_table' => { regexp => qr/^DROP TABLE dump_test_second_schema\.test_third_table;/m, like => { clean => 1, }, - unlike => { clean_if_exists => 1, }, }, + unlike => { + clean_if_exists => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP EXTENSION IF EXISTS plpgsql' => { regexp => qr/^DROP EXTENSION IF EXISTS plpgsql;/m, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler()' => { regexp => qr/^ \QDROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler();\E /xm, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP LANGUAGE IF EXISTS pltestlang' => { regexp => qr/^DROP PROCEDURAL LANGUAGE IF EXISTS pltestlang;/m, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP SCHEMA IF EXISTS dump_test' => { regexp => qr/^DROP SCHEMA IF EXISTS dump_test;/m, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP SCHEMA IF EXISTS dump_test_second_schema' => { regexp => qr/^DROP SCHEMA IF EXISTS dump_test_second_schema;/m, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE IF EXISTS test_table' => { regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_table;/m, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE IF EXISTS test_second_table' => { regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_second_table;/m, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP TABLE IF EXISTS test_third_table' => { regexp => qr/^ \QDROP TABLE IF EXISTS dump_test_second_schema.test_third_table;\E /xm, like => { clean_if_exists => 1, }, - unlike => { clean => 1, }, }, + unlike => { + clean => 1, + pg_dumpall_globals_clean => 1, }, }, + 'DROP ROLE regress_dump_test_role' => { regexp => qr/^ \QDROP ROLE regress_dump_test_role;\E @@ -2137,16 +2553,19 @@ my %tests = ( unlike => { clean => 1, clean_if_exists => 1, }, }, + 'DROP ROLE pg_' => { regexp => qr/^ \QDROP ROLE pg_\E.*; /xm, - like => {}, + like => { }, unlike => { clean => 1, clean_if_exists => 1, pg_dumpall_globals_clean => 1, }, }, + 'DROP ... commands' => { # catch-all for DROP + all_runs => 0, # catch-all regexp => qr/^DROP /m, like => {}, # use more-specific options above unlike => { @@ -2164,8 +2583,16 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_dbprivs => 1, pg_dumpall_globals => 1, - schema_only => 1, }, }, + role => 1, + schema_only => 1, + section_data => 1, + section_pre_data => 1, + section_post_data => 1, + test_schema_plus_blobs => 1, }, }, + 'GRANT USAGE ON SCHEMA dump_test_second_schema' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 10, create_sql => 'GRANT USAGE ON SCHEMA dump_test_second_schema TO regress_dump_test_role;', @@ -2183,6 +2610,7 @@ my %tests = ( exclude_test_table_data => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -2190,7 +2618,10 @@ my %tests = ( only_dump_test_table => 1, pg_dumpall_globals => 1, test_schema_plus_blobs => 1, }, }, + 'GRANT CREATE ON DATABASE dump_test' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 48, create_sql => 'GRANT CREATE ON DATABASE dump_test TO regress_dump_test_role;', @@ -2211,10 +2642,14 @@ my %tests = ( only_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, + role => 1, schema_only => 1, section_pre_data => 1, test_schema_plus_blobs => 1, }, }, + 'GRANT SELECT ON TABLE test_table' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 5, create_sql => 'GRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;', @@ -2237,8 +2672,12 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, exclude_test_table => 1, - pg_dumpall_globals => 1, }, }, + pg_dumpall_globals => 1, + role => 1, }, }, + 'GRANT SELECT ON TABLE test_third_table' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 19, create_sql => 'GRANT SELECT ON TABLE dump_test_second_schema.test_third_table @@ -2256,6 +2695,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, exclude_test_table_data => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -2263,7 +2703,10 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, only_dump_test_table => 1, pg_dumpall_globals => 1, test_schema_plus_blobs => 1, }, }, + 'GRANT ALL ON SEQUENCE test_third_table_col1_seq' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 28, create_sql => 'GRANT ALL ON SEQUENCE dump_test_second_schema.test_third_table_col1_seq @@ -2282,6 +2725,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, exclude_test_table_data => 1, no_owner => 1, pg_dumpall_dbprivs => 1, + role => 1, schema_only => 1, section_pre_data => 1, }, unlike => { @@ -2289,7 +2733,10 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, only_dump_test_table => 1, pg_dumpall_globals => 1, test_schema_plus_blobs => 1, }, }, + 'GRANT INSERT(col1) ON TABLE test_second_table' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 8, create_sql => 'GRANT INSERT (col1) ON TABLE dump_test.test_second_table @@ -2314,8 +2761,12 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, unlike => { exclude_dump_test_schema => 1, only_dump_test_table => 1, - pg_dumpall_globals => 1, }, }, + pg_dumpall_globals => 1, + role => 1, }, }, + 'GRANT EXECUTE ON FUNCTION pg_sleep() TO regress_dump_test_role' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 16, create_sql => 'GRANT EXECUTE ON FUNCTION pg_sleep(float8) TO regress_dump_test_role;', @@ -2338,8 +2789,13 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, unlike => { only_dump_test_schema => 1, only_dump_test_table => 1, + pg_dumpall_globals => 1, + role => 1, test_schema_plus_blobs => 1, }, }, + 'GRANT SELECT (proname ...) ON TABLE pg_proc TO public' => { + all_runs => 1, + catch_all => 'GRANT commands', create_order => 46, create_sql => 'GRANT SELECT ( tableoid, @@ -2422,16 +2878,24 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, unlike => { only_dump_test_schema => 1, only_dump_test_table => 1, + pg_dumpall_globals => 1, + role => 1, test_schema_plus_blobs => 1, }, }, + '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, - no_privs => 1, - section_data => 1, }, }, + column_inserts => 1, + data_only => 1, + no_privs => 1, + pg_dumpall_globals_clean => 1, + section_data => 1, + section_post_data => 1, }, }, + 'REFRESH MATERIALIZED VIEW matview' => { + all_runs => 1, regexp => qr/^REFRESH MATERIALIZED VIEW matview;/m, like => { clean => 1, @@ -2448,12 +2912,19 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, section_post_data => 1, }, unlike => { binary_upgrade => 1, + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + role => 1, schema_only => 1, + section_data => 1, section_pre_data => 1, }, }, + 'REFRESH MATERIALIZED VIEW matview_second' => { + all_runs => 1, regexp => qr/^ \QREFRESH MATERIALIZED VIEW matview;\E \n.* @@ -2474,12 +2945,20 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, section_post_data => 1, }, unlike => { binary_upgrade => 1, + column_inserts => 1, + data_only => 1, exclude_dump_test_schema => 1, only_dump_test_table => 1, pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + role => 1, schema_only => 1, + section_data => 1, section_pre_data => 1, }, }, + 'REVOKE CONNECT ON DATABASE dump_test FROM public' => { + all_runs => 1, + catch_all => 'REVOKE commands', create_order => 49, create_sql => 'REVOKE CONNECT ON DATABASE dump_test FROM public;', regexp => qr/^ @@ -2500,10 +2979,18 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, no_owner => 1, only_dump_test_schema => 1, only_dump_test_table => 1, + pg_dumpall_globals => 1, + pg_dumpall_globals_clean => 1, + role => 1, schema_only => 1, + section_data => 1, section_pre_data => 1, + section_post_data => 1, test_schema_plus_blobs => 1, }, }, + 'REVOKE EXECUTE ON FUNCTION pg_sleep() FROM public' => { + all_runs => 1, + catch_all => 'REVOKE commands', create_order => 15, create_sql => 'REVOKE EXECUTE ON FUNCTION pg_sleep(float8) FROM public;', @@ -2524,9 +3011,14 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, schema_only => 1, section_pre_data => 1, }, unlike => { - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_post_data => 1, + test_schema_plus_blobs => 1, }, }, + 'REVOKE SELECT ON TABLE pg_proc FROM public' => { create_order => 45, create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;', @@ -2545,9 +3037,14 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, schema_only => 1, section_pre_data => 1, }, unlike => { - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_post_data => 1, + test_schema_plus_blobs => 1, }, }, + 'REVOKE CREATE ON SCHEMA public FROM public' => { create_order => 16, create_sql => 'REVOKE CREATE ON SCHEMA public FROM public;', @@ -2569,9 +3066,14 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, schema_only => 1, section_pre_data => 1, }, unlike => { - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_post_data => 1, + test_schema_plus_blobs => 1, }, }, + 'REVOKE USAGE ON LANGUAGE plpgsql FROM public' => { create_order => 16, create_sql => 'REVOKE USAGE ON LANGUAGE plpgsql FROM public;', @@ -2590,10 +3092,16 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, schema_only => 1, section_pre_data => 1, }, unlike => { - only_dump_test_schema => 1, - only_dump_test_table => 1, - test_schema_plus_blobs => 1, }, }, + only_dump_test_schema => 1, + only_dump_test_table => 1, + pg_dumpall_globals_clean => 1, + role => 1, + section_data => 1, + section_post_data => 1, + test_schema_plus_blobs => 1, }, }, + 'REVOKE commands' => { # catch-all for REVOKE commands + all_runs => 0, # catch-all regexp => qr/^REVOKE /m, like => {}, # use more-specific options above unlike => { @@ -2644,6 +3152,10 @@ foreach my $run (sort keys %pgdump_runs) { $num_tests++; } + if ($tests{$test}->{all_runs}) + { + $num_tests++; + } } } plan tests => $num_tests; @@ -2738,6 +3250,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'"); + } + 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}), + "$run defined for `$test' or `$catch_all'"); + } + } } }