9 my $tempdir = TestLib::tempdir;
10 my $tempdir_short = TestLib::tempdir_short;
12 ###############################################################
13 # Definition of the pg_dump runs to make.
15 # Each of these runs are named and those names are used below
16 # to define how each test should (or shouldn't) treat a result
19 # test_key indicates that a given run should simply use the same
20 # set of like/unlike tests as another run, and which run that is.
22 # dump_cmd is the pg_dump command to run, which is an array of
23 # the full command and arguments to run. Note that this is run
24 # using $node->command_ok(), so the port does not need to be
25 # specified and is pulled from $PGPORT, which is set by the
26 # PostgresNode system.
28 # restore_cmd is the pg_restore command to run, if any. Note
29 # that this should generally be used when the pg_dump goes to
30 # a non-text file and that the restore can then be used to
31 # generate a text file to run through the tests from the
32 # non-text file generated by pg_dump.
34 # TODO: Have pg_restore actually restore to an independent
35 # database and then pg_dump *that* database (or something along
36 # those lines) to validate that part of the process.
42 '-f', "$tempdir/binary_upgrade.sql",
45 '-d', 'postgres', # alternative way to specify database
51 '-f', "$tempdir/clean.sql",
53 '-d', 'postgres', # alternative way to specify database
59 '-f', "$tempdir/clean_if_exists.sql",
62 '-E', 'UTF8', # no-op, just tests that option is accepted
69 '-f', "$tempdir/column_inserts.sql",
78 '-f', "$tempdir/createdb.sql",
80 '-R', # no-op, just for testing
87 '-f', "$tempdir/data_only.sql",
89 '-v', # no-op, just make sure it works
96 '-f', "$tempdir/defaults.sql",
100 defaults_custom_format => {
101 test_key => 'defaults',
106 '-f', "$tempdir/defaults_custom_format.dump",
111 '-f', "$tempdir/defaults_custom_format.sql",
112 "$tempdir/defaults_custom_format.dump",
115 defaults_dir_format => {
116 test_key => 'defaults',
120 '-f', "$tempdir/defaults_dir_format",
125 '-f', "$tempdir/defaults_dir_format.sql",
126 "$tempdir/defaults_dir_format",
129 defaults_parallel => {
130 test_key => 'defaults',
135 '-f', "$tempdir/defaults_parallel",
140 '-f', "$tempdir/defaults_parallel.sql",
141 "$tempdir/defaults_parallel",
144 defaults_tar_format => {
145 test_key => 'defaults',
149 '-f', "$tempdir/defaults_tar_format.tar",
154 '-f', "$tempdir/defaults_tar_format.sql",
155 "$tempdir/defaults_tar_format.tar",
158 exclude_dump_test_schema => {
161 '-f', "$tempdir/exclude_dump_test_schema.sql",
166 exclude_test_table => {
169 '-f', "$tempdir/exclude_test_table.sql",
170 '-T', 'dump_test.test_table',
174 exclude_test_table_data => {
177 '-f', "$tempdir/exclude_test_table_data.sql",
178 '--exclude-table-data=dump_test.test_table',
182 pg_dumpall_globals => {
185 '-f', "$tempdir/pg_dumpall_globals.sql",
189 pg_dumpall_globals_clean => {
192 '-f', "$tempdir/pg_dumpall_globals_clean.sql",
200 '-f', "$tempdir/no_privs.sql",
208 '-f', "$tempdir/no_owner.sql",
213 only_dump_test_schema => {
216 '-f', "$tempdir/only_dump_test_schema.sql",
221 only_dump_test_table => {
224 '-f', "$tempdir/only_dump_test_table.sql",
225 '-t', 'dump_test.test_table',
226 '--lock-wait-timeout=1000000',
233 '-f', "$tempdir/role.sql",
235 '--schema=dump_test_second_schema',
242 '-f', "$tempdir/schema_only.sql",
247 section_pre_data => {
250 '-f', "$tempdir/section_pre_data.sql",
251 '--section=pre-data',
258 '-f', "$tempdir/section_data.sql",
263 section_post_data => {
266 '-f', "$tempdir/section_post_data.sql",
267 '--section=post-data',
271 test_schema_plus_blobs => {
274 '-f', "$tempdir/test_schema_plus_blobs.sql",
282 ###############################################################
283 # Definition of the tests to run.
285 # Each test is defined using the log message that will be used.
287 # A regexp should be defined for each test which provides the
288 # basis for the test. That regexp will be run against the output
289 # file of each of the runs which the test is to be run against
290 # and the success of the result will depend on if the regexp
291 # result matches the expected 'like' or 'unlike' case.
293 # For each test, there are two sets of runs defined, one for
294 # the 'like' tests and one for the 'unlike' tests. 'like'
295 # essentially means "the regexp for this test must match the
296 # output file". 'unlike' is the opposite.
298 # There are a few 'catch-all' tests which can be used to have
299 # a single, simple, test to over a range of other tests. For
300 # example, there is a '^CREATE ' test, which is used for the
301 # 'data-only' test as there should never be any kind of CREATE
302 # statement in a 'data-only' run. Without the catch-all, we
303 # would have to list the 'data-only' run in each and every
304 # 'CREATE xxxx' test, which would be a lot of additional tests.
306 # Note that it makes no sense for the same run to ever be listed
307 # in both 'like' and 'unlike' categories.
309 # There can then be a 'create_sql' and 'create_order' for a
310 # given test. The 'create_sql' commands are collected up in
311 # 'create_order' and then run against the database prior to any
312 # of the pg_dump runs happening. This is what "seeds" the
313 # system with objects to be dumped out.
315 # Building of this hash takes a bit of time as all of the regexps
316 # included in it are compiled. This greatly improves performance
317 # as the regexps are used for each run the test applies to.
320 'ALTER DEFAULT PRIVILEGES FOR ROLE dump_test' => {
322 create_sql => 'ALTER DEFAULT PRIVILEGES
323 FOR ROLE dump_test IN SCHEMA dump_test
324 GRANT SELECT ON TABLES TO dump_test;',
326 \QALTER DEFAULT PRIVILEGES \E
327 \QFOR ROLE dump_test IN SCHEMA dump_test \E
328 \QGRANT SELECT ON TABLES TO dump_test;\E
333 clean_if_exists => 1,
336 exclude_test_table => 1,
337 exclude_test_table_data => 1,
338 only_dump_test_schema => 1,
340 section_post_data => 1,
341 test_schema_plus_blobs => 1,
344 exclude_dump_test_schema => 1,
346 only_dump_test_table => 1,
347 pg_dumpall_globals => 1,
348 pg_dumpall_globals_clean => 1,
349 section_pre_data => 1,
353 'ALTER ROLE dump_test' => {
355 \QALTER ROLE dump_test WITH \E
356 \QNOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB NOLOGIN \E
357 \QNOREPLICATION NOBYPASSRLS;\E
360 pg_dumpall_globals => 1,
361 pg_dumpall_globals_clean => 1,
366 clean_if_exists => 1,
369 exclude_dump_test_schema => 1,
370 exclude_test_table => 1,
371 exclude_test_table_data => 1,
374 only_dump_test_schema => 1,
375 only_dump_test_table => 1,
377 section_pre_data => 1,
378 section_post_data => 1,
379 test_schema_plus_blobs => 1,
382 'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => {
384 \QALTER FUNCTION dump_test.pltestlang_call_handler() \E
390 clean_if_exists => 1,
393 exclude_test_table => 1,
394 exclude_test_table_data => 1,
396 only_dump_test_schema => 1,
398 section_pre_data => 1,
399 test_schema_plus_blobs => 1,
402 exclude_dump_test_schema => 1,
403 only_dump_test_table => 1,
406 'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => {
407 regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .*;/m,
411 clean_if_exists => 1,
414 exclude_dump_test_schema => 1,
415 exclude_test_table => 1,
416 exclude_test_table_data => 1,
419 section_pre_data => 1,
422 only_dump_test_schema => 1,
423 only_dump_test_table => 1,
424 test_schema_plus_blobs => 1,
427 'ALTER SCHEMA dump_test OWNER TO' => {
428 regexp => qr/^ALTER SCHEMA dump_test OWNER TO .*;/m,
432 clean_if_exists => 1,
435 exclude_test_table => 1,
436 exclude_test_table_data => 1,
438 only_dump_test_schema => 1,
440 section_pre_data => 1,
441 test_schema_plus_blobs => 1,
444 exclude_dump_test_schema => 1,
445 only_dump_test_table => 1,
448 'ALTER SCHEMA dump_test_second_schema OWNER TO' => {
449 regexp => qr/^ALTER SCHEMA dump_test_second_schema OWNER TO .*;/m,
453 clean_if_exists => 1,
456 exclude_dump_test_schema => 1,
457 exclude_test_table => 1,
458 exclude_test_table_data => 1,
461 section_pre_data => 1,
464 only_dump_test_schema => 1,
465 only_dump_test_table => 1,
466 test_schema_plus_blobs => 1,
469 'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => {
471 \QALTER TABLE ONLY test_table\E \n^\s+
472 \QADD CONSTRAINT test_table_pkey PRIMARY KEY (col1);\E
477 clean_if_exists => 1,
480 exclude_test_table_data => 1,
482 only_dump_test_schema => 1,
483 only_dump_test_table => 1,
485 section_post_data => 1,
486 test_schema_plus_blobs => 1,
489 exclude_dump_test_schema => 1,
490 exclude_test_table => 1,
491 section_pre_data => 1,
495 'ALTER TABLE test_table OWNER TO' => {
496 regexp => qr/^ALTER TABLE test_table OWNER TO .*;/m,
500 clean_if_exists => 1,
503 exclude_test_table_data => 1,
505 only_dump_test_schema => 1,
506 only_dump_test_table => 1,
508 section_pre_data => 1,
509 test_schema_plus_blobs => 1,
512 exclude_dump_test_schema => 1,
513 exclude_test_table => 1,
516 'ALTER TABLE test_table ENABLE ROW LEVEL SECURITY' => {
518 create_sql => 'ALTER TABLE dump_test.test_table
519 ENABLE ROW LEVEL SECURITY;',
520 regexp => qr/^ALTER TABLE test_table ENABLE ROW LEVEL SECURITY;/m,
524 clean_if_exists => 1,
527 exclude_test_table_data => 1,
529 only_dump_test_schema => 1,
530 only_dump_test_table => 1,
532 section_post_data => 1,
533 test_schema_plus_blobs => 1,
536 section_pre_data => 1,
537 exclude_dump_test_schema => 1,
538 exclude_test_table => 1,
541 'ALTER TABLE test_second_table OWNER TO' => {
542 regexp => qr/^ALTER TABLE test_second_table OWNER TO .*;/m,
546 clean_if_exists => 1,
549 exclude_test_table => 1,
550 exclude_test_table_data => 1,
552 only_dump_test_schema => 1,
554 section_pre_data => 1,
555 test_schema_plus_blobs => 1,
558 exclude_dump_test_schema => 1,
559 only_dump_test_table => 1,
562 'ALTER TABLE test_third_table OWNER TO' => {
563 regexp => qr/^ALTER TABLE test_third_table OWNER TO .*;/m,
567 clean_if_exists => 1,
570 exclude_dump_test_schema => 1,
571 exclude_test_table => 1,
572 exclude_test_table_data => 1,
575 section_pre_data => 1,
578 only_dump_test_schema => 1,
579 only_dump_test_table => 1,
580 test_schema_plus_blobs => 1,
583 # catch-all for ALTER ... OWNER (except LARGE OBJECTs)
584 'ALTER ... OWNER commands (except LARGE OBJECTs)' => {
585 regexp => qr/^ALTER (?!LARGE OBJECT)(.*) OWNER TO .*;/m,
586 like => { }, # use more-specific options above
593 # catch-all for ALTER TABLE ...
594 'ALTER TABLE ... commands' => {
595 regexp => qr/^ALTER TABLE .*;/m,
596 like => { }, # use more-specific options above
600 pg_dumpall_globals => 1,
601 pg_dumpall_globals_clean => 1,
605 # catch-all for ALTER ... OWNER
606 'ALTER ... OWNER commands' => {
607 regexp => qr/^ALTER .* OWNER TO .*;/m,
608 like => { }, # use more-specific options above
611 pg_dumpall_globals => 1,
612 pg_dumpall_globals_clean => 1,
613 section_post_data => 1,
616 # 'BLOB load (contents are of test_table)' => {
617 # create_order => 14,
619 # "\\o '$tempdir/large_object_test.sql'\n"
620 # . "table dump_test.test_table;\n"
622 # . "\\lo_import '$tempdir/large_object_test.sql'\n",
624 # \QSELECT pg_catalog.lo_open\E \('\d+',\ \d+\);\n
625 # \QSELECT pg_catalog.lowrite(0, \E
626 # \Q'\x310a320a330a340a350a360a370a380a390a');\E\n
627 # \QSELECT pg_catalog.lo_close(0);\E
631 # clean_if_exists => 1,
634 # exclude_dump_test_schema => 1,
635 # exclude_test_table => 1,
636 # exclude_test_table_data => 1,
639 # test_schema_plus_blobs => 1,
642 # binary_upgrade => 1,
643 # only_dump_test_schema => 1,
644 # only_dump_test_table => 1,
645 # pg_dumpall_globals => 1,
647 # section_post_data => 1,
650 'COMMENT ON DATABASE postgres' => {
651 regexp => qr/^COMMENT ON DATABASE postgres IS .*;/m,
655 clean_if_exists => 1,
658 exclude_dump_test_schema => 1,
659 exclude_test_table => 1,
660 exclude_test_table_data => 1,
664 section_pre_data => 1,
667 only_dump_test_schema => 1,
668 only_dump_test_table => 1,
671 'COMMENT ON EXTENSION plpgsql' => {
672 regexp => qr/^COMMENT ON EXTENSION plpgsql IS .*;/m,
675 clean_if_exists => 1,
678 exclude_dump_test_schema => 1,
679 exclude_test_table => 1,
680 exclude_test_table_data => 1,
684 section_pre_data => 1,
688 only_dump_test_schema => 1,
689 only_dump_test_table => 1,
692 'COMMENT ON TABLE dump_test.test_table' => {
694 create_sql => 'COMMENT ON TABLE dump_test.test_table
695 IS \'comment on table\';',
696 regexp => qr/^COMMENT ON TABLE test_table IS 'comment on table';/m,
700 clean_if_exists => 1,
703 exclude_test_table_data => 1,
706 only_dump_test_schema => 1,
707 only_dump_test_table => 1,
709 section_pre_data => 1,
712 exclude_dump_test_schema => 1,
713 exclude_test_table => 1,
716 'COMMENT ON COLUMN dump_test.test_table.col1' => {
718 create_sql => 'COMMENT ON COLUMN dump_test.test_table.col1
719 IS \'comment on column\';',
721 \QCOMMENT ON COLUMN test_table.col1 IS 'comment on column';\E
726 clean_if_exists => 1,
729 exclude_test_table_data => 1,
732 only_dump_test_schema => 1,
733 only_dump_test_table => 1,
735 section_pre_data => 1,
738 exclude_dump_test_schema => 1,
739 exclude_test_table => 1,
742 'COMMENT ON COLUMN dump_test.composite.f1' => {
744 create_sql => 'COMMENT ON COLUMN dump_test.composite.f1
745 IS \'comment on column of type\';',
747 \QCOMMENT ON COLUMN composite.f1 IS 'comment on column of type';\E
752 clean_if_exists => 1,
755 exclude_test_table => 1,
756 exclude_test_table_data => 1,
759 only_dump_test_schema => 1,
761 section_pre_data => 1,
764 exclude_dump_test_schema => 1,
765 only_dump_test_table => 1,
768 # catch-all for COMMENTs
769 'COMMENT commands' => {
770 regexp => qr/^COMMENT ON /m,
771 like => { }, # use more-specific options above
775 pg_dumpall_globals => 1,
776 pg_dumpall_globals_clean => 1,
778 section_post_data => 1,
781 'COPY test_table' => {
784 'INSERT INTO dump_test.test_table (col1) '
785 . 'SELECT generate_series FROM generate_series(1,9);',
787 \QCOPY test_table (col1) FROM stdin;\E
792 clean_if_exists => 1,
798 only_dump_test_schema => 1,
799 only_dump_test_table => 1,
801 test_schema_plus_blobs => 1,
804 exclude_dump_test_schema => 1,
805 exclude_test_table => 1,
806 exclude_test_table_data => 1,
809 'COPY fk_reference_test_table' => {
812 'INSERT INTO dump_test.fk_reference_test_table (col1) '
813 . 'SELECT generate_series FROM generate_series(1,5);',
815 \QCOPY fk_reference_test_table (col1) FROM stdin;\E
820 clean_if_exists => 1,
824 exclude_test_table => 1,
825 exclude_test_table_data => 1,
828 only_dump_test_schema => 1,
830 test_schema_plus_blobs => 1,
833 exclude_dump_test_schema => 1,
834 only_dump_test_table => 1,
837 'COPY fk_reference_test_table second' => {
839 \QCOPY test_table (col1) FROM stdin;\E
840 \n(?:\d\n){9}\\\.\n.*
841 \QCOPY fk_reference_test_table (col1) FROM stdin;\E
848 exclude_dump_test_schema => 1,
849 exclude_test_table => 1,
850 exclude_test_table_data => 1,
853 'COPY test_second_table' => {
856 'INSERT INTO dump_test.test_second_table (col1, col2) '
857 . 'SELECT generate_series, generate_series::text '
858 . 'FROM generate_series(1,9);',
860 \QCOPY test_second_table (col1, col2) FROM stdin;\E
861 \n(?:\d\t\d\n){9}\\\.\n
865 clean_if_exists => 1,
869 exclude_test_table => 1,
870 exclude_test_table_data => 1,
873 only_dump_test_schema => 1,
875 test_schema_plus_blobs => 1,
878 exclude_dump_test_schema => 1,
879 only_dump_test_table => 1,
882 'COPY test_third_table' => {
885 'INSERT INTO dump_test_second_schema.test_third_table (col1) '
886 . 'SELECT generate_series FROM generate_series(1,9);',
888 \QCOPY test_third_table (col1) FROM stdin;\E
893 clean_if_exists => 1,
897 exclude_dump_test_schema => 1,
898 exclude_test_table => 1,
899 exclude_test_table_data => 1,
905 only_dump_test_schema => 1,
906 only_dump_test_table => 1,
907 test_schema_plus_blobs => 1,
910 'INSERT INTO test_table' => {
912 (?:INSERT\ INTO\ test_table\ \(col1\)\ VALUES\ \(\d\);\n){9}
919 clean_if_exists => 1,
923 exclude_dump_test_schema => 1,
924 exclude_test_table => 1,
925 exclude_test_table_data => 1,
929 only_dump_test_schema => 1,
930 only_dump_test_table => 1,
931 test_schema_plus_blobs => 1,
934 'INSERT INTO test_second_table' => {
936 (?:INSERT\ INTO\ test_second_table\ \(col1,\ col2\)
937 \ VALUES\ \(\d,\ '\d'\);\n){9}/xm,
943 clean_if_exists => 1,
947 exclude_dump_test_schema => 1,
948 exclude_test_table => 1,
949 exclude_test_table_data => 1,
953 only_dump_test_schema => 1,
954 only_dump_test_table => 1,
955 test_schema_plus_blobs => 1,
958 'INSERT INTO test_third_table' => {
960 (?:INSERT\ INTO\ test_third_table\ \(col1\)
961 \ VALUES\ \(\d\);\n){9}/xm,
967 clean_if_exists => 1,
971 exclude_dump_test_schema => 1,
972 exclude_test_table => 1,
973 exclude_test_table_data => 1,
977 only_dump_test_schema => 1,
978 only_dump_test_table => 1,
979 test_schema_plus_blobs => 1,
982 'COPY ... commands' => { # catch-all for COPY
983 regexp => qr/^COPY /m,
984 like => { }, # use more-specific options above
988 pg_dumpall_globals => 1,
989 pg_dumpall_globals_clean => 1,
991 section_post_data => 1,
994 'CREATE ROLE dump_test' => {
996 create_sql => 'CREATE ROLE dump_test;',
997 regexp => qr/^CREATE ROLE dump_test;/m,
999 pg_dumpall_globals => 1,
1000 pg_dumpall_globals_clean => 1,
1003 binary_upgrade => 1,
1005 clean_if_exists => 1,
1008 exclude_dump_test_schema => 1,
1009 exclude_test_table => 1,
1010 exclude_test_table_data => 1,
1013 only_dump_test_schema => 1,
1014 only_dump_test_table => 1,
1016 section_pre_data => 1,
1017 section_post_data => 1,
1018 test_schema_plus_blobs => 1,
1021 'CREATE DATABASE postgres' => {
1023 \QCREATE DATABASE postgres WITH TEMPLATE = template0 \E
1029 binary_upgrade => 1,
1031 clean_if_exists => 1,
1033 exclude_dump_test_schema => 1,
1034 exclude_test_table => 1,
1035 exclude_test_table_data => 1,
1038 only_dump_test_schema => 1,
1039 only_dump_test_table => 1,
1040 pg_dumpall_globals => 1,
1041 pg_dumpall_globals_clean => 1,
1043 section_pre_data => 1,
1044 section_post_data => 1,
1045 test_schema_plus_blobs => 1,
1048 'CREATE EXTENSION ... plpgsql' => {
1050 \QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E
1054 clean_if_exists => 1,
1057 exclude_dump_test_schema => 1,
1058 exclude_test_table => 1,
1059 exclude_test_table_data => 1,
1063 section_pre_data => 1,
1066 binary_upgrade => 1,
1067 only_dump_test_schema => 1,
1068 only_dump_test_table => 1,
1069 pg_dumpall_globals => 1,
1070 pg_dumpall_globals_clean => 1,
1071 section_post_data => 1,
1072 test_schema_plus_blobs => 1,
1075 'CREATE AGGREGATE dump_test.newavg' => {
1077 create_sql => 'CREATE AGGREGATE dump_test.newavg (
1078 sfunc = int4_avg_accum,
1081 finalfunc = int8_avg,
1082 initcond1 = \'{0,0}\'
1085 \QCREATE AGGREGATE newavg(integer) (\E
1086 \n\s+\QSFUNC = int4_avg_accum,\E
1087 \n\s+\QSTYPE = bigint[],\E
1088 \n\s+\QINITCOND = '{0,0}',\E
1089 \n\s+\QFINALFUNC = int8_avg\E
1092 binary_upgrade => 1,
1094 clean_if_exists => 1,
1097 exclude_test_table => 1,
1098 exclude_test_table_data => 1,
1101 only_dump_test_schema => 1,
1103 section_pre_data => 1,
1104 test_schema_plus_blobs => 1,
1107 exclude_dump_test_schema => 1,
1108 only_dump_test_table => 1,
1109 pg_dumpall_globals => 1,
1110 pg_dumpall_globals_clean => 1,
1111 section_post_data => 1,
1114 'CREATE DOMAIN dump_test.us_postal_code' => {
1116 create_sql => 'CREATE DOMAIN dump_test.us_postal_code AS TEXT
1117 CHECK(VALUE ~ \'^\d{5}$\' OR
1118 VALUE ~ \'^\d{5}-\d{4}$\');',
1120 \QCREATE DOMAIN us_postal_code AS text\E
1122 \QCONSTRAINT us_postal_code_check CHECK \E
1123 \Q(((VALUE ~ '^\d{5}\E
1124 \$\Q'::text) OR (VALUE ~ '^\d{5}-\d{4}\E\$
1128 binary_upgrade => 1,
1130 clean_if_exists => 1,
1133 exclude_test_table => 1,
1134 exclude_test_table_data => 1,
1137 only_dump_test_schema => 1,
1139 section_pre_data => 1,
1140 test_schema_plus_blobs => 1,
1143 exclude_dump_test_schema => 1,
1144 only_dump_test_table => 1,
1145 pg_dumpall_globals => 1,
1146 pg_dumpall_globals_clean => 1,
1147 section_post_data => 1,
1150 'CREATE FUNCTION dump_test.pltestlang_call_handler' => {
1152 create_sql => 'CREATE FUNCTION dump_test.pltestlang_call_handler()
1153 RETURNS LANGUAGE_HANDLER AS \'$libdir/plpgsql\',
1154 \'plpgsql_call_handler\' LANGUAGE C;',
1156 \QCREATE FUNCTION pltestlang_call_handler() \E
1157 \QRETURNS language_handler\E
1160 \Qlibdir\/plpgsql', 'plpgsql_call_handler';\E
1163 binary_upgrade => 1,
1165 clean_if_exists => 1,
1168 exclude_test_table => 1,
1169 exclude_test_table_data => 1,
1172 only_dump_test_schema => 1,
1174 section_pre_data => 1,
1175 test_schema_plus_blobs => 1,
1178 exclude_dump_test_schema => 1,
1179 only_dump_test_table => 1,
1180 pg_dumpall_globals => 1,
1181 pg_dumpall_globals_clean => 1,
1182 section_post_data => 1,
1185 'CREATE FUNCTION dump_test.trigger_func' => {
1187 create_sql => 'CREATE FUNCTION dump_test.trigger_func()
1188 RETURNS trigger LANGUAGE plpgsql
1189 AS $$ BEGIN RETURN NULL; END;$$;',
1191 \QCREATE FUNCTION trigger_func() RETURNS trigger\E
1192 \n\s+\QLANGUAGE plpgsql\E
1194 \Q BEGIN RETURN NULL; END;\E
1197 binary_upgrade => 1,
1199 clean_if_exists => 1,
1202 exclude_test_table => 1,
1203 exclude_test_table_data => 1,
1206 only_dump_test_schema => 1,
1208 section_pre_data => 1,
1209 test_schema_plus_blobs => 1,
1212 exclude_dump_test_schema => 1,
1213 only_dump_test_table => 1,
1214 pg_dumpall_globals => 1,
1215 pg_dumpall_globals_clean => 1,
1216 section_post_data => 1,
1219 'CREATE FUNCTION dump_test.event_trigger_func' => {
1221 create_sql => 'CREATE FUNCTION dump_test.event_trigger_func()
1222 RETURNS event_trigger LANGUAGE plpgsql
1223 AS $$ BEGIN RETURN; END;$$;',
1225 \QCREATE FUNCTION event_trigger_func() RETURNS event_trigger\E
1226 \n\s+\QLANGUAGE plpgsql\E
1228 \Q BEGIN RETURN; END;\E
1231 binary_upgrade => 1,
1233 clean_if_exists => 1,
1236 exclude_test_table => 1,
1237 exclude_test_table_data => 1,
1240 only_dump_test_schema => 1,
1242 section_pre_data => 1,
1243 test_schema_plus_blobs => 1,
1246 exclude_dump_test_schema => 1,
1247 only_dump_test_table => 1,
1248 pg_dumpall_globals => 1,
1249 pg_dumpall_globals_clean => 1,
1250 section_post_data => 1,
1253 'CREATE EVENT TRIGGER test_event_trigger' => {
1255 create_sql => 'CREATE EVENT TRIGGER test_event_trigger
1256 ON ddl_command_start
1257 EXECUTE PROCEDURE dump_test.event_trigger_func();',
1259 \QCREATE EVENT TRIGGER test_event_trigger \E
1260 \QON ddl_command_start\E
1261 \n\s+\QEXECUTE PROCEDURE dump_test.event_trigger_func();\E
1264 binary_upgrade => 1,
1266 clean_if_exists => 1,
1269 exclude_dump_test_schema => 1,
1270 exclude_test_table => 1,
1271 exclude_test_table_data => 1,
1275 section_post_data => 1,
1278 section_pre_data => 1,
1279 only_dump_test_schema => 1,
1280 only_dump_test_table => 1,
1281 pg_dumpall_globals => 1,
1282 pg_dumpall_globals_clean => 1,
1283 test_schema_plus_blobs => 1,
1286 'CREATE TRIGGER test_trigger' => {
1288 create_sql => 'CREATE TRIGGER test_trigger
1289 BEFORE INSERT ON dump_test.test_table
1290 FOR EACH ROW WHEN (NEW.col1 > 10)
1291 EXECUTE PROCEDURE dump_test.trigger_func();',
1293 \QCREATE TRIGGER test_trigger BEFORE INSERT ON test_table \E
1294 \QFOR EACH ROW WHEN ((new.col1 > 10)) \E
1295 \QEXECUTE PROCEDURE trigger_func();\E
1298 binary_upgrade => 1,
1300 clean_if_exists => 1,
1303 exclude_test_table_data => 1,
1306 only_dump_test_schema => 1,
1307 only_dump_test_table => 1,
1309 section_post_data => 1,
1310 test_schema_plus_blobs => 1,
1313 section_pre_data => 1,
1314 exclude_dump_test_schema => 1,
1315 exclude_test_table => 1,
1316 pg_dumpall_globals => 1,
1317 pg_dumpall_globals_clean => 1,
1320 'CREATE TYPE dump_test.planets AS ENUM' => {
1322 create_sql => 'CREATE TYPE dump_test.planets
1323 AS ENUM ( \'venus\', \'earth\', \'mars\' );',
1325 \QCREATE TYPE planets AS ENUM (\E
1332 clean_if_exists => 1,
1335 exclude_test_table => 1,
1336 exclude_test_table_data => 1,
1339 only_dump_test_schema => 1,
1341 section_pre_data => 1,
1342 test_schema_plus_blobs => 1,
1345 exclude_dump_test_schema => 1,
1346 only_dump_test_table => 1,
1347 pg_dumpall_globals => 1,
1348 pg_dumpall_globals_clean => 1,
1349 section_post_data => 1,
1352 'CREATE TYPE dump_test.planets AS ENUM pg_upgrade' => {
1354 \QCREATE TYPE planets AS ENUM (\E
1356 \QALTER TYPE dump_test.planets ADD VALUE 'venus';\E
1358 \QALTER TYPE dump_test.planets ADD VALUE 'earth';\E
1360 \QALTER TYPE dump_test.planets ADD VALUE 'mars';\E
1363 binary_upgrade => 1,
1367 clean_if_exists => 1,
1370 exclude_test_table => 1,
1371 exclude_test_table_data => 1,
1374 only_dump_test_schema => 1,
1376 section_pre_data => 1,
1377 test_schema_plus_blobs => 1,
1378 exclude_dump_test_schema => 1,
1379 only_dump_test_table => 1,
1380 pg_dumpall_globals => 1,
1381 pg_dumpall_globals_clean => 1,
1382 section_post_data => 1,
1385 'CREATE TYPE dump_test.textrange AS RANGE' => {
1387 create_sql => 'CREATE TYPE dump_test.textrange
1388 AS RANGE (subtype=text, collation="C");',
1390 \QCREATE TYPE textrange AS RANGE (\E
1391 \n\s+\Qsubtype = text,\E
1392 \n\s+\Qcollation = pg_catalog."C"\E
1396 clean_if_exists => 1,
1399 exclude_test_table => 1,
1400 exclude_test_table_data => 1,
1403 only_dump_test_schema => 1,
1405 section_pre_data => 1,
1406 test_schema_plus_blobs => 1,
1409 exclude_dump_test_schema => 1,
1410 only_dump_test_table => 1,
1411 pg_dumpall_globals => 1,
1412 pg_dumpall_globals_clean => 1,
1413 section_post_data => 1,
1416 'CREATE TYPE dump_test.int42' => {
1418 create_sql => 'CREATE TYPE dump_test.int42;',
1419 regexp => qr/^CREATE TYPE int42;/m,
1422 clean_if_exists => 1,
1425 exclude_test_table => 1,
1426 exclude_test_table_data => 1,
1429 only_dump_test_schema => 1,
1431 section_pre_data => 1,
1432 test_schema_plus_blobs => 1,
1435 exclude_dump_test_schema => 1,
1436 only_dump_test_table => 1,
1437 pg_dumpall_globals => 1,
1438 pg_dumpall_globals_clean => 1,
1439 section_post_data => 1,
1442 'CREATE FUNCTION dump_test.int42_in' => {
1444 create_sql => 'CREATE FUNCTION dump_test.int42_in(cstring)
1445 RETURNS dump_test.int42 AS \'int4in\'
1446 LANGUAGE internal STRICT IMMUTABLE;',
1448 \QCREATE FUNCTION int42_in(cstring) RETURNS int42\E
1449 \n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
1450 \n\s+AS\ \$\$int4in\$\$;
1453 binary_upgrade => 1,
1455 clean_if_exists => 1,
1458 exclude_test_table => 1,
1459 exclude_test_table_data => 1,
1462 only_dump_test_schema => 1,
1464 section_pre_data => 1,
1465 test_schema_plus_blobs => 1,
1468 exclude_dump_test_schema => 1,
1469 only_dump_test_table => 1,
1470 pg_dumpall_globals => 1,
1471 pg_dumpall_globals_clean => 1,
1472 section_post_data => 1,
1475 'CREATE FUNCTION dump_test.int42_out' => {
1477 create_sql => 'CREATE FUNCTION dump_test.int42_out(dump_test.int42)
1478 RETURNS cstring AS \'int4out\'
1479 LANGUAGE internal STRICT IMMUTABLE;',
1481 \QCREATE FUNCTION int42_out(int42) RETURNS cstring\E
1482 \n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
1483 \n\s+AS\ \$\$int4out\$\$;
1486 binary_upgrade => 1,
1488 clean_if_exists => 1,
1491 exclude_test_table => 1,
1492 exclude_test_table_data => 1,
1495 only_dump_test_schema => 1,
1497 section_pre_data => 1,
1498 test_schema_plus_blobs => 1,
1501 exclude_dump_test_schema => 1,
1502 only_dump_test_table => 1,
1503 pg_dumpall_globals => 1,
1504 pg_dumpall_globals_clean => 1,
1505 section_post_data => 1,
1508 'CREATE TYPE dump_test.int42 populated' => {
1510 create_sql => 'CREATE TYPE dump_test.int42 (
1512 input = dump_test.int42_in,
1513 output = dump_test.int42_out,
1518 \QCREATE TYPE int42 (\E
1519 \n\s+\QINTERNALLENGTH = 4,\E
1520 \n\s+\QINPUT = int42_in,\E
1521 \n\s+\QOUTPUT = int42_out,\E
1522 \n\s+\QDEFAULT = '42',\E
1523 \n\s+\QALIGNMENT = int4,\E
1524 \n\s+\QSTORAGE = plain,\E
1525 \n\s+PASSEDBYVALUE\n\);
1529 clean_if_exists => 1,
1532 exclude_test_table => 1,
1533 exclude_test_table_data => 1,
1536 only_dump_test_schema => 1,
1538 section_pre_data => 1,
1539 test_schema_plus_blobs => 1,
1542 exclude_dump_test_schema => 1,
1543 only_dump_test_table => 1,
1544 pg_dumpall_globals => 1,
1545 pg_dumpall_globals_clean => 1,
1546 section_post_data => 1,
1549 'CREATE TYPE dump_test.composite' => {
1551 create_sql => 'CREATE TYPE dump_test.composite AS (
1556 \QCREATE TYPE composite AS (\E
1557 \n\s+\Qf1 integer,\E
1563 clean_if_exists => 1,
1566 exclude_test_table => 1,
1567 exclude_test_table_data => 1,
1570 only_dump_test_schema => 1,
1572 section_pre_data => 1,
1573 test_schema_plus_blobs => 1,
1576 exclude_dump_test_schema => 1,
1577 only_dump_test_table => 1,
1578 pg_dumpall_globals => 1,
1579 pg_dumpall_globals_clean => 1,
1580 section_post_data => 1,
1583 'CREATE FOREIGN DATA WRAPPER dummy' => {
1585 create_sql => 'CREATE FOREIGN DATA WRAPPER dummy;',
1586 regexp => qr/CREATE FOREIGN DATA WRAPPER dummy;/m,
1588 binary_upgrade => 1,
1590 clean_if_exists => 1,
1593 exclude_dump_test_schema => 1,
1594 exclude_test_table => 1,
1595 exclude_test_table_data => 1,
1599 section_pre_data => 1,
1602 only_dump_test_schema => 1,
1603 only_dump_test_table => 1,
1604 pg_dumpall_globals => 1,
1605 pg_dumpall_globals_clean => 1,
1606 section_post_data => 1,
1607 test_schema_plus_blobs => 1,
1610 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy' => {
1612 create_sql => 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;',
1613 regexp => qr/CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;/m,
1615 binary_upgrade => 1,
1617 clean_if_exists => 1,
1620 exclude_dump_test_schema => 1,
1621 exclude_test_table => 1,
1622 exclude_test_table_data => 1,
1626 section_pre_data => 1,
1629 only_dump_test_schema => 1,
1630 only_dump_test_table => 1,
1631 pg_dumpall_globals => 1,
1632 pg_dumpall_globals_clean => 1,
1633 section_post_data => 1,
1634 test_schema_plus_blobs => 1,
1637 #######################################
1639 #######################################
1641 # 'CREATE TRANSFORM FOR int' => {
1642 # create_order => 34,
1643 # create_sql => 'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION varchar_transform(internal), TO SQL WITH FUNCTION int4recv(internal));',
1644 # regexp => qr/CREATE TRANSFORM FOR int LANGUAGE SQL \(FROM SQL WITH FUNCTION varchar_transform\(internal\), TO SQL WITH FUNCTION int4recv\(internal\)\);/m,
1646 # binary_upgrade => 1,
1648 # clean_if_exists => 1,
1651 # exclude_dump_test_schema => 1,
1652 # exclude_test_table => 1,
1653 # exclude_test_table_data => 1,
1657 # section_post_data => 1,
1660 # section_pre_data => 1,
1661 # only_dump_test_schema => 1,
1662 # only_dump_test_table => 1,
1663 # pg_dumpall_globals => 1,
1664 # test_schema_plus_blobs => 1,
1667 'CREATE LANGUAGE pltestlang' => {
1669 create_sql => 'CREATE LANGUAGE pltestlang
1670 HANDLER dump_test.pltestlang_call_handler;',
1672 \QCREATE PROCEDURAL LANGUAGE pltestlang \E
1673 \QHANDLER pltestlang_call_handler;\E
1676 binary_upgrade => 1,
1678 clean_if_exists => 1,
1681 exclude_test_table => 1,
1682 exclude_test_table_data => 1,
1686 section_pre_data => 1,
1689 exclude_dump_test_schema => 1,
1690 only_dump_test_table => 1,
1691 pg_dumpall_globals => 1,
1692 pg_dumpall_globals_clean => 1,
1693 section_post_data => 1,
1694 only_dump_test_schema => 1,
1695 test_schema_plus_blobs => 1,
1698 'CREATE MATERIALIZED VIEW matview' => {
1700 create_sql => 'CREATE MATERIALIZED VIEW dump_test.matview (col1) AS
1701 SELECT * FROM dump_test.test_table;',
1703 \QCREATE MATERIALIZED VIEW matview AS\E
1704 \n\s+\QSELECT test_table.col1\E
1705 \n\s+\QFROM test_table\E
1706 \n\s+\QWITH NO DATA;\E
1709 binary_upgrade => 1,
1711 clean_if_exists => 1,
1714 exclude_test_table => 1,
1715 exclude_test_table_data => 1,
1718 only_dump_test_schema => 1,
1720 section_pre_data => 1,
1721 test_schema_plus_blobs => 1,
1724 exclude_dump_test_schema => 1,
1725 only_dump_test_table => 1,
1726 pg_dumpall_globals => 1,
1727 pg_dumpall_globals_clean => 1,
1728 section_post_data => 1,
1731 'CREATE MATERIALIZED VIEW matview_second' => {
1733 create_sql => 'CREATE MATERIALIZED VIEW
1734 dump_test.matview_second (col1) AS
1735 SELECT * FROM dump_test.matview;',
1737 \QCREATE MATERIALIZED VIEW matview_second AS\E
1738 \n\s+\QSELECT matview.col1\E
1739 \n\s+\QFROM matview\E
1740 \n\s+\QWITH NO DATA;\E
1743 binary_upgrade => 1,
1745 clean_if_exists => 1,
1748 exclude_test_table => 1,
1749 exclude_test_table_data => 1,
1752 only_dump_test_schema => 1,
1754 section_pre_data => 1,
1755 test_schema_plus_blobs => 1,
1758 exclude_dump_test_schema => 1,
1759 only_dump_test_table => 1,
1760 pg_dumpall_globals => 1,
1761 pg_dumpall_globals_clean => 1,
1762 section_post_data => 1,
1765 'CREATE POLICY p1 ON test_table' => {
1767 create_sql => 'CREATE POLICY p1 ON dump_test.test_table
1769 WITH CHECK (true);',
1771 \QCREATE POLICY p1 ON test_table FOR ALL TO PUBLIC \E
1772 \QUSING (true) WITH CHECK (true);\E
1775 binary_upgrade => 1,
1777 clean_if_exists => 1,
1780 exclude_test_table_data => 1,
1783 only_dump_test_schema => 1,
1784 only_dump_test_table => 1,
1786 section_post_data => 1,
1787 test_schema_plus_blobs => 1,
1790 section_pre_data => 1,
1791 exclude_dump_test_schema => 1,
1792 exclude_test_table => 1,
1793 pg_dumpall_globals => 1,
1794 pg_dumpall_globals_clean => 1,
1797 'CREATE POLICY p2 ON test_table FOR SELECT' => {
1799 create_sql => 'CREATE POLICY p2 ON dump_test.test_table
1800 FOR SELECT TO dump_test USING (true);',
1802 \QCREATE POLICY p2 ON test_table FOR SELECT TO dump_test \E
1806 binary_upgrade => 1,
1808 clean_if_exists => 1,
1811 exclude_test_table_data => 1,
1814 only_dump_test_schema => 1,
1815 only_dump_test_table => 1,
1817 section_post_data => 1,
1818 test_schema_plus_blobs => 1,
1821 section_pre_data => 1,
1822 exclude_dump_test_schema => 1,
1823 exclude_test_table => 1,
1824 pg_dumpall_globals => 1,
1825 pg_dumpall_globals_clean => 1,
1828 'CREATE POLICY p3 ON test_table FOR INSERT' => {
1830 create_sql => 'CREATE POLICY p3 ON dump_test.test_table
1831 FOR INSERT TO dump_test WITH CHECK (true);',
1833 \QCREATE POLICY p3 ON test_table FOR INSERT \E
1834 \QTO dump_test WITH CHECK (true);\E
1837 binary_upgrade => 1,
1839 clean_if_exists => 1,
1842 exclude_test_table_data => 1,
1845 only_dump_test_schema => 1,
1846 only_dump_test_table => 1,
1848 section_post_data => 1,
1849 test_schema_plus_blobs => 1,
1852 section_pre_data => 1,
1853 exclude_dump_test_schema => 1,
1854 exclude_test_table => 1,
1855 pg_dumpall_globals => 1,
1856 pg_dumpall_globals_clean => 1,
1859 'CREATE POLICY p4 ON test_table FOR UPDATE' => {
1861 create_sql => 'CREATE POLICY p4 ON dump_test.test_table FOR UPDATE
1862 TO dump_test USING (true) WITH CHECK (true);',
1864 \QCREATE POLICY p4 ON test_table FOR UPDATE TO dump_test \E
1865 \QUSING (true) WITH CHECK (true);\E
1868 binary_upgrade => 1,
1870 clean_if_exists => 1,
1873 exclude_test_table_data => 1,
1876 only_dump_test_schema => 1,
1877 only_dump_test_table => 1,
1879 section_post_data => 1,
1880 test_schema_plus_blobs => 1,
1883 section_pre_data => 1,
1884 exclude_dump_test_schema => 1,
1885 exclude_test_table => 1,
1886 pg_dumpall_globals => 1,
1887 pg_dumpall_globals_clean => 1,
1890 'CREATE POLICY p5 ON test_table FOR DELETE' => {
1892 create_sql => 'CREATE POLICY p5 ON dump_test.test_table
1893 FOR DELETE TO dump_test USING (true);',
1895 \QCREATE POLICY p5 ON test_table FOR DELETE \E
1896 \QTO dump_test USING (true);\E
1899 binary_upgrade => 1,
1901 clean_if_exists => 1,
1904 exclude_test_table_data => 1,
1907 only_dump_test_schema => 1,
1908 only_dump_test_table => 1,
1910 section_post_data => 1,
1911 test_schema_plus_blobs => 1,
1914 section_pre_data => 1,
1915 exclude_dump_test_schema => 1,
1916 exclude_test_table => 1,
1917 pg_dumpall_globals => 1,
1918 pg_dumpall_globals_clean => 1,
1921 'CREATE SCHEMA dump_test' => {
1923 create_sql => 'CREATE SCHEMA dump_test;',
1924 regexp => qr/^CREATE SCHEMA dump_test;/m,
1926 binary_upgrade => 1,
1928 clean_if_exists => 1,
1931 exclude_test_table => 1,
1932 exclude_test_table_data => 1,
1935 only_dump_test_schema => 1,
1937 section_pre_data => 1,
1938 test_schema_plus_blobs => 1,
1941 exclude_dump_test_schema => 1,
1942 only_dump_test_table => 1,
1943 pg_dumpall_globals => 1,
1944 pg_dumpall_globals_clean => 1,
1945 section_post_data => 1,
1948 'CREATE SCHEMA dump_test_second_schema' => {
1950 create_sql => 'CREATE SCHEMA dump_test_second_schema;',
1951 regexp => qr/^CREATE SCHEMA dump_test_second_schema;/m,
1953 binary_upgrade => 1,
1955 clean_if_exists => 1,
1958 exclude_dump_test_schema => 1,
1959 exclude_test_table => 1,
1960 exclude_test_table_data => 1,
1964 section_pre_data => 1,
1967 only_dump_test_schema => 1,
1968 only_dump_test_table => 1,
1969 pg_dumpall_globals => 1,
1970 pg_dumpall_globals_clean => 1,
1971 section_post_data => 1,
1972 test_schema_plus_blobs => 1,
1975 'CREATE TABLE test_table' => {
1977 create_sql => 'CREATE TABLE dump_test.test_table (
1978 col1 serial primary key,
1979 CHECK (col1 <= 1000)
1982 \QCREATE TABLE test_table (\E
1983 \n\s+\Qcol1 integer NOT NULL,\E
1984 \n\s+\QCONSTRAINT test_table_col1_check CHECK \E
1985 \Q((col1 <= 1000))\E
1988 binary_upgrade => 1,
1990 clean_if_exists => 1,
1993 exclude_test_table_data => 1,
1996 only_dump_test_schema => 1,
1997 only_dump_test_table => 1,
1999 section_pre_data => 1,
2000 test_schema_plus_blobs => 1,
2003 exclude_dump_test_schema => 1,
2004 exclude_test_table => 1,
2005 pg_dumpall_globals => 1,
2006 pg_dumpall_globals_clean => 1,
2007 section_post_data => 1,
2010 'CREATE TABLE fk_reference_test_table' => {
2012 create_sql => 'CREATE TABLE dump_test.fk_reference_test_table (
2013 col1 int primary key references dump_test.test_table
2016 \QCREATE TABLE fk_reference_test_table (\E
2017 \n\s+\Qcol1 integer NOT NULL\E
2021 binary_upgrade => 1,
2023 clean_if_exists => 1,
2026 exclude_test_table => 1,
2027 exclude_test_table_data => 1,
2030 only_dump_test_schema => 1,
2032 section_pre_data => 1,
2033 test_schema_plus_blobs => 1,
2036 exclude_dump_test_schema => 1,
2037 only_dump_test_table => 1,
2038 pg_dumpall_globals => 1,
2039 pg_dumpall_globals_clean => 1,
2040 section_post_data => 1,
2043 'CREATE TABLE test_second_table' => {
2045 create_sql => 'CREATE TABLE dump_test.test_second_table (
2050 \QCREATE TABLE test_second_table (\E
2051 \n\s+\Qcol1 integer,\E
2056 binary_upgrade => 1,
2058 clean_if_exists => 1,
2061 exclude_test_table => 1,
2062 exclude_test_table_data => 1,
2065 only_dump_test_schema => 1,
2067 section_pre_data => 1,
2068 test_schema_plus_blobs => 1,
2071 exclude_dump_test_schema => 1,
2072 only_dump_test_table => 1,
2073 pg_dumpall_globals => 1,
2074 pg_dumpall_globals_clean => 1,
2075 section_post_data => 1,
2078 'CREATE TABLE test_third_table' => {
2080 create_sql => 'CREATE TABLE dump_test_second_schema.test_third_table (
2084 \QCREATE TABLE test_third_table (\E
2085 \n\s+\Qcol1 integer NOT NULL\E
2089 binary_upgrade => 1,
2091 clean_if_exists => 1,
2094 exclude_dump_test_schema => 1,
2095 exclude_test_table => 1,
2096 exclude_test_table_data => 1,
2100 section_pre_data => 1,
2103 only_dump_test_schema => 1,
2104 only_dump_test_table => 1,
2105 pg_dumpall_globals => 1,
2106 pg_dumpall_globals_clean => 1,
2107 section_post_data => 1,
2108 test_schema_plus_blobs => 1,
2111 'CREATE SEQUENCE test_table_col1_seq' => {
2113 \QCREATE SEQUENCE test_table_col1_seq\E
2114 \n\s+\QSTART WITH 1\E
2115 \n\s+\QINCREMENT BY 1\E
2116 \n\s+\QNO MINVALUE\E
2117 \n\s+\QNO MAXVALUE\E
2121 binary_upgrade => 1,
2123 clean_if_exists => 1,
2126 exclude_test_table => 1,
2127 exclude_test_table_data => 1,
2130 only_dump_test_schema => 1,
2131 only_dump_test_table => 1,
2133 section_pre_data => 1,
2134 test_schema_plus_blobs => 1,
2137 exclude_dump_test_schema => 1,
2138 pg_dumpall_globals => 1,
2139 pg_dumpall_globals_clean => 1,
2140 section_post_data => 1,
2143 'CREATE SEQUENCE test_third_table_col1_seq' => {
2145 \QCREATE SEQUENCE test_third_table_col1_seq\E
2146 \n\s+\QSTART WITH 1\E
2147 \n\s+\QINCREMENT BY 1\E
2148 \n\s+\QNO MINVALUE\E
2149 \n\s+\QNO MAXVALUE\E
2153 binary_upgrade => 1,
2155 clean_if_exists => 1,
2158 exclude_dump_test_schema => 1,
2159 exclude_test_table => 1,
2160 exclude_test_table_data => 1,
2164 section_pre_data => 1,
2167 only_dump_test_schema => 1,
2168 only_dump_test_table => 1,
2169 pg_dumpall_globals => 1,
2170 pg_dumpall_globals_clean => 1,
2171 section_post_data => 1,
2172 test_schema_plus_blobs => 1,
2175 'CREATE UNIQUE INDEX test_third_table_idx ON test_third_table' => {
2177 create_sql => 'CREATE UNIQUE INDEX test_third_table_idx
2178 ON dump_test_second_schema.test_third_table (col1);',
2180 \QCREATE UNIQUE INDEX test_third_table_idx \E
2181 \QON test_third_table USING btree (col1);\E
2184 binary_upgrade => 1,
2186 clean_if_exists => 1,
2189 exclude_dump_test_schema => 1,
2190 exclude_test_table => 1,
2191 exclude_test_table_data => 1,
2195 section_post_data => 1,
2198 only_dump_test_schema => 1,
2199 only_dump_test_table => 1,
2200 pg_dumpall_globals => 1,
2201 pg_dumpall_globals_clean => 1,
2202 test_schema_plus_blobs => 1,
2205 'CREATE ... commands' => { # catch-all for CREATE
2206 regexp => qr/^CREATE /m,
2207 like => { }, # use more-specific options above
2209 column_inserts => 1,
2214 'DROP EXTENSION plpgsql' => {
2215 regexp => qr/^DROP EXTENSION plpgsql;/m,
2220 clean_if_exists => 1,
2223 'DROP FUNCTION dump_test.pltestlang_call_handler()' => {
2224 regexp => qr/^DROP FUNCTION dump_test\.pltestlang_call_handler\(\);/m,
2229 clean_if_exists => 1,
2232 'DROP LANGUAGE pltestlang' => {
2233 regexp => qr/^DROP PROCEDURAL LANGUAGE pltestlang;/m,
2238 clean_if_exists => 1,
2241 'DROP SCHEMA dump_test' => {
2242 regexp => qr/^DROP SCHEMA dump_test;/m,
2247 clean_if_exists => 1,
2250 'DROP SCHEMA dump_test_second_schema' => {
2251 regexp => qr/^DROP SCHEMA dump_test_second_schema;/m,
2256 clean_if_exists => 1,
2259 'DROP TABLE test_table' => {
2260 regexp => qr/^DROP TABLE dump_test\.test_table;/m,
2265 clean_if_exists => 1,
2268 'DROP TABLE fk_reference_test_table' => {
2269 regexp => qr/^DROP TABLE dump_test\.fk_reference_test_table;/m,
2274 clean_if_exists => 1,
2277 'DROP TABLE test_second_table' => {
2278 regexp => qr/^DROP TABLE dump_test\.test_second_table;/m,
2283 clean_if_exists => 1,
2286 'DROP TABLE test_third_table' => {
2287 regexp => qr/^DROP TABLE dump_test_second_schema\.test_third_table;/m,
2292 clean_if_exists => 1,
2295 'DROP EXTENSION IF EXISTS plpgsql' => {
2296 regexp => qr/^DROP EXTENSION IF EXISTS plpgsql;/m,
2298 clean_if_exists => 1,
2304 'DROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler()' => {
2306 \QDROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler();\E
2309 clean_if_exists => 1,
2315 'DROP LANGUAGE IF EXISTS pltestlang' => {
2316 regexp => qr/^DROP PROCEDURAL LANGUAGE IF EXISTS pltestlang;/m,
2318 clean_if_exists => 1,
2324 'DROP SCHEMA IF EXISTS dump_test' => {
2325 regexp => qr/^DROP SCHEMA IF EXISTS dump_test;/m,
2327 clean_if_exists => 1,
2333 'DROP SCHEMA IF EXISTS dump_test_second_schema' => {
2334 regexp => qr/^DROP SCHEMA IF EXISTS dump_test_second_schema;/m,
2336 clean_if_exists => 1,
2342 'DROP TABLE IF EXISTS test_table' => {
2343 regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_table;/m,
2345 clean_if_exists => 1,
2351 'DROP TABLE IF EXISTS test_second_table' => {
2352 regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_second_table;/m,
2354 clean_if_exists => 1,
2360 'DROP TABLE IF EXISTS test_third_table' => {
2362 \QDROP TABLE IF EXISTS dump_test_second_schema.test_third_table;\E
2365 clean_if_exists => 1,
2371 'DROP ROLE dump_test' => {
2373 \QDROP ROLE dump_test;\E
2376 pg_dumpall_globals_clean => 1,
2380 clean_if_exists => 1,
2383 'DROP ROLE pg_' => {
2385 \QDROP ROLE pg_\E.*;
2391 clean_if_exists => 1,
2392 pg_dumpall_globals_clean => 1,
2395 'DROP ... commands' => { # catch-all for DROP
2396 regexp => qr/^DROP /m,
2397 like => { }, # use more-specific options above
2399 binary_upgrade => 1,
2400 column_inserts => 1,
2404 exclude_dump_test_schema => 1,
2405 exclude_test_table => 1,
2406 exclude_test_table_data => 1,
2409 only_dump_test_schema => 1,
2410 only_dump_test_table => 1,
2411 pg_dumpall_globals => 1,
2415 'GRANT USAGE ON SCHEMA dump_test_second_schema' => {
2417 create_sql => 'GRANT USAGE ON SCHEMA dump_test_second_schema
2420 \QGRANT USAGE ON SCHEMA dump_test_second_schema TO dump_test;\E
2423 binary_upgrade => 1,
2425 clean_if_exists => 1,
2428 exclude_dump_test_schema => 1,
2429 exclude_test_table => 1,
2430 exclude_test_table_data => 1,
2433 section_pre_data => 1,
2436 only_dump_test_schema => 1,
2437 only_dump_test_table => 1,
2438 pg_dumpall_globals => 1,
2439 test_schema_plus_blobs => 1,
2442 'GRANT SELECT ON TABLE test_table' => {
2444 create_sql => 'GRANT SELECT ON TABLE dump_test.test_table
2446 regexp => qr/^GRANT SELECT ON TABLE test_table TO dump_test;/m,
2448 binary_upgrade => 1,
2450 clean_if_exists => 1,
2453 exclude_test_table_data => 1,
2455 only_dump_test_schema => 1,
2456 only_dump_test_table => 1,
2458 section_pre_data => 1,
2459 test_schema_plus_blobs => 1,
2462 exclude_dump_test_schema => 1,
2463 exclude_test_table => 1,
2464 pg_dumpall_globals => 1,
2467 'GRANT SELECT ON TABLE test_third_table' => {
2469 create_sql => 'GRANT SELECT ON
2470 TABLE dump_test_second_schema.test_third_table
2472 regexp => qr/^GRANT SELECT ON TABLE test_third_table TO dump_test;/m,
2474 binary_upgrade => 1,
2476 clean_if_exists => 1,
2479 exclude_dump_test_schema => 1,
2480 exclude_test_table => 1,
2481 exclude_test_table_data => 1,
2484 section_pre_data => 1,
2487 only_dump_test_schema => 1,
2488 only_dump_test_table => 1,
2489 pg_dumpall_globals => 1,
2490 test_schema_plus_blobs => 1,
2493 'GRANT ALL ON SEQUENCE test_third_table_col1_seq' => {
2495 create_sql => 'GRANT ALL ON SEQUENCE
2496 dump_test_second_schema.test_third_table_col1_seq
2499 \QGRANT ALL ON SEQUENCE test_third_table_col1_seq TO dump_test;\E
2502 binary_upgrade => 1,
2504 clean_if_exists => 1,
2507 exclude_dump_test_schema => 1,
2508 exclude_test_table => 1,
2509 exclude_test_table_data => 1,
2512 section_pre_data => 1,
2515 only_dump_test_schema => 1,
2516 only_dump_test_table => 1,
2517 pg_dumpall_globals => 1,
2518 test_schema_plus_blobs => 1,
2521 'GRANT INSERT(col1) ON TABLE test_second_table' => {
2523 create_sql => 'GRANT INSERT (col1) ON TABLE dump_test.test_second_table
2526 \QGRANT INSERT(col1) ON TABLE test_second_table TO dump_test;\E
2529 binary_upgrade => 1,
2531 clean_if_exists => 1,
2534 exclude_test_table => 1,
2535 exclude_test_table_data => 1,
2537 only_dump_test_schema => 1,
2539 section_pre_data => 1,
2540 test_schema_plus_blobs => 1,
2543 exclude_dump_test_schema => 1,
2544 only_dump_test_table => 1,
2545 pg_dumpall_globals => 1,
2548 'GRANT EXECUTE ON FUNCTION pg_sleep() TO dump_test' => {
2550 create_sql => 'GRANT EXECUTE ON FUNCTION pg_sleep(float8)
2553 \QGRANT ALL ON FUNCTION pg_sleep(double precision) TO dump_test;\E
2556 binary_upgrade => 1,
2558 clean_if_exists => 1,
2561 exclude_dump_test_schema => 1,
2562 exclude_test_table => 1,
2563 exclude_test_table_data => 1,
2566 section_pre_data => 1,
2569 only_dump_test_schema => 1,
2570 only_dump_test_table => 1,
2571 test_schema_plus_blobs => 1,
2574 'GRANT SELECT (proname ...) ON TABLE pg_proc TO public' => {
2576 create_sql => 'GRANT SELECT (
2608 ) ON TABLE pg_proc TO public;',
2610 \QGRANT SELECT(tableoid) ON TABLE pg_proc TO PUBLIC;\E\n.*
2611 \QGRANT SELECT(oid) ON TABLE pg_proc TO PUBLIC;\E\n.*
2612 \QGRANT SELECT(proname) ON TABLE pg_proc TO PUBLIC;\E\n.*
2613 \QGRANT SELECT(pronamespace) ON TABLE pg_proc TO PUBLIC;\E\n.*
2614 \QGRANT SELECT(proowner) ON TABLE pg_proc TO PUBLIC;\E\n.*
2615 \QGRANT SELECT(prolang) ON TABLE pg_proc TO PUBLIC;\E\n.*
2616 \QGRANT SELECT(procost) ON TABLE pg_proc TO PUBLIC;\E\n.*
2617 \QGRANT SELECT(prorows) ON TABLE pg_proc TO PUBLIC;\E\n.*
2618 \QGRANT SELECT(provariadic) ON TABLE pg_proc TO PUBLIC;\E\n.*
2619 \QGRANT SELECT(protransform) ON TABLE pg_proc TO PUBLIC;\E\n.*
2620 \QGRANT SELECT(proisagg) ON TABLE pg_proc TO PUBLIC;\E\n.*
2621 \QGRANT SELECT(proiswindow) ON TABLE pg_proc TO PUBLIC;\E\n.*
2622 \QGRANT SELECT(prosecdef) ON TABLE pg_proc TO PUBLIC;\E\n.*
2623 \QGRANT SELECT(proleakproof) ON TABLE pg_proc TO PUBLIC;\E\n.*
2624 \QGRANT SELECT(proisstrict) ON TABLE pg_proc TO PUBLIC;\E\n.*
2625 \QGRANT SELECT(proretset) ON TABLE pg_proc TO PUBLIC;\E\n.*
2626 \QGRANT SELECT(provolatile) ON TABLE pg_proc TO PUBLIC;\E\n.*
2627 \QGRANT SELECT(proparallel) ON TABLE pg_proc TO PUBLIC;\E\n.*
2628 \QGRANT SELECT(pronargs) ON TABLE pg_proc TO PUBLIC;\E\n.*
2629 \QGRANT SELECT(pronargdefaults) ON TABLE pg_proc TO PUBLIC;\E\n.*
2630 \QGRANT SELECT(prorettype) ON TABLE pg_proc TO PUBLIC;\E\n.*
2631 \QGRANT SELECT(proargtypes) ON TABLE pg_proc TO PUBLIC;\E\n.*
2632 \QGRANT SELECT(proallargtypes) ON TABLE pg_proc TO PUBLIC;\E\n.*
2633 \QGRANT SELECT(proargmodes) ON TABLE pg_proc TO PUBLIC;\E\n.*
2634 \QGRANT SELECT(proargnames) ON TABLE pg_proc TO PUBLIC;\E\n.*
2635 \QGRANT SELECT(proargdefaults) ON TABLE pg_proc TO PUBLIC;\E\n.*
2636 \QGRANT SELECT(protrftypes) ON TABLE pg_proc TO PUBLIC;\E\n.*
2637 \QGRANT SELECT(prosrc) ON TABLE pg_proc TO PUBLIC;\E\n.*
2638 \QGRANT SELECT(probin) ON TABLE pg_proc TO PUBLIC;\E\n.*
2639 \QGRANT SELECT(proconfig) ON TABLE pg_proc TO PUBLIC;\E\n.*
2640 \QGRANT SELECT(proacl) ON TABLE pg_proc TO PUBLIC;\E/xms,
2642 binary_upgrade => 1,
2644 clean_if_exists => 1,
2647 exclude_dump_test_schema => 1,
2648 exclude_test_table => 1,
2649 exclude_test_table_data => 1,
2652 section_pre_data => 1,
2655 only_dump_test_schema => 1,
2656 only_dump_test_table => 1,
2657 test_schema_plus_blobs => 1,
2660 'GRANT commands' => { # catch-all for GRANT commands
2661 regexp => qr/^GRANT /m,
2662 like => { }, # use more-specific options above
2664 column_inserts => 1,
2670 'REFRESH MATERIALIZED VIEW matview' => {
2671 regexp => qr/^REFRESH MATERIALIZED VIEW matview;/m,
2674 clean_if_exists => 1,
2677 exclude_test_table => 1,
2678 exclude_test_table_data => 1,
2681 only_dump_test_schema => 1,
2682 test_schema_plus_blobs => 1,
2683 section_post_data => 1,
2686 binary_upgrade => 1,
2687 exclude_dump_test_schema => 1,
2688 only_dump_test_table => 1,
2689 pg_dumpall_globals => 1,
2691 section_pre_data => 1,
2694 'REFRESH MATERIALIZED VIEW matview_second' => {
2696 \QREFRESH MATERIALIZED VIEW matview;\E
2698 \QREFRESH MATERIALIZED VIEW matview_second;\E
2702 clean_if_exists => 1,
2705 exclude_test_table => 1,
2706 exclude_test_table_data => 1,
2709 only_dump_test_schema => 1,
2710 test_schema_plus_blobs => 1,
2711 section_post_data => 1,
2714 binary_upgrade => 1,
2715 exclude_dump_test_schema => 1,
2716 only_dump_test_table => 1,
2717 pg_dumpall_globals => 1,
2719 section_pre_data => 1,
2722 'REVOKE EXECUTE ON FUNCTION pg_sleep() FROM public' => {
2724 create_sql => 'REVOKE EXECUTE ON FUNCTION pg_sleep(float8)
2727 \QREVOKE ALL ON FUNCTION pg_sleep(double precision) FROM PUBLIC;\E
2730 binary_upgrade => 1,
2732 clean_if_exists => 1,
2735 exclude_dump_test_schema => 1,
2736 exclude_test_table => 1,
2737 exclude_test_table_data => 1,
2740 section_pre_data => 1,
2743 only_dump_test_schema => 1,
2744 only_dump_test_table => 1,
2745 test_schema_plus_blobs => 1,
2748 'REVOKE SELECT ON TABLE pg_proc FROM public' => {
2750 create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;',
2751 regexp => qr/^REVOKE SELECT ON TABLE pg_proc FROM PUBLIC;/m,
2753 binary_upgrade => 1,
2755 clean_if_exists => 1,
2758 exclude_dump_test_schema => 1,
2759 exclude_test_table => 1,
2760 exclude_test_table_data => 1,
2763 section_pre_data => 1,
2766 only_dump_test_schema => 1,
2767 only_dump_test_table => 1,
2768 test_schema_plus_blobs => 1,
2771 'REVOKE CREATE ON SCHEMA public FROM public' => {
2773 create_sql => 'REVOKE CREATE ON SCHEMA public FROM public;',
2775 \QREVOKE ALL ON SCHEMA public FROM PUBLIC;\E
2776 \n\QGRANT USAGE ON SCHEMA public TO PUBLIC;\E
2779 binary_upgrade => 1,
2781 clean_if_exists => 1,
2784 exclude_dump_test_schema => 1,
2785 exclude_test_table => 1,
2786 exclude_test_table_data => 1,
2789 section_pre_data => 1,
2792 only_dump_test_schema => 1,
2793 only_dump_test_table => 1,
2794 test_schema_plus_blobs => 1,
2797 'REVOKE USAGE ON LANGUAGE plpgsql FROM public' => {
2799 create_sql => 'REVOKE USAGE ON LANGUAGE plpgsql FROM public;',
2800 regexp => qr/^REVOKE ALL ON LANGUAGE plpgsql FROM PUBLIC;/m,
2802 binary_upgrade => 1,
2804 clean_if_exists => 1,
2807 exclude_dump_test_schema => 1,
2808 exclude_test_table => 1,
2809 exclude_test_table_data => 1,
2812 section_pre_data => 1,
2815 only_dump_test_schema => 1,
2816 only_dump_test_table => 1,
2817 test_schema_plus_blobs => 1,
2820 'REVOKE commands' => { # catch-all for REVOKE commands
2821 regexp => qr/^REVOKE /m,
2822 like => { }, # use more-specific options above
2824 column_inserts => 1,
2827 pg_dumpall_globals => 1,
2832 #########################################
2833 # Create a PG instance to test actually dumping from
2835 my $node = get_new_node('main');
2839 my $port = $node->port;
2841 # Start with 2 because of command_exit_is() tests below
2844 foreach my $run (sort keys %pgdump_runs) {
2845 my $test_key = $run;
2847 # Each run of pg_dump is a test itself
2850 # If there is a restore cmd, that's another test
2851 if ($pgdump_runs{$run}->{restore_cmd}) {
2855 if ($pgdump_runs{$run}->{test_key}) {
2856 $test_key = $pgdump_runs{$run}->{test_key};
2859 # Then count all the tests run against each run
2860 foreach my $test (sort keys %tests) {
2861 if ($tests{$test}->{like}->{$test_key}) {
2865 if ($tests{$test}->{unlike}->{$test_key}) {
2870 plan tests => $num_tests;
2872 #########################################
2873 # Set up schemas, tables, etc, to be dumped.
2875 # Build up the create statements
2876 my $create_sql = '';
2880 if ($tests{$a}->{create_order} and $tests{$b}->{create_order}) {
2881 $tests{$a}->{create_order} <=> $tests{$b}->{create_order};
2882 } elsif ($tests{$a}->{create_order}) {
2884 } elsif ($tests{$b}->{create_order}) {
2890 if ($tests{$test}->{create_sql}) {
2891 $create_sql .= $tests{$test}->{create_sql};
2895 # Send the combined set of commands to psql
2896 $node->safe_psql('postgres', $create_sql);
2898 #########################################
2899 # Test connecting to a non-existent database
2901 command_exit_is([ 'pg_dump', '-p', "$port", 'qqq' ],
2902 1, 'pg_dump: [archiver (db)] connection to database "qqq" failed: FATAL: database "qqq" does not exist');
2904 command_exit_is([ 'pg_dump', '-p', "$port", '--role=dump_test' ],
2905 1, 'pg_dump: [archiver (db)] query failed: ERROR: permission denied for');
2907 #########################################
2910 foreach my $run (sort keys %pgdump_runs) {
2912 my $test_key = $run;
2914 $node->command_ok(\@{ $pgdump_runs{$run}->{dump_cmd} }, "$run: pg_dump runs");
2916 if ($pgdump_runs{$run}->{restore_cmd}) {
2917 $node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} }, "$run: pg_restore runs");
2920 if ($pgdump_runs{$run}->{test_key}) {
2921 $test_key = $pgdump_runs{$run}->{test_key};
2924 my $output_file = slurp_file("$tempdir/${run}.sql");
2926 #########################################
2927 # Run all tests where this run is included
2928 # as either a 'like' or 'unlike' test.
2930 foreach my $test (sort keys %tests) {
2931 if ($tests{$test}->{like}->{$test_key}) {
2932 like($output_file, $tests{$test}->{regexp}, "$run: dumps $test");
2935 if ($tests{$test}->{unlike}->{$test_key}) {
2936 unlike($output_file, $tests{$test}->{regexp}, "$run: does not dump $test");
2941 #########################################
2942 # Stop the database instance, which will be removed at the end of the tests.
2944 $node->stop('fast');