]> granicus.if.org Git - postgresql/blob - src/bin/pg_dump/t/002_pg_dump.pl
3c6859912f34708eaadd9efefbff5f044936d72b
[postgresql] / src / bin / pg_dump / t / 002_pg_dump.pl
1 use strict;
2 use warnings;
3
4 use Config;
5 use PostgresNode;
6 use TestLib;
7 use Test::More;
8
9 my $tempdir       = TestLib::tempdir;
10 my $tempdir_short = TestLib::tempdir_short;
11
12 ###############################################################
13 # Definition of the pg_dump runs to make.
14 #
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
17 # from a given run.
18 #
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.
21 #
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.
27 #
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.
33 #
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.
37
38 my %pgdump_runs = (
39         binary_upgrade => {
40                 dump_cmd => [
41                         'pg_dump',
42                         '-f', "$tempdir/binary_upgrade.sql",
43                         '--schema-only',
44                         '--binary-upgrade',
45                         '-d', 'postgres', # alternative way to specify database
46                 ],
47         },
48         clean => {
49                 dump_cmd => [
50                         'pg_dump',
51                         '-f', "$tempdir/clean.sql",
52                         '-c',
53                         '-d', 'postgres', # alternative way to specify database
54                 ],
55         },
56         clean_if_exists => {
57                 dump_cmd => [
58                         'pg_dump',
59                         '-f', "$tempdir/clean_if_exists.sql",
60                         '-c',
61                         '--if-exists',
62                         '-E', 'UTF8', # no-op, just tests that option is accepted
63                         'postgres',
64                 ],
65         },
66         column_inserts => {
67                 dump_cmd => [
68                         'pg_dump',
69                         '-f', "$tempdir/column_inserts.sql",
70                         '-a',
71                         '--column-inserts',
72                         'postgres',
73                 ],
74         },
75         createdb => {
76                 dump_cmd => [
77                         'pg_dump',
78                         '-f', "$tempdir/createdb.sql",
79                         '-C',
80                         '-R', # no-op, just for testing
81                         'postgres',
82                 ],
83         },
84         data_only => {
85                 dump_cmd => [
86                         'pg_dump',
87                         '-f', "$tempdir/data_only.sql",
88                         '-a',
89                         '-v', # no-op, just make sure it works
90                         'postgres',
91                 ],
92         },
93         defaults => {
94                 dump_cmd => [
95                         'pg_dump',
96                         '-f', "$tempdir/defaults.sql",
97                         'postgres',
98                 ],
99         },
100         defaults_custom_format => {
101                 test_key => 'defaults',
102                 dump_cmd => [
103                         'pg_dump',
104                         '-Fc',
105                         '-Z6',
106                         '-f', "$tempdir/defaults_custom_format.dump",
107                         'postgres',
108                 ],
109                 restore_cmd => [
110                         'pg_restore',
111                         '-f', "$tempdir/defaults_custom_format.sql",
112                         "$tempdir/defaults_custom_format.dump",
113                 ],
114         },
115         defaults_dir_format => {
116                 test_key => 'defaults',
117                 dump_cmd => [
118                         'pg_dump',
119                         '-Fd',
120                         '-f', "$tempdir/defaults_dir_format",
121                         'postgres',
122                 ],
123                 restore_cmd => [
124                         'pg_restore',
125                         '-f', "$tempdir/defaults_dir_format.sql",
126                         "$tempdir/defaults_dir_format",
127                 ],
128         },
129         defaults_parallel => {
130                 test_key => 'defaults',
131                 dump_cmd => [
132                         'pg_dump',
133                         '-Fd',
134                         '-j2',
135                         '-f', "$tempdir/defaults_parallel",
136                         'postgres',
137                 ],
138                 restore_cmd => [
139                         'pg_restore',
140                         '-f', "$tempdir/defaults_parallel.sql",
141                         "$tempdir/defaults_parallel",
142                 ],
143         },
144         defaults_tar_format => {
145                 test_key => 'defaults',
146                 dump_cmd => [
147                         'pg_dump',
148                         '-Ft',
149                         '-f', "$tempdir/defaults_tar_format.tar",
150                         'postgres',
151                 ],
152                 restore_cmd => [
153                         'pg_restore',
154                         '-f', "$tempdir/defaults_tar_format.sql",
155                         "$tempdir/defaults_tar_format.tar",
156                 ],
157         },
158         exclude_dump_test_schema => {
159                 dump_cmd => [
160                         'pg_dump',
161                         '-f', "$tempdir/exclude_dump_test_schema.sql",
162                         '-N', 'dump_test',
163                         'postgres',
164                 ],
165         },
166         exclude_test_table => {
167                 dump_cmd => [
168                         'pg_dump',
169                         '-f', "$tempdir/exclude_test_table.sql",
170                         '-T', 'dump_test.test_table',
171                         'postgres',
172                 ],
173         },
174         exclude_test_table_data => {
175                 dump_cmd => [
176                         'pg_dump',
177                         '-f', "$tempdir/exclude_test_table_data.sql",
178                         '--exclude-table-data=dump_test.test_table',
179                         'postgres',
180                 ],
181         },
182         pg_dumpall_globals => {
183                 dump_cmd => [
184                         'pg_dumpall',
185                         '-f', "$tempdir/pg_dumpall_globals.sql",
186                         '-g',
187                 ],
188         },
189         pg_dumpall_globals_clean => {
190                 dump_cmd => [
191                         'pg_dumpall',
192                         '-f', "$tempdir/pg_dumpall_globals_clean.sql",
193                         '-g',
194                         '-c',
195                 ],
196         },
197         no_privs => {
198                 dump_cmd => [
199                         'pg_dump',
200                         '-f', "$tempdir/no_privs.sql",
201                         '-x',
202                         'postgres',
203                 ],
204         },
205         no_owner => {
206                 dump_cmd => [
207                         'pg_dump',
208                         '-f', "$tempdir/no_owner.sql",
209                         '-O',
210                         'postgres',
211                 ],
212         },
213         only_dump_test_schema => {
214                 dump_cmd => [
215                         'pg_dump',
216                         '-f', "$tempdir/only_dump_test_schema.sql",
217                         '-n', 'dump_test',
218                         'postgres',
219                 ],
220         },
221         only_dump_test_table => {
222                 dump_cmd => [
223                         'pg_dump',
224                         '-f', "$tempdir/only_dump_test_table.sql",
225                         '-t', 'dump_test.test_table',
226                         '--lock-wait-timeout=1000000',
227                         'postgres',
228                 ],
229         },
230         role => {
231                 dump_cmd => [
232                         'pg_dump',
233                         '-f', "$tempdir/role.sql",
234                         '--role=dump_test',
235                         '--schema=dump_test_second_schema',
236                         'postgres',
237                 ],
238         },
239         schema_only => {
240                 dump_cmd => [
241                         'pg_dump',
242                         '-f', "$tempdir/schema_only.sql",
243                         '-s',
244                         'postgres',
245                 ],
246         },
247         section_pre_data => {
248                 dump_cmd => [
249                         'pg_dump',
250                         '-f', "$tempdir/section_pre_data.sql",
251                         '--section=pre-data',
252                         'postgres',
253                 ],
254         },
255         section_data => {
256                 dump_cmd => [
257                         'pg_dump',
258                         '-f', "$tempdir/section_data.sql",
259                         '--section=data',
260                         'postgres',
261                 ],
262         },
263         section_post_data => {
264                 dump_cmd => [
265                         'pg_dump',
266                         '-f', "$tempdir/section_post_data.sql",
267                         '--section=post-data',
268                         'postgres',
269                 ],
270         },
271         test_schema_plus_blobs => {
272                 dump_cmd => [
273                         'pg_dump',
274                         '-f', "$tempdir/test_schema_plus_blobs.sql",
275                         '-n', 'dump_test',
276                         '-b',
277                         'postgres',
278                 ],
279         },
280 );
281
282 ###############################################################
283 # Definition of the tests to run.
284 #
285 # Each test is defined using the log message that will be used.
286 #
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.
292 #
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.
297 #
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.
305 #
306 # Note that it makes no sense for the same run to ever be listed
307 # in both 'like' and 'unlike' categories.
308 #
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.
314 #
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.
318
319 my %tests = (
320         'ALTER DEFAULT PRIVILEGES FOR ROLE dump_test' => {
321                 create_order => 14,
322                 create_sql => 'ALTER DEFAULT PRIVILEGES
323                                            FOR ROLE dump_test IN SCHEMA dump_test
324                                            GRANT SELECT ON TABLES TO dump_test;',
325                 regexp => qr/^
326                         \QALTER DEFAULT PRIVILEGES \E
327                         \QFOR ROLE dump_test IN SCHEMA dump_test \E
328                         \QGRANT SELECT ON TABLES  TO dump_test;\E
329                         /xm,
330                 like => {
331                         binary_upgrade => 1,
332                         clean => 1,
333                         clean_if_exists => 1,
334                         createdb => 1,
335                         defaults => 1,
336                         exclude_test_table => 1,
337                         exclude_test_table_data => 1,
338                         only_dump_test_schema => 1,
339                         schema_only => 1,
340                         section_post_data => 1,
341                         test_schema_plus_blobs => 1,
342                 },
343                 unlike => {
344                         exclude_dump_test_schema => 1,
345                         no_privs => 1,
346                         only_dump_test_table => 1,
347                         pg_dumpall_globals => 1,
348                         pg_dumpall_globals_clean => 1,
349                         section_pre_data => 1,
350                         section_data => 1,
351                 },
352         },
353         'ALTER ROLE dump_test' => {
354                 regexp => qr/^
355                         \QALTER ROLE dump_test WITH \E
356                         \QNOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB NOLOGIN \E
357                         \QNOREPLICATION NOBYPASSRLS;\E
358                         /xm,
359                 like => {
360                         pg_dumpall_globals => 1,
361                         pg_dumpall_globals_clean => 1,
362                 },
363                 unlike => {
364                         binary_upgrade => 1,
365                         clean => 1,
366                         clean_if_exists => 1,
367                         createdb => 1,
368                         defaults => 1,
369                         exclude_dump_test_schema => 1,
370                         exclude_test_table => 1,
371                         exclude_test_table_data => 1,
372                         no_privs => 1,
373                         no_owner => 1,
374                         only_dump_test_schema => 1,
375                         only_dump_test_table => 1,
376                         schema_only => 1,
377                         section_pre_data => 1,
378                         section_post_data => 1,
379                         test_schema_plus_blobs => 1,
380                 },
381         },
382         'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => {
383                 regexp => qr/^
384                         \QALTER FUNCTION dump_test.pltestlang_call_handler() \E
385                         \QOWNER TO \E
386                         .*;/xm,
387                 like => {
388                         binary_upgrade => 1,
389                         clean => 1,
390                         clean_if_exists => 1,
391                         createdb => 1,
392                         defaults => 1,
393                         exclude_test_table => 1,
394                         exclude_test_table_data => 1,
395                         no_privs => 1,
396                         only_dump_test_schema => 1,
397                         schema_only => 1,
398                         section_pre_data => 1,
399                         test_schema_plus_blobs => 1,
400                 },
401                 unlike => {
402                         exclude_dump_test_schema => 1,
403                         only_dump_test_table => 1,
404                 },
405         },
406         'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => {
407                 regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .*;/m,
408                 like => {
409                         binary_upgrade => 1,
410                         clean => 1,
411                         clean_if_exists => 1,
412                         createdb => 1,
413                         defaults => 1,
414                         exclude_dump_test_schema => 1,
415                         exclude_test_table => 1,
416                         exclude_test_table_data => 1,
417                         no_privs => 1,
418                         schema_only => 1,
419                         section_pre_data => 1,
420                 },
421                 unlike => {
422                         only_dump_test_schema => 1,
423                         only_dump_test_table => 1,
424                         test_schema_plus_blobs => 1,
425                 },
426         },
427         'ALTER SCHEMA dump_test OWNER TO' => {
428                 regexp => qr/^ALTER SCHEMA dump_test OWNER TO .*;/m,
429                 like => {
430                         binary_upgrade => 1,
431                         clean => 1,
432                         clean_if_exists => 1,
433                         createdb => 1,
434                         defaults => 1,
435                         exclude_test_table => 1,
436                         exclude_test_table_data => 1,
437                         no_privs => 1,
438                         only_dump_test_schema => 1,
439                         schema_only => 1,
440                         section_pre_data => 1,
441                         test_schema_plus_blobs => 1,
442                 },
443                 unlike => {
444                         exclude_dump_test_schema => 1,
445                         only_dump_test_table => 1,
446                 },
447         },
448         'ALTER SCHEMA dump_test_second_schema OWNER TO' => {
449                 regexp => qr/^ALTER SCHEMA dump_test_second_schema OWNER TO .*;/m,
450                 like => {
451                         binary_upgrade => 1,
452                         clean => 1,
453                         clean_if_exists => 1,
454                         createdb => 1,
455                         defaults => 1,
456                         exclude_dump_test_schema => 1,
457                         exclude_test_table => 1,
458                         exclude_test_table_data => 1,
459                         no_privs => 1,
460                         schema_only => 1,
461                         section_pre_data => 1,
462                 },
463                 unlike => {
464                         only_dump_test_schema => 1,
465                         only_dump_test_table => 1,
466                         test_schema_plus_blobs => 1,
467                 },
468         },
469         'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => {
470                 regexp => qr/^
471                         \QALTER TABLE ONLY test_table\E \n^\s+
472                         \QADD CONSTRAINT test_table_pkey PRIMARY KEY (col1);\E
473                         /xm,
474                 like => {
475                         binary_upgrade => 1,
476                         clean => 1,
477                         clean_if_exists => 1,
478                         createdb => 1,
479                         defaults => 1,
480                         exclude_test_table_data => 1,
481                         no_privs => 1,
482                         only_dump_test_schema => 1,
483                         only_dump_test_table => 1,
484                         schema_only => 1,
485                         section_post_data => 1,
486                         test_schema_plus_blobs => 1,
487                 },
488                 unlike => {
489                         exclude_dump_test_schema => 1,
490                         exclude_test_table => 1,
491                         section_pre_data => 1,
492                         section_data => 1,
493                 },
494         },
495         'ALTER TABLE test_table OWNER TO' => {
496                 regexp => qr/^ALTER TABLE test_table OWNER TO .*;/m,
497                 like => {
498                         binary_upgrade => 1,
499                         clean => 1,
500                         clean_if_exists => 1,
501                         createdb => 1,
502                         defaults => 1,
503                         exclude_test_table_data => 1,
504                         no_privs => 1,
505                         only_dump_test_schema => 1,
506                         only_dump_test_table => 1,
507                         schema_only => 1,
508                         section_pre_data => 1,
509                         test_schema_plus_blobs => 1,
510                 },
511                 unlike => {
512                         exclude_dump_test_schema => 1,
513                         exclude_test_table => 1,
514                 },
515         },
516         'ALTER TABLE test_table ENABLE ROW LEVEL SECURITY' => {
517                 create_order => 23,
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,
521                 like => {
522                         binary_upgrade => 1,
523                         clean => 1,
524                         clean_if_exists => 1,
525                         createdb => 1,
526                         defaults => 1,
527                         exclude_test_table_data => 1,
528                         no_privs => 1,
529                         only_dump_test_schema => 1,
530                         only_dump_test_table => 1,
531                         schema_only => 1,
532                         section_post_data => 1,
533                         test_schema_plus_blobs => 1,
534                 },
535                 unlike => {
536                         section_pre_data => 1,
537                         exclude_dump_test_schema => 1,
538                         exclude_test_table => 1,
539                 },
540         },
541         'ALTER TABLE test_second_table OWNER TO' => {
542                 regexp => qr/^ALTER TABLE test_second_table OWNER TO .*;/m,
543                 like => {
544                         binary_upgrade => 1,
545                         clean => 1,
546                         clean_if_exists => 1,
547                         createdb => 1,
548                         defaults => 1,
549                         exclude_test_table => 1,
550                         exclude_test_table_data => 1,
551                         no_privs => 1,
552                         only_dump_test_schema => 1,
553                         schema_only => 1,
554                         section_pre_data => 1,
555                         test_schema_plus_blobs => 1,
556                 },
557                 unlike => {
558                         exclude_dump_test_schema => 1,
559                         only_dump_test_table => 1,
560                 },
561         },
562         'ALTER TABLE test_third_table OWNER TO' => {
563                 regexp => qr/^ALTER TABLE test_third_table OWNER TO .*;/m,
564                 like => {
565                         binary_upgrade => 1,
566                         clean => 1,
567                         clean_if_exists => 1,
568                         createdb => 1,
569                         defaults => 1,
570                         exclude_dump_test_schema => 1,
571                         exclude_test_table => 1,
572                         exclude_test_table_data => 1,
573                         no_privs => 1,
574                         schema_only => 1,
575                         section_pre_data => 1,
576                 },
577                 unlike => {
578                         only_dump_test_schema => 1,
579                         only_dump_test_table => 1,
580                         test_schema_plus_blobs => 1,
581                 },
582         },
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
587                 unlike => {
588                         column_inserts => 1,
589                         data_only => 1,
590                         section_data => 1,
591                 },
592         },
593         # catch-all for ALTER TABLE ...
594         'ALTER TABLE ... commands' => {
595                 regexp => qr/^ALTER TABLE .*;/m,
596                 like => { }, # use more-specific options above
597                 unlike => {
598                         column_inserts => 1,
599                         data_only => 1,
600                         pg_dumpall_globals => 1,
601                         pg_dumpall_globals_clean => 1,
602                         section_data => 1,
603                 },
604         },
605         # catch-all for ALTER ... OWNER
606         'ALTER ... OWNER commands' => {
607                 regexp => qr/^ALTER .* OWNER TO .*;/m,
608                 like => { }, # use more-specific options above
609                 unlike => {
610                         no_owner => 1,
611                         pg_dumpall_globals => 1,
612                         pg_dumpall_globals_clean => 1,
613                         section_post_data => 1,
614                 },
615         },
616 #       'BLOB load (contents are of test_table)' => {
617 #               create_order => 14,
618 #               create_sql =>
619 #                   "\\o '$tempdir/large_object_test.sql'\n"
620 #                 . "table dump_test.test_table;\n"
621 #                 . "\\o\n"
622 #                 . "\\lo_import '$tempdir/large_object_test.sql'\n",
623 #               regexp => qr/^
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
628 #                       /xm,
629 #               like => {
630 #                       clean => 1,
631 #                       clean_if_exists => 1,
632 #                       createdb => 1,
633 #                       defaults => 1,
634 #                       exclude_dump_test_schema => 1,
635 #                       exclude_test_table => 1,
636 #                       exclude_test_table_data => 1,
637 #                       no_privs => 1,
638 #                       section_data => 1,
639 #                       test_schema_plus_blobs => 1,
640 #               },
641 #               unlike => {
642 #                       binary_upgrade => 1,
643 #                       only_dump_test_schema => 1,
644 #                       only_dump_test_table => 1,
645 #                       pg_dumpall_globals => 1,
646 #                       schema_only => 1,
647 #                       section_post_data => 1,
648 #               },
649 #       },
650         'COMMENT ON DATABASE postgres' => {
651                 regexp => qr/^COMMENT ON DATABASE postgres IS .*;/m,
652                 like => {
653                         binary_upgrade => 1,
654                         clean => 1,
655                         clean_if_exists => 1,
656                         createdb => 1,
657                         defaults => 1,
658                         exclude_dump_test_schema => 1,
659                         exclude_test_table => 1,
660                         exclude_test_table_data => 1,
661                         no_privs => 1,
662                         no_owner => 1,
663                         schema_only => 1,
664                         section_pre_data => 1,
665                 },
666                 unlike => {
667                         only_dump_test_schema => 1,
668                         only_dump_test_table => 1,
669                 },
670         },
671         'COMMENT ON EXTENSION plpgsql' => {
672                 regexp => qr/^COMMENT ON EXTENSION plpgsql IS .*;/m,
673                 like => {
674                         clean => 1,
675                         clean_if_exists => 1,
676                         createdb => 1,
677                         defaults => 1,
678                         exclude_dump_test_schema => 1,
679                         exclude_test_table => 1,
680                         exclude_test_table_data => 1,
681                         no_privs => 1,
682                         no_owner => 1,
683                         schema_only => 1,
684                         section_pre_data => 1,
685                 },
686                 unlike => {
687                         binary_upgrade => 1,
688                         only_dump_test_schema => 1,
689                         only_dump_test_table => 1,
690                 },
691         },
692         'COMMENT ON TABLE dump_test.test_table' => {
693                 create_order => 36,
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,
697                 like => {
698                         binary_upgrade => 1,
699                         clean => 1,
700                         clean_if_exists => 1,
701                         createdb => 1,
702                         defaults => 1,
703                         exclude_test_table_data => 1,
704                         no_privs => 1,
705                         no_owner => 1,
706                         only_dump_test_schema => 1,
707                         only_dump_test_table => 1,
708                         schema_only => 1,
709                         section_pre_data => 1,
710                 },
711                 unlike => {
712                         exclude_dump_test_schema => 1,
713                         exclude_test_table => 1,
714                 },
715         },
716         'COMMENT ON COLUMN dump_test.test_table.col1' => {
717                 create_order => 36,
718                 create_sql => 'COMMENT ON COLUMN dump_test.test_table.col1
719                                            IS \'comment on column\';',
720                 regexp => qr/^
721                         \QCOMMENT ON COLUMN test_table.col1 IS 'comment on column';\E
722                         /xm,
723                 like => {
724                         binary_upgrade => 1,
725                         clean => 1,
726                         clean_if_exists => 1,
727                         createdb => 1,
728                         defaults => 1,
729                         exclude_test_table_data => 1,
730                         no_privs => 1,
731                         no_owner => 1,
732                         only_dump_test_schema => 1,
733                         only_dump_test_table => 1,
734                         schema_only => 1,
735                         section_pre_data => 1,
736                 },
737                 unlike => {
738                         exclude_dump_test_schema => 1,
739                         exclude_test_table => 1,
740                 },
741         },
742         'COMMENT ON COLUMN dump_test.composite.f1' => {
743                 create_order => 44,
744                 create_sql => 'COMMENT ON COLUMN dump_test.composite.f1
745                                            IS \'comment on column of type\';',
746                 regexp => qr/^
747                         \QCOMMENT ON COLUMN composite.f1 IS 'comment on column of type';\E
748                         /xm,
749                 like => {
750                         binary_upgrade => 1,
751                         clean => 1,
752                         clean_if_exists => 1,
753                         createdb => 1,
754                         defaults => 1,
755                         exclude_test_table => 1,
756                         exclude_test_table_data => 1,
757                         no_privs => 1,
758                         no_owner => 1,
759                         only_dump_test_schema => 1,
760                         schema_only => 1,
761                         section_pre_data => 1,
762                 },
763                 unlike => {
764                         exclude_dump_test_schema => 1,
765                         only_dump_test_table => 1,
766                 },
767         },
768         # catch-all for COMMENTs
769         'COMMENT commands' => {
770                 regexp => qr/^COMMENT ON /m,
771                 like => { }, # use more-specific options above
772                 unlike => {
773                         column_inserts => 1,
774                         data_only => 1,
775                         pg_dumpall_globals => 1,
776                         pg_dumpall_globals_clean => 1,
777                         section_data => 1,
778                         section_post_data => 1,
779                 },
780         },
781         'COPY test_table' => {
782                 create_order => 4,
783                 create_sql =>
784                     'INSERT INTO dump_test.test_table (col1) '
785                   . 'SELECT generate_series FROM generate_series(1,9);',
786                 regexp => qr/^
787                         \QCOPY test_table (col1) FROM stdin;\E
788                         \n(?:\d\n){9}\\\.\n
789                         /xm,
790                 like => {
791                         clean => 1,
792                         clean_if_exists => 1,
793                         createdb => 1,
794                         data_only => 1,
795                         defaults => 1,
796                         no_privs => 1,
797                         no_owner => 1,
798                         only_dump_test_schema => 1,
799                         only_dump_test_table => 1,
800                         section_data => 1,
801                         test_schema_plus_blobs => 1,
802                 },
803                 unlike => {
804                         exclude_dump_test_schema => 1,
805                         exclude_test_table => 1,
806                         exclude_test_table_data => 1,
807                 },
808         },
809         'COPY fk_reference_test_table' => {
810                 create_order => 22,
811                 create_sql =>
812                     'INSERT INTO dump_test.fk_reference_test_table (col1) '
813                   . 'SELECT generate_series FROM generate_series(1,5);',
814                 regexp => qr/^
815                         \QCOPY fk_reference_test_table (col1) FROM stdin;\E
816                         \n(?:\d\n){5}\\\.\n
817                         /xm,
818                 like => {
819                         clean => 1,
820                         clean_if_exists => 1,
821                         createdb => 1,
822                         data_only => 1,
823                         defaults => 1,
824                         exclude_test_table => 1,
825                         exclude_test_table_data => 1,
826                         no_privs => 1,
827                         no_owner => 1,
828                         only_dump_test_schema => 1,
829                         section_data => 1,
830                         test_schema_plus_blobs => 1,
831                 },
832                 unlike => {
833                         exclude_dump_test_schema => 1,
834                         only_dump_test_table => 1,
835                 },
836         },
837         'COPY fk_reference_test_table second' => {
838                 regexp => qr/^
839                         \QCOPY test_table (col1) FROM stdin;\E
840                         \n(?:\d\n){9}\\\.\n.*
841                         \QCOPY fk_reference_test_table (col1) FROM stdin;\E
842                         \n(?:\d\n){5}\\\.\n
843                         /xms,
844                 like => {
845                         data_only => 1,
846                 },
847                 unlike => {
848                         exclude_dump_test_schema => 1,
849                         exclude_test_table => 1,
850                         exclude_test_table_data => 1,
851                 },
852         },
853         'COPY test_second_table' => {
854                 create_order => 7,
855                 create_sql =>
856                     'INSERT INTO dump_test.test_second_table (col1, col2) '
857                   . 'SELECT generate_series, generate_series::text '
858                   . 'FROM generate_series(1,9);',
859                 regexp => qr/^
860                         \QCOPY test_second_table (col1, col2) FROM stdin;\E
861                         \n(?:\d\t\d\n){9}\\\.\n
862                         /xm,
863                 like => {
864                         clean => 1,
865                         clean_if_exists => 1,
866                         createdb => 1,
867                         data_only => 1,
868                         defaults => 1,
869                         exclude_test_table => 1,
870                         exclude_test_table_data => 1,
871                         no_privs => 1,
872                         no_owner => 1,
873                         only_dump_test_schema => 1,
874                         section_data => 1,
875                         test_schema_plus_blobs => 1,
876                 },
877                 unlike => {
878                         exclude_dump_test_schema => 1,
879                         only_dump_test_table => 1,
880                 },
881         },
882         'COPY test_third_table' => {
883                 create_order => 12,
884                 create_sql =>
885                         'INSERT INTO dump_test_second_schema.test_third_table (col1) '
886                   . 'SELECT generate_series FROM generate_series(1,9);',
887                 regexp => qr/^
888                         \QCOPY test_third_table (col1) FROM stdin;\E
889                         \n(?:\d\n){9}\\\.\n
890                         /xm,
891                 like => {
892                         clean => 1,
893                         clean_if_exists => 1,
894                         createdb => 1,
895                         data_only => 1,
896                         defaults => 1,
897                         exclude_dump_test_schema => 1,
898                         exclude_test_table => 1,
899                         exclude_test_table_data => 1,
900                         no_privs => 1,
901                         no_owner => 1,
902                         section_data => 1,
903                 },
904                 unlike => {
905                         only_dump_test_schema => 1,
906                         only_dump_test_table => 1,
907                         test_schema_plus_blobs => 1,
908                 },
909         },
910         'INSERT INTO test_table' => {
911                 regexp => qr/^
912                         (?:INSERT\ INTO\ test_table\ \(col1\)\ VALUES\ \(\d\);\n){9}
913                         /xm,
914                 like => {
915                         column_inserts => 1,
916                 },
917                 unlike => {
918                         clean => 1,
919                         clean_if_exists => 1,
920                         createdb => 1,
921                         data_only => 1,
922                         defaults => 1,
923                         exclude_dump_test_schema => 1,
924                         exclude_test_table => 1,
925                         exclude_test_table_data => 1,
926                         no_privs => 1,
927                         no_owner => 1,
928                         section_data => 1,
929                         only_dump_test_schema => 1,
930                         only_dump_test_table => 1,
931                         test_schema_plus_blobs => 1,
932                 },
933         },
934         'INSERT INTO test_second_table' => {
935                 regexp => qr/^
936                         (?:INSERT\ INTO\ test_second_table\ \(col1,\ col2\)
937                            \ VALUES\ \(\d,\ '\d'\);\n){9}/xm,
938                 like => {
939                         column_inserts => 1,
940                 },
941                 unlike => {
942                         clean => 1,
943                         clean_if_exists => 1,
944                         createdb => 1,
945                         data_only => 1,
946                         defaults => 1,
947                         exclude_dump_test_schema => 1,
948                         exclude_test_table => 1,
949                         exclude_test_table_data => 1,
950                         no_privs => 1,
951                         no_owner => 1,
952                         section_data => 1,
953                         only_dump_test_schema => 1,
954                         only_dump_test_table => 1,
955                         test_schema_plus_blobs => 1,
956                 },
957         },
958         'INSERT INTO test_third_table' => {
959                 regexp => qr/^
960                         (?:INSERT\ INTO\ test_third_table\ \(col1\)
961                            \ VALUES\ \(\d\);\n){9}/xm,
962                 like => {
963                         column_inserts => 1,
964                 },
965                 unlike => {
966                         clean => 1,
967                         clean_if_exists => 1,
968                         createdb => 1,
969                         data_only => 1,
970                         defaults => 1,
971                         exclude_dump_test_schema => 1,
972                         exclude_test_table => 1,
973                         exclude_test_table_data => 1,
974                         no_privs => 1,
975                         no_owner => 1,
976                         section_data => 1,
977                         only_dump_test_schema => 1,
978                         only_dump_test_table => 1,
979                         test_schema_plus_blobs => 1,
980                 },
981         },
982         'COPY ... commands' => { # catch-all for COPY
983                 regexp => qr/^COPY /m,
984                 like => { }, # use more-specific options above
985                 unlike => {
986                         binary_upgrade => 1,
987                         column_inserts => 1,
988                         pg_dumpall_globals => 1,
989                         pg_dumpall_globals_clean => 1,
990                         schema_only => 1,
991                         section_post_data => 1,
992                 },
993         },
994         'CREATE ROLE dump_test' => {
995                 create_order => 1,
996                 create_sql => 'CREATE ROLE dump_test;',
997                 regexp => qr/^CREATE ROLE dump_test;/m,
998                 like => {
999                         pg_dumpall_globals => 1,
1000                         pg_dumpall_globals_clean => 1,
1001                 },
1002                 unlike => {
1003                         binary_upgrade => 1,
1004                         clean => 1,
1005                         clean_if_exists => 1,
1006                         createdb => 1,
1007                         defaults => 1,
1008                         exclude_dump_test_schema => 1,
1009                         exclude_test_table => 1,
1010                         exclude_test_table_data => 1,
1011                         no_privs => 1,
1012                         no_owner => 1,
1013                         only_dump_test_schema => 1,
1014                         only_dump_test_table => 1,
1015                         schema_only => 1,
1016                         section_pre_data => 1,
1017                         section_post_data => 1,
1018                         test_schema_plus_blobs => 1,
1019                 },
1020         },
1021         'CREATE DATABASE postgres' => {
1022                 regexp => qr/^
1023                         \QCREATE DATABASE postgres WITH TEMPLATE = template0 \E
1024                         .*;/xm,
1025                 like => {
1026                         createdb => 1,
1027                 },
1028                 unlike => {
1029                         binary_upgrade => 1,
1030                         clean => 1,
1031                         clean_if_exists => 1,
1032                         defaults => 1,
1033                         exclude_dump_test_schema => 1,
1034                         exclude_test_table => 1,
1035                         exclude_test_table_data => 1,
1036                         no_privs => 1,
1037                         no_owner => 1,
1038                         only_dump_test_schema => 1,
1039                         only_dump_test_table => 1,
1040                         pg_dumpall_globals => 1,
1041                         pg_dumpall_globals_clean => 1,
1042                         schema_only => 1,
1043                         section_pre_data => 1,
1044                         section_post_data => 1,
1045                         test_schema_plus_blobs => 1,
1046                 },
1047         },
1048         'CREATE EXTENSION ... plpgsql' => {
1049                 regexp => qr/^
1050                         \QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E
1051                         /xm,
1052                 like => {
1053                         clean => 1,
1054                         clean_if_exists => 1,
1055                         createdb => 1,
1056                         defaults => 1,
1057                         exclude_dump_test_schema => 1,
1058                         exclude_test_table => 1,
1059                         exclude_test_table_data => 1,
1060                         no_privs => 1,
1061                         no_owner => 1,
1062                         schema_only => 1,
1063                         section_pre_data => 1,
1064                 },
1065                 unlike => {
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,
1073                 },
1074         },
1075         'CREATE AGGREGATE dump_test.newavg' => {
1076                 create_order => 25,
1077                 create_sql => 'CREATE AGGREGATE dump_test.newavg (
1078                                                   sfunc = int4_avg_accum,
1079                                                   basetype = int4,
1080                                                   stype = _int8,
1081                                                   finalfunc = int8_avg,
1082                                                   initcond1 = \'{0,0}\'
1083                                            );',
1084                 regexp => qr/^
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
1090                         \n\);/xm,
1091                 like => {
1092                         binary_upgrade => 1,
1093                         clean => 1,
1094                         clean_if_exists => 1,
1095                         createdb => 1,
1096                         defaults => 1,
1097                         exclude_test_table => 1,
1098                         exclude_test_table_data => 1,
1099                         no_privs => 1,
1100                         no_owner => 1,
1101                         only_dump_test_schema => 1,
1102                         schema_only => 1,
1103                         section_pre_data => 1,
1104                         test_schema_plus_blobs => 1,
1105                 },
1106                 unlike => {
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,
1112                 },
1113         },
1114         'CREATE DOMAIN dump_test.us_postal_code' => {
1115                 create_order => 29,
1116                 create_sql => 'CREATE DOMAIN dump_test.us_postal_code AS TEXT
1117                                            CHECK(VALUE ~ \'^\d{5}$\' OR
1118                                                          VALUE ~ \'^\d{5}-\d{4}$\');',
1119                 regexp => qr/^
1120                         \QCREATE DOMAIN us_postal_code AS text\E
1121                         \n\s+
1122                         \QCONSTRAINT us_postal_code_check CHECK \E
1123                         \Q(((VALUE ~ '^\d{5}\E
1124                         \$\Q'::text) OR (VALUE ~ '^\d{5}-\d{4}\E\$
1125                         \Q'::text)));\E
1126                         /xm,
1127                 like => {
1128                         binary_upgrade => 1,
1129                         clean => 1,
1130                         clean_if_exists => 1,
1131                         createdb => 1,
1132                         defaults => 1,
1133                         exclude_test_table => 1,
1134                         exclude_test_table_data => 1,
1135                         no_privs => 1,
1136                         no_owner => 1,
1137                         only_dump_test_schema => 1,
1138                         schema_only => 1,
1139                         section_pre_data => 1,
1140                         test_schema_plus_blobs => 1,
1141                 },
1142                 unlike => {
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,
1148                 },
1149         },
1150         'CREATE FUNCTION dump_test.pltestlang_call_handler' => {
1151                 create_order => 17,
1152                 create_sql => 'CREATE FUNCTION dump_test.pltestlang_call_handler()
1153                                            RETURNS LANGUAGE_HANDLER AS \'$libdir/plpgsql\',
1154                                            \'plpgsql_call_handler\' LANGUAGE C;',
1155                 regexp => qr/^
1156                         \QCREATE FUNCTION pltestlang_call_handler() \E
1157                         \QRETURNS language_handler\E
1158                         \n\s+\QLANGUAGE c\E
1159                         \n\s+AS\ \'\$
1160                         \Qlibdir\/plpgsql', 'plpgsql_call_handler';\E
1161                         /xm,
1162                 like => {
1163                         binary_upgrade => 1,
1164                         clean => 1,
1165                         clean_if_exists => 1,
1166                         createdb => 1,
1167                         defaults => 1,
1168                         exclude_test_table => 1,
1169                         exclude_test_table_data => 1,
1170                         no_privs => 1,
1171                         no_owner => 1,
1172                         only_dump_test_schema => 1,
1173                         schema_only => 1,
1174                         section_pre_data => 1,
1175                         test_schema_plus_blobs => 1,
1176                 },
1177                 unlike => {
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,
1183                 },
1184         },
1185         'CREATE FUNCTION dump_test.trigger_func' => {
1186                 create_order => 30,
1187                 create_sql => 'CREATE FUNCTION dump_test.trigger_func()
1188                                            RETURNS trigger LANGUAGE plpgsql
1189                                            AS $$ BEGIN RETURN NULL; END;$$;',
1190                 regexp => qr/^
1191                         \QCREATE FUNCTION trigger_func() RETURNS trigger\E
1192                         \n\s+\QLANGUAGE plpgsql\E
1193                         \n\s+AS\ \$\$
1194                         \Q BEGIN RETURN NULL; END;\E
1195                         \$\$;/xm,
1196                 like => {
1197                         binary_upgrade => 1,
1198                         clean => 1,
1199                         clean_if_exists => 1,
1200                         createdb => 1,
1201                         defaults => 1,
1202                         exclude_test_table => 1,
1203                         exclude_test_table_data => 1,
1204                         no_privs => 1,
1205                         no_owner => 1,
1206                         only_dump_test_schema => 1,
1207                         schema_only => 1,
1208                         section_pre_data => 1,
1209                         test_schema_plus_blobs => 1,
1210                 },
1211                 unlike => {
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,
1217                 },
1218         },
1219         'CREATE FUNCTION dump_test.event_trigger_func' => {
1220                 create_order => 32,
1221                 create_sql => 'CREATE FUNCTION dump_test.event_trigger_func()
1222                                            RETURNS event_trigger LANGUAGE plpgsql
1223                                            AS $$ BEGIN RETURN; END;$$;',
1224                 regexp => qr/^
1225                         \QCREATE FUNCTION event_trigger_func() RETURNS event_trigger\E
1226                         \n\s+\QLANGUAGE plpgsql\E
1227                         \n\s+AS\ \$\$
1228                         \Q BEGIN RETURN; END;\E
1229                         \$\$;/xm,
1230                 like => {
1231                         binary_upgrade => 1,
1232                         clean => 1,
1233                         clean_if_exists => 1,
1234                         createdb => 1,
1235                         defaults => 1,
1236                         exclude_test_table => 1,
1237                         exclude_test_table_data => 1,
1238                         no_privs => 1,
1239                         no_owner => 1,
1240                         only_dump_test_schema => 1,
1241                         schema_only => 1,
1242                         section_pre_data => 1,
1243                         test_schema_plus_blobs => 1,
1244                 },
1245                 unlike => {
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,
1251                 },
1252         },
1253         'CREATE EVENT TRIGGER test_event_trigger' => {
1254                 create_order => 33,
1255                 create_sql => 'CREATE EVENT TRIGGER test_event_trigger
1256                                            ON ddl_command_start
1257                                            EXECUTE PROCEDURE dump_test.event_trigger_func();',
1258                 regexp => qr/^
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
1262                         /xm,
1263                 like => {
1264                         binary_upgrade => 1,
1265                         clean => 1,
1266                         clean_if_exists => 1,
1267                         createdb => 1,
1268                         defaults => 1,
1269                         exclude_dump_test_schema => 1,
1270                         exclude_test_table => 1,
1271                         exclude_test_table_data => 1,
1272                         no_privs => 1,
1273                         no_owner => 1,
1274                         schema_only => 1,
1275                         section_post_data => 1,
1276                 },
1277                 unlike => {
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,
1284                 },
1285         },
1286         'CREATE TRIGGER test_trigger' => {
1287                 create_order => 31,
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();',
1292                 regexp => qr/^
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
1296                         /xm,
1297                 like => {
1298                         binary_upgrade => 1,
1299                         clean => 1,
1300                         clean_if_exists => 1,
1301                         createdb => 1,
1302                         defaults => 1,
1303                         exclude_test_table_data => 1,
1304                         no_privs => 1,
1305                         no_owner => 1,
1306                         only_dump_test_schema => 1,
1307                         only_dump_test_table => 1,
1308                         schema_only => 1,
1309                         section_post_data => 1,
1310                         test_schema_plus_blobs => 1,
1311                 },
1312                 unlike => {
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,
1318                 },
1319         },
1320         'CREATE TYPE dump_test.planets AS ENUM' => {
1321                 create_order => 37,
1322                 create_sql => 'CREATE TYPE dump_test.planets
1323                                            AS ENUM ( \'venus\', \'earth\', \'mars\' );',
1324                 regexp => qr/^
1325                         \QCREATE TYPE planets AS ENUM (\E
1326                         \n\s+'venus',
1327                         \n\s+'earth',
1328                         \n\s+'mars'
1329                         \n\);/xm,
1330                 like => {
1331                         clean => 1,
1332                         clean_if_exists => 1,
1333                         createdb => 1,
1334                         defaults => 1,
1335                         exclude_test_table => 1,
1336                         exclude_test_table_data => 1,
1337                         no_privs => 1,
1338                         no_owner => 1,
1339                         only_dump_test_schema => 1,
1340                         schema_only => 1,
1341                         section_pre_data => 1,
1342                         test_schema_plus_blobs => 1,
1343                 },
1344                 unlike => {
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,
1350                 },
1351         },
1352         'CREATE TYPE dump_test.planets AS ENUM pg_upgrade' => {
1353                 regexp => qr/^
1354                         \QCREATE TYPE planets AS ENUM (\E
1355                         \n\);.*^
1356                         \QALTER TYPE dump_test.planets ADD VALUE 'venus';\E
1357                         \n.*^
1358                         \QALTER TYPE dump_test.planets ADD VALUE 'earth';\E
1359                         \n.*^
1360                         \QALTER TYPE dump_test.planets ADD VALUE 'mars';\E
1361                         \n/xms,
1362                 like => {
1363                         binary_upgrade => 1,
1364                 },
1365                 unlike => {
1366                         clean => 1,
1367                         clean_if_exists => 1,
1368                         createdb => 1,
1369                         defaults => 1,
1370                         exclude_test_table => 1,
1371                         exclude_test_table_data => 1,
1372                         no_privs => 1,
1373                         no_owner => 1,
1374                         only_dump_test_schema => 1,
1375                         schema_only => 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,
1383                 },
1384         },
1385         'CREATE TYPE dump_test.textrange AS RANGE' => {
1386                 create_order => 38,
1387                 create_sql => 'CREATE TYPE dump_test.textrange
1388                                            AS RANGE (subtype=text, collation="C");',
1389                 regexp => qr/^
1390                         \QCREATE TYPE textrange AS RANGE (\E
1391                         \n\s+\Qsubtype = text,\E
1392                         \n\s+\Qcollation = pg_catalog."C"\E
1393                         \n\);/xm,
1394                 like => {
1395                         clean => 1,
1396                         clean_if_exists => 1,
1397                         createdb => 1,
1398                         defaults => 1,
1399                         exclude_test_table => 1,
1400                         exclude_test_table_data => 1,
1401                         no_privs => 1,
1402                         no_owner => 1,
1403                         only_dump_test_schema => 1,
1404                         schema_only => 1,
1405                         section_pre_data => 1,
1406                         test_schema_plus_blobs => 1,
1407                 },
1408                 unlike => {
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,
1414                 },
1415         },
1416         'CREATE TYPE dump_test.int42' => {
1417                 create_order => 39,
1418                 create_sql => 'CREATE TYPE dump_test.int42;',
1419                 regexp => qr/^CREATE TYPE int42;/m,
1420                 like => {
1421                         clean => 1,
1422                         clean_if_exists => 1,
1423                         createdb => 1,
1424                         defaults => 1,
1425                         exclude_test_table => 1,
1426                         exclude_test_table_data => 1,
1427                         no_privs => 1,
1428                         no_owner => 1,
1429                         only_dump_test_schema => 1,
1430                         schema_only => 1,
1431                         section_pre_data => 1,
1432                         test_schema_plus_blobs => 1,
1433                 },
1434                 unlike => {
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,
1440                 },
1441         },
1442         'CREATE FUNCTION dump_test.int42_in' => {
1443                 create_order => 40,
1444                 create_sql => 'CREATE FUNCTION dump_test.int42_in(cstring)
1445                                            RETURNS dump_test.int42 AS \'int4in\'
1446                                            LANGUAGE internal STRICT IMMUTABLE;',
1447                 regexp => qr/^
1448                         \QCREATE FUNCTION int42_in(cstring) RETURNS int42\E
1449                         \n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
1450                         \n\s+AS\ \$\$int4in\$\$;
1451                         /xm,
1452                 like => {
1453                         binary_upgrade => 1,
1454                         clean => 1,
1455                         clean_if_exists => 1,
1456                         createdb => 1,
1457                         defaults => 1,
1458                         exclude_test_table => 1,
1459                         exclude_test_table_data => 1,
1460                         no_privs => 1,
1461                         no_owner => 1,
1462                         only_dump_test_schema => 1,
1463                         schema_only => 1,
1464                         section_pre_data => 1,
1465                         test_schema_plus_blobs => 1,
1466                 },
1467                 unlike => {
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,
1473                 },
1474         },
1475         'CREATE FUNCTION dump_test.int42_out' => {
1476                 create_order => 41,
1477                 create_sql => 'CREATE FUNCTION dump_test.int42_out(dump_test.int42)
1478                                            RETURNS cstring AS \'int4out\'
1479                                            LANGUAGE internal STRICT IMMUTABLE;',
1480                 regexp => qr/^
1481                         \QCREATE FUNCTION int42_out(int42) RETURNS cstring\E
1482                         \n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
1483                         \n\s+AS\ \$\$int4out\$\$;
1484                         /xm,
1485                 like => {
1486                         binary_upgrade => 1,
1487                         clean => 1,
1488                         clean_if_exists => 1,
1489                         createdb => 1,
1490                         defaults => 1,
1491                         exclude_test_table => 1,
1492                         exclude_test_table_data => 1,
1493                         no_privs => 1,
1494                         no_owner => 1,
1495                         only_dump_test_schema => 1,
1496                         schema_only => 1,
1497                         section_pre_data => 1,
1498                         test_schema_plus_blobs => 1,
1499                 },
1500                 unlike => {
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,
1506                 },
1507         },
1508         'CREATE TYPE dump_test.int42 populated' => {
1509                 create_order => 42,
1510                 create_sql => 'CREATE TYPE dump_test.int42 (
1511                                                    internallength = 4,
1512                                                    input = dump_test.int42_in,
1513                                                    output = dump_test.int42_out,
1514                                                    alignment = int4,
1515                                                    default = 42,
1516                                                    passedbyvalue);',
1517                 regexp => qr/^
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\);
1526                         /xm,
1527                 like => {
1528                         clean => 1,
1529                         clean_if_exists => 1,
1530                         createdb => 1,
1531                         defaults => 1,
1532                         exclude_test_table => 1,
1533                         exclude_test_table_data => 1,
1534                         no_privs => 1,
1535                         no_owner => 1,
1536                         only_dump_test_schema => 1,
1537                         schema_only => 1,
1538                         section_pre_data => 1,
1539                         test_schema_plus_blobs => 1,
1540                 },
1541                 unlike => {
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,
1547                 },
1548         },
1549         'CREATE TYPE dump_test.composite' => {
1550                 create_order => 43,
1551                 create_sql => 'CREATE TYPE dump_test.composite AS (
1552                                                    f1 int,
1553                                                    f2 dump_test.int42
1554                                            );',
1555                 regexp => qr/^
1556                         \QCREATE TYPE composite AS (\E
1557                         \n\s+\Qf1 integer,\E
1558                         \n\s+\Qf2 int42\E
1559                         \n\);
1560                         /xm,
1561                 like => {
1562                         clean => 1,
1563                         clean_if_exists => 1,
1564                         createdb => 1,
1565                         defaults => 1,
1566                         exclude_test_table => 1,
1567                         exclude_test_table_data => 1,
1568                         no_privs => 1,
1569                         no_owner => 1,
1570                         only_dump_test_schema => 1,
1571                         schema_only => 1,
1572                         section_pre_data => 1,
1573                         test_schema_plus_blobs => 1,
1574                 },
1575                 unlike => {
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,
1581                 },
1582         },
1583         'CREATE FOREIGN DATA WRAPPER dummy' => {
1584                 create_order => 35,
1585                 create_sql => 'CREATE FOREIGN DATA WRAPPER dummy;',
1586                 regexp => qr/CREATE FOREIGN DATA WRAPPER dummy;/m,
1587                 like => {
1588                         binary_upgrade => 1,
1589                         clean => 1,
1590                         clean_if_exists => 1,
1591                         createdb => 1,
1592                         defaults => 1,
1593                         exclude_dump_test_schema => 1,
1594                         exclude_test_table => 1,
1595                         exclude_test_table_data => 1,
1596                         no_privs => 1,
1597                         no_owner => 1,
1598                         schema_only => 1,
1599                         section_pre_data => 1,
1600                 },
1601                 unlike => {
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,
1608                 },
1609         },
1610         'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy' => {
1611                 create_order => 36,
1612                 create_sql => 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;',
1613                 regexp => qr/CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;/m,
1614                 like => {
1615                         binary_upgrade => 1,
1616                         clean => 1,
1617                         clean_if_exists => 1,
1618                         createdb => 1,
1619                         defaults => 1,
1620                         exclude_dump_test_schema => 1,
1621                         exclude_test_table => 1,
1622                         exclude_test_table_data => 1,
1623                         no_privs => 1,
1624                         no_owner => 1,
1625                         schema_only => 1,
1626                         section_pre_data => 1,
1627                 },
1628                 unlike => {
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,
1635                 },
1636         },
1637 #######################################
1638 # Currently broken.
1639 #######################################
1640 #
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,
1645 #               like => {
1646 #                       binary_upgrade => 1,
1647 #                       clean => 1,
1648 #                       clean_if_exists => 1,
1649 #                       createdb => 1,
1650 #                       defaults => 1,
1651 #                       exclude_dump_test_schema => 1,
1652 #                       exclude_test_table => 1,
1653 #                       exclude_test_table_data => 1,
1654 #                       no_privs => 1,
1655 #                       no_owner => 1,
1656 #                       schema_only => 1,
1657 #                       section_post_data => 1,
1658 #               },
1659 #               unlike => {
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,
1665 #               },
1666 #       },
1667         'CREATE LANGUAGE pltestlang' => {
1668                 create_order => 18,
1669                 create_sql => 'CREATE LANGUAGE pltestlang
1670                                            HANDLER dump_test.pltestlang_call_handler;',
1671                 regexp => qr/^
1672                         \QCREATE PROCEDURAL LANGUAGE pltestlang \E
1673                         \QHANDLER pltestlang_call_handler;\E
1674                         /xm,
1675                 like => {
1676                         binary_upgrade => 1,
1677                         clean => 1,
1678                         clean_if_exists => 1,
1679                         createdb => 1,
1680                         defaults => 1,
1681                         exclude_test_table => 1,
1682                         exclude_test_table_data => 1,
1683                         no_privs => 1,
1684                         no_owner => 1,
1685                         schema_only => 1,
1686                         section_pre_data => 1,
1687                 },
1688                 unlike => {
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,
1696                 },
1697         },
1698         'CREATE MATERIALIZED VIEW matview' => {
1699                 create_order => 20,
1700                 create_sql => 'CREATE MATERIALIZED VIEW dump_test.matview (col1) AS
1701                                            SELECT * FROM dump_test.test_table;',
1702                 regexp => qr/^
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
1707                         /xm,
1708                 like => {
1709                         binary_upgrade => 1,
1710                         clean => 1,
1711                         clean_if_exists => 1,
1712                         createdb => 1,
1713                         defaults => 1,
1714                         exclude_test_table => 1,
1715                         exclude_test_table_data => 1,
1716                         no_privs => 1,
1717                         no_owner => 1,
1718                         only_dump_test_schema => 1,
1719                         schema_only => 1,
1720                         section_pre_data => 1,
1721                         test_schema_plus_blobs => 1,
1722                 },
1723                 unlike => {
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,
1729                 },
1730         },
1731         'CREATE MATERIALIZED VIEW matview_second' => {
1732                 create_order => 21,
1733                 create_sql => 'CREATE MATERIALIZED VIEW
1734                                                    dump_test.matview_second (col1) AS
1735                                                    SELECT * FROM dump_test.matview;',
1736                 regexp => qr/^
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
1741                         /xm,
1742                 like => {
1743                         binary_upgrade => 1,
1744                         clean => 1,
1745                         clean_if_exists => 1,
1746                         createdb => 1,
1747                         defaults => 1,
1748                         exclude_test_table => 1,
1749                         exclude_test_table_data => 1,
1750                         no_privs => 1,
1751                         no_owner => 1,
1752                         only_dump_test_schema => 1,
1753                         schema_only => 1,
1754                         section_pre_data => 1,
1755                         test_schema_plus_blobs => 1,
1756                 },
1757                 unlike => {
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,
1763                 },
1764         },
1765         'CREATE POLICY p1 ON test_table' => {
1766                 create_order => 22,
1767                 create_sql => 'CREATE POLICY p1 ON dump_test.test_table
1768                                                    USING (true)
1769                                                    WITH CHECK (true);',
1770                 regexp => qr/^
1771                         \QCREATE POLICY p1 ON test_table FOR ALL TO PUBLIC \E
1772                         \QUSING (true) WITH CHECK (true);\E
1773                         /xm,
1774                 like => {
1775                         binary_upgrade => 1,
1776                         clean => 1,
1777                         clean_if_exists => 1,
1778                         createdb => 1,
1779                         defaults => 1,
1780                         exclude_test_table_data => 1,
1781                         no_privs => 1,
1782                         no_owner => 1,
1783                         only_dump_test_schema => 1,
1784                         only_dump_test_table => 1,
1785                         schema_only => 1,
1786                         section_post_data => 1,
1787                         test_schema_plus_blobs => 1,
1788                 },
1789                 unlike => {
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,
1795                 },
1796         },
1797         'CREATE POLICY p2 ON test_table FOR SELECT' => {
1798                 create_order => 24,
1799                 create_sql => 'CREATE POLICY p2 ON dump_test.test_table
1800                                                    FOR SELECT TO dump_test USING (true);',
1801                 regexp => qr/^
1802                         \QCREATE POLICY p2 ON test_table FOR SELECT TO dump_test \E
1803                         \QUSING (true);\E
1804                         /xm,
1805                 like => {
1806                         binary_upgrade => 1,
1807                         clean => 1,
1808                         clean_if_exists => 1,
1809                         createdb => 1,
1810                         defaults => 1,
1811                         exclude_test_table_data => 1,
1812                         no_privs => 1,
1813                         no_owner => 1,
1814                         only_dump_test_schema => 1,
1815                         only_dump_test_table => 1,
1816                         schema_only => 1,
1817                         section_post_data => 1,
1818                         test_schema_plus_blobs => 1,
1819                 },
1820                 unlike => {
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,
1826                 },
1827         },
1828         'CREATE POLICY p3 ON test_table FOR INSERT' => {
1829                 create_order => 25,
1830                 create_sql => 'CREATE POLICY p3 ON dump_test.test_table
1831                                                    FOR INSERT TO dump_test WITH CHECK (true);',
1832                 regexp => qr/^
1833                         \QCREATE POLICY p3 ON test_table FOR INSERT \E
1834                         \QTO dump_test WITH CHECK (true);\E
1835                         /xm,
1836                 like => {
1837                         binary_upgrade => 1,
1838                         clean => 1,
1839                         clean_if_exists => 1,
1840                         createdb => 1,
1841                         defaults => 1,
1842                         exclude_test_table_data => 1,
1843                         no_privs => 1,
1844                         no_owner => 1,
1845                         only_dump_test_schema => 1,
1846                         only_dump_test_table => 1,
1847                         schema_only => 1,
1848                         section_post_data => 1,
1849                         test_schema_plus_blobs => 1,
1850                 },
1851                 unlike => {
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,
1857                 },
1858         },
1859         'CREATE POLICY p4 ON test_table FOR UPDATE' => {
1860                 create_order => 26,
1861                 create_sql => 'CREATE POLICY p4 ON dump_test.test_table FOR UPDATE
1862                                                    TO dump_test USING (true) WITH CHECK (true);',
1863                 regexp => qr/^
1864                         \QCREATE POLICY p4 ON test_table FOR UPDATE TO dump_test \E
1865                         \QUSING (true) WITH CHECK (true);\E
1866                         /xm,
1867                 like => {
1868                         binary_upgrade => 1,
1869                         clean => 1,
1870                         clean_if_exists => 1,
1871                         createdb => 1,
1872                         defaults => 1,
1873                         exclude_test_table_data => 1,
1874                         no_privs => 1,
1875                         no_owner => 1,
1876                         only_dump_test_schema => 1,
1877                         only_dump_test_table => 1,
1878                         schema_only => 1,
1879                         section_post_data => 1,
1880                         test_schema_plus_blobs => 1,
1881                 },
1882                 unlike => {
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,
1888                 },
1889         },
1890         'CREATE POLICY p5 ON test_table FOR DELETE' => {
1891                 create_order => 27,
1892                 create_sql => 'CREATE POLICY p5 ON dump_test.test_table
1893                                                    FOR DELETE TO dump_test USING (true);',
1894                 regexp => qr/^
1895                         \QCREATE POLICY p5 ON test_table FOR DELETE \E
1896                         \QTO dump_test USING (true);\E
1897                         /xm,
1898                 like => {
1899                         binary_upgrade => 1,
1900                         clean => 1,
1901                         clean_if_exists => 1,
1902                         createdb => 1,
1903                         defaults => 1,
1904                         exclude_test_table_data => 1,
1905                         no_privs => 1,
1906                         no_owner => 1,
1907                         only_dump_test_schema => 1,
1908                         only_dump_test_table => 1,
1909                         schema_only => 1,
1910                         section_post_data => 1,
1911                         test_schema_plus_blobs => 1,
1912                 },
1913                 unlike => {
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,
1919                 },
1920         },
1921         'CREATE SCHEMA dump_test' => {
1922                 create_order => 2,
1923                 create_sql => 'CREATE SCHEMA dump_test;',
1924                 regexp => qr/^CREATE SCHEMA dump_test;/m,
1925                 like => {
1926                         binary_upgrade => 1,
1927                         clean => 1,
1928                         clean_if_exists => 1,
1929                         createdb => 1,
1930                         defaults => 1,
1931                         exclude_test_table => 1,
1932                         exclude_test_table_data => 1,
1933                         no_privs => 1,
1934                         no_owner => 1,
1935                         only_dump_test_schema => 1,
1936                         schema_only => 1,
1937                         section_pre_data => 1,
1938                         test_schema_plus_blobs => 1,
1939                 },
1940                 unlike => {
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,
1946                 },
1947         },
1948         'CREATE SCHEMA dump_test_second_schema' => {
1949                 create_order => 9,
1950                 create_sql => 'CREATE SCHEMA dump_test_second_schema;',
1951                 regexp => qr/^CREATE SCHEMA dump_test_second_schema;/m,
1952                 like => {
1953                         binary_upgrade => 1,
1954                         clean => 1,
1955                         clean_if_exists => 1,
1956                         createdb => 1,
1957                         defaults => 1,
1958                         exclude_dump_test_schema => 1,
1959                         exclude_test_table => 1,
1960                         exclude_test_table_data => 1,
1961                         no_privs => 1,
1962                         no_owner => 1,
1963                         schema_only => 1,
1964                         section_pre_data => 1,
1965                 },
1966                 unlike => {
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,
1973                 },
1974         },
1975         'CREATE TABLE test_table' => {
1976                 create_order => 3,
1977                 create_sql => 'CREATE TABLE dump_test.test_table (
1978                                                    col1 serial primary key,
1979                                                    CHECK (col1 <= 1000)
1980                                            );',
1981                 regexp => qr/^
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
1986                         \n\);/xm,
1987                 like => {
1988                         binary_upgrade => 1,
1989                         clean => 1,
1990                         clean_if_exists => 1,
1991                         createdb => 1,
1992                         defaults => 1,
1993                         exclude_test_table_data => 1,
1994                         no_privs => 1,
1995                         no_owner => 1,
1996                         only_dump_test_schema => 1,
1997                         only_dump_test_table => 1,
1998                         schema_only => 1,
1999                         section_pre_data => 1,
2000                         test_schema_plus_blobs => 1,
2001                 },
2002                 unlike => {
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,
2008                 },
2009         },
2010         'CREATE TABLE fk_reference_test_table' => {
2011                 create_order => 21,
2012                 create_sql => 'CREATE TABLE dump_test.fk_reference_test_table (
2013                                                    col1 int primary key references dump_test.test_table
2014                                            );',
2015                 regexp => qr/^
2016                         \QCREATE TABLE fk_reference_test_table (\E
2017                         \n\s+\Qcol1 integer NOT NULL\E
2018                         \n\);
2019                         /xm,
2020                 like => {
2021                         binary_upgrade => 1,
2022                         clean => 1,
2023                         clean_if_exists => 1,
2024                         createdb => 1,
2025                         defaults => 1,
2026                         exclude_test_table => 1,
2027                         exclude_test_table_data => 1,
2028                         no_privs => 1,
2029                         no_owner => 1,
2030                         only_dump_test_schema => 1,
2031                         schema_only => 1,
2032                         section_pre_data => 1,
2033                         test_schema_plus_blobs => 1,
2034                 },
2035                 unlike => {
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,
2041                 },
2042         },
2043         'CREATE TABLE test_second_table' => {
2044                 create_order => 6,
2045                 create_sql => 'CREATE TABLE dump_test.test_second_table (
2046                                                    col1 int,
2047                                                    col2 text
2048                                            );',
2049                 regexp => qr/^
2050                         \QCREATE TABLE test_second_table (\E
2051                         \n\s+\Qcol1 integer,\E
2052                         \n\s+\Qcol2 text\E
2053                         \n\);
2054                         /xm,
2055                 like => {
2056                         binary_upgrade => 1,
2057                         clean => 1,
2058                         clean_if_exists => 1,
2059                         createdb => 1,
2060                         defaults => 1,
2061                         exclude_test_table => 1,
2062                         exclude_test_table_data => 1,
2063                         no_privs => 1,
2064                         no_owner => 1,
2065                         only_dump_test_schema => 1,
2066                         schema_only => 1,
2067                         section_pre_data => 1,
2068                         test_schema_plus_blobs => 1,
2069                 },
2070                 unlike => {
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,
2076                 },
2077         },
2078         'CREATE TABLE test_third_table' => {
2079                 create_order => 11,
2080                 create_sql => 'CREATE TABLE dump_test_second_schema.test_third_table (
2081                                                    col1 serial
2082                                            );',
2083                 regexp => qr/^
2084                         \QCREATE TABLE test_third_table (\E
2085                         \n\s+\Qcol1 integer NOT NULL\E
2086                         \n\);
2087                         /xm,
2088                 like => {
2089                         binary_upgrade => 1,
2090                         clean => 1,
2091                         clean_if_exists => 1,
2092                         createdb => 1,
2093                         defaults => 1,
2094                         exclude_dump_test_schema => 1,
2095                         exclude_test_table => 1,
2096                         exclude_test_table_data => 1,
2097                         no_privs => 1,
2098                         no_owner => 1,
2099                         schema_only => 1,
2100                         section_pre_data => 1,
2101                 },
2102                 unlike => {
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,
2109                 },
2110         },
2111         'CREATE SEQUENCE test_table_col1_seq' => {
2112                 regexp => qr/^
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
2118                         \n\s+\QCACHE 1;\E
2119                         /xm,
2120                 like => {
2121                         binary_upgrade => 1,
2122                         clean => 1,
2123                         clean_if_exists => 1,
2124                         createdb => 1,
2125                         defaults => 1,
2126                         exclude_test_table => 1,
2127                         exclude_test_table_data => 1,
2128                         no_privs => 1,
2129                         no_owner => 1,
2130                         only_dump_test_schema => 1,
2131                         only_dump_test_table => 1,
2132                         schema_only => 1,
2133                         section_pre_data => 1,
2134                         test_schema_plus_blobs => 1,
2135                 },
2136                 unlike => {
2137                         exclude_dump_test_schema => 1,
2138                         pg_dumpall_globals => 1,
2139                         pg_dumpall_globals_clean => 1,
2140                         section_post_data => 1,
2141                 },
2142         },
2143         'CREATE SEQUENCE test_third_table_col1_seq' => {
2144                 regexp => qr/^
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
2150                         \n\s+\QCACHE 1;\E
2151                         /xm,
2152                 like => {
2153                         binary_upgrade => 1,
2154                         clean => 1,
2155                         clean_if_exists => 1,
2156                         createdb => 1,
2157                         defaults => 1,
2158                         exclude_dump_test_schema => 1,
2159                         exclude_test_table => 1,
2160                         exclude_test_table_data => 1,
2161                         no_privs => 1,
2162                         no_owner => 1,
2163                         schema_only => 1,
2164                         section_pre_data => 1,
2165                 },
2166                 unlike => {
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,
2173                 },
2174         },
2175         'CREATE UNIQUE INDEX test_third_table_idx ON test_third_table' => {
2176                 create_order => 13,
2177                 create_sql => 'CREATE UNIQUE INDEX test_third_table_idx
2178                                            ON dump_test_second_schema.test_third_table (col1);',
2179                 regexp => qr/^
2180                         \QCREATE UNIQUE INDEX test_third_table_idx \E
2181                         \QON test_third_table USING btree (col1);\E
2182                         /xm,
2183                 like => {
2184                         binary_upgrade => 1,
2185                         clean => 1,
2186                         clean_if_exists => 1,
2187                         createdb => 1,
2188                         defaults => 1,
2189                         exclude_dump_test_schema => 1,
2190                         exclude_test_table => 1,
2191                         exclude_test_table_data => 1,
2192                         no_privs => 1,
2193                         no_owner => 1,
2194                         schema_only => 1,
2195                         section_post_data => 1,
2196                 },
2197                 unlike => {
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,
2203                 },
2204         },
2205         'CREATE ... commands' => { # catch-all for CREATE
2206                 regexp => qr/^CREATE /m,
2207                 like => { }, # use more-specific options above
2208                 unlike => {
2209                         column_inserts => 1,
2210                         data_only => 1,
2211                         section_data => 1,
2212                 },
2213         },
2214         'DROP EXTENSION plpgsql' => {
2215                 regexp => qr/^DROP EXTENSION plpgsql;/m,
2216                 like => {
2217                         clean => 1,
2218                 },
2219                 unlike => {
2220                         clean_if_exists => 1,
2221                 },
2222         },
2223         'DROP FUNCTION dump_test.pltestlang_call_handler()' => {
2224                 regexp => qr/^DROP FUNCTION dump_test\.pltestlang_call_handler\(\);/m,
2225                 like => {
2226                         clean => 1,
2227                 },
2228                 unlike => {
2229                         clean_if_exists => 1,
2230                 },
2231         },
2232         'DROP LANGUAGE pltestlang' => {
2233                 regexp => qr/^DROP PROCEDURAL LANGUAGE pltestlang;/m,
2234                 like => {
2235                         clean => 1,
2236                 },
2237                 unlike => {
2238                         clean_if_exists => 1,
2239                 },
2240         },
2241         'DROP SCHEMA dump_test' => {
2242                 regexp => qr/^DROP SCHEMA dump_test;/m,
2243                 like => {
2244                         clean => 1,
2245                 },
2246                 unlike => {
2247                         clean_if_exists => 1,
2248                 },
2249         },
2250         'DROP SCHEMA dump_test_second_schema' => {
2251                 regexp => qr/^DROP SCHEMA dump_test_second_schema;/m,
2252                 like => {
2253                         clean => 1,
2254                 },
2255                 unlike => {
2256                         clean_if_exists => 1,
2257                 },
2258         },
2259         'DROP TABLE test_table' => {
2260                 regexp => qr/^DROP TABLE dump_test\.test_table;/m,
2261                 like => {
2262                         clean => 1,
2263                 },
2264                 unlike => {
2265                         clean_if_exists => 1,
2266                 },
2267         },
2268         'DROP TABLE fk_reference_test_table' => {
2269                 regexp => qr/^DROP TABLE dump_test\.fk_reference_test_table;/m,
2270                 like => {
2271                         clean => 1,
2272                 },
2273                 unlike => {
2274                         clean_if_exists => 1,
2275                 },
2276         },
2277         'DROP TABLE test_second_table' => {
2278                 regexp => qr/^DROP TABLE dump_test\.test_second_table;/m,
2279                 like => {
2280                         clean => 1,
2281                 },
2282                 unlike => {
2283                         clean_if_exists => 1,
2284                 },
2285         },
2286         'DROP TABLE test_third_table' => {
2287                 regexp => qr/^DROP TABLE dump_test_second_schema\.test_third_table;/m,
2288                 like => {
2289                         clean => 1,
2290                 },
2291                 unlike => {
2292                         clean_if_exists => 1,
2293                 },
2294         },
2295         'DROP EXTENSION IF EXISTS plpgsql' => {
2296                 regexp => qr/^DROP EXTENSION IF EXISTS plpgsql;/m,
2297                 like => {
2298                         clean_if_exists => 1,
2299                 },
2300                 unlike => {
2301                         clean => 1,
2302                 },
2303         },
2304         'DROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler()' => {
2305                 regexp => qr/^
2306                         \QDROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler();\E
2307                         /xm,
2308                 like => {
2309                         clean_if_exists => 1,
2310                 },
2311                 unlike => {
2312                         clean => 1,
2313                 },
2314         },
2315         'DROP LANGUAGE IF EXISTS pltestlang' => {
2316                 regexp => qr/^DROP PROCEDURAL LANGUAGE IF EXISTS pltestlang;/m,
2317                 like => {
2318                         clean_if_exists => 1,
2319                 },
2320                 unlike => {
2321                         clean => 1,
2322                 },
2323         },
2324         'DROP SCHEMA IF EXISTS dump_test' => {
2325                 regexp => qr/^DROP SCHEMA IF EXISTS dump_test;/m,
2326                 like => {
2327                         clean_if_exists => 1,
2328                 },
2329                 unlike => {
2330                         clean => 1,
2331                 },
2332         },
2333         'DROP SCHEMA IF EXISTS dump_test_second_schema' => {
2334                 regexp => qr/^DROP SCHEMA IF EXISTS dump_test_second_schema;/m,
2335                 like => {
2336                         clean_if_exists => 1,
2337                 },
2338                 unlike => {
2339                         clean => 1,
2340                 },
2341         },
2342         'DROP TABLE IF EXISTS test_table' => {
2343                 regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_table;/m,
2344                 like => {
2345                         clean_if_exists => 1,
2346                 },
2347                 unlike => {
2348                         clean => 1,
2349                 },
2350         },
2351         'DROP TABLE IF EXISTS test_second_table' => {
2352                 regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_second_table;/m,
2353                 like => {
2354                         clean_if_exists => 1,
2355                 },
2356                 unlike => {
2357                         clean => 1,
2358                 },
2359         },
2360         'DROP TABLE IF EXISTS test_third_table' => {
2361                 regexp => qr/^
2362                         \QDROP TABLE IF EXISTS dump_test_second_schema.test_third_table;\E
2363                         /xm,
2364                 like => {
2365                         clean_if_exists => 1,
2366                 },
2367                 unlike => {
2368                         clean => 1,
2369                 },
2370         },
2371         'DROP ROLE dump_test' => {
2372                 regexp => qr/^
2373                         \QDROP ROLE dump_test;\E
2374                         /xm,
2375                 like => {
2376                         pg_dumpall_globals_clean => 1,
2377                 },
2378                 unlike => {
2379                         clean => 1,
2380                         clean_if_exists => 1,
2381                 },
2382         },
2383         'DROP ROLE pg_' => {
2384                 regexp => qr/^
2385                         \QDROP ROLE pg_\E.*;
2386                         /xm,
2387                 like => {
2388                 },
2389                 unlike => {
2390                         clean => 1,
2391                         clean_if_exists => 1,
2392                         pg_dumpall_globals_clean => 1,
2393                 },
2394         },
2395         'DROP ... commands' => { # catch-all for DROP
2396                 regexp => qr/^DROP /m,
2397                 like => { }, # use more-specific options above
2398                 unlike => {
2399                         binary_upgrade => 1,
2400                         column_inserts => 1,
2401                         createdb => 1,
2402                         data_only => 1,
2403                         defaults => 1,
2404                         exclude_dump_test_schema => 1,
2405                         exclude_test_table => 1,
2406                         exclude_test_table_data => 1,
2407                         no_privs => 1,
2408                         no_owner => 1,
2409                         only_dump_test_schema => 1,
2410                         only_dump_test_table => 1,
2411                         pg_dumpall_globals => 1,
2412                         schema_only => 1,
2413                 },
2414         },
2415         'GRANT USAGE ON SCHEMA dump_test_second_schema' => {
2416                 create_order => 10,
2417                 create_sql => 'GRANT USAGE ON SCHEMA dump_test_second_schema
2418                                                    TO dump_test;',
2419                 regexp => qr/^
2420                         \QGRANT USAGE ON SCHEMA dump_test_second_schema TO dump_test;\E
2421                         /xm,
2422                 like => {
2423                         binary_upgrade => 1,
2424                         clean => 1,
2425                         clean_if_exists => 1,
2426                         createdb => 1,
2427                         defaults => 1,
2428                         exclude_dump_test_schema => 1,
2429                         exclude_test_table => 1,
2430                         exclude_test_table_data => 1,
2431                         no_owner => 1,
2432                         schema_only => 1,
2433                         section_pre_data => 1,
2434                 },
2435                 unlike => {
2436                         only_dump_test_schema => 1,
2437                         only_dump_test_table => 1,
2438                         pg_dumpall_globals => 1,
2439                         test_schema_plus_blobs => 1,
2440                 },
2441         },
2442         'GRANT SELECT ON TABLE test_table' => {
2443                 create_order => 5,
2444                 create_sql => 'GRANT SELECT ON TABLE dump_test.test_table
2445                                                    TO dump_test;',
2446                 regexp => qr/^GRANT SELECT ON TABLE test_table TO dump_test;/m,
2447                 like => {
2448                         binary_upgrade => 1,
2449                         clean => 1,
2450                         clean_if_exists => 1,
2451                         createdb => 1,
2452                         defaults => 1,
2453                         exclude_test_table_data => 1,
2454                         no_owner => 1,
2455                         only_dump_test_schema => 1,
2456                         only_dump_test_table => 1,
2457                         schema_only => 1,
2458                         section_pre_data => 1,
2459                         test_schema_plus_blobs => 1,
2460                 },
2461                 unlike => {
2462                         exclude_dump_test_schema => 1,
2463                         exclude_test_table => 1,
2464                         pg_dumpall_globals => 1,
2465                 },
2466         },
2467         'GRANT SELECT ON TABLE test_third_table' => {
2468                 create_order => 19,
2469                 create_sql => 'GRANT SELECT ON
2470                                                    TABLE dump_test_second_schema.test_third_table
2471                                                    TO dump_test;',
2472                 regexp => qr/^GRANT SELECT ON TABLE test_third_table TO dump_test;/m,
2473                 like => {
2474                         binary_upgrade => 1,
2475                         clean => 1,
2476                         clean_if_exists => 1,
2477                         createdb => 1,
2478                         defaults => 1,
2479                         exclude_dump_test_schema => 1,
2480                         exclude_test_table => 1,
2481                         exclude_test_table_data => 1,
2482                         no_owner => 1,
2483                         schema_only => 1,
2484                         section_pre_data => 1,
2485                 },
2486                 unlike => {
2487                         only_dump_test_schema => 1,
2488                         only_dump_test_table => 1,
2489                         pg_dumpall_globals => 1,
2490                         test_schema_plus_blobs => 1,
2491                 },
2492         },
2493         'GRANT ALL ON SEQUENCE test_third_table_col1_seq' => {
2494                 create_order => 28,
2495                 create_sql => 'GRANT ALL ON SEQUENCE
2496                                                    dump_test_second_schema.test_third_table_col1_seq
2497                                                    TO dump_test;',
2498                 regexp => qr/^
2499                         \QGRANT ALL ON SEQUENCE test_third_table_col1_seq TO dump_test;\E
2500                         /xm,
2501                 like => {
2502                         binary_upgrade => 1,
2503                         clean => 1,
2504                         clean_if_exists => 1,
2505                         createdb => 1,
2506                         defaults => 1,
2507                         exclude_dump_test_schema => 1,
2508                         exclude_test_table => 1,
2509                         exclude_test_table_data => 1,
2510                         no_owner => 1,
2511                         schema_only => 1,
2512                         section_pre_data => 1,
2513                 },
2514                 unlike => {
2515                         only_dump_test_schema => 1,
2516                         only_dump_test_table => 1,
2517                         pg_dumpall_globals => 1,
2518                         test_schema_plus_blobs => 1,
2519                 },
2520         },
2521         'GRANT INSERT(col1) ON TABLE test_second_table' => {
2522                 create_order => 8,
2523                 create_sql => 'GRANT INSERT (col1) ON TABLE dump_test.test_second_table
2524                                                    TO dump_test;',
2525                 regexp => qr/^
2526                         \QGRANT INSERT(col1) ON TABLE test_second_table TO dump_test;\E
2527                         /xm,
2528                 like => {
2529                         binary_upgrade => 1,
2530                         clean => 1,
2531                         clean_if_exists => 1,
2532                         createdb => 1,
2533                         defaults => 1,
2534                         exclude_test_table => 1,
2535                         exclude_test_table_data => 1,
2536                         no_owner => 1,
2537                         only_dump_test_schema => 1,
2538                         schema_only => 1,
2539                         section_pre_data => 1,
2540                         test_schema_plus_blobs => 1,
2541                 },
2542                 unlike => {
2543                         exclude_dump_test_schema => 1,
2544                         only_dump_test_table => 1,
2545                         pg_dumpall_globals => 1,
2546                 },
2547         },
2548         'GRANT EXECUTE ON FUNCTION pg_sleep() TO dump_test' => {
2549                 create_order => 16,
2550                 create_sql => 'GRANT EXECUTE ON FUNCTION pg_sleep(float8)
2551                                                    TO dump_test;',
2552                 regexp => qr/^
2553                         \QGRANT ALL ON FUNCTION pg_sleep(double precision) TO dump_test;\E
2554                         /xm,
2555                 like => {
2556                         binary_upgrade => 1,
2557                         clean => 1,
2558                         clean_if_exists => 1,
2559                         createdb => 1,
2560                         defaults => 1,
2561                         exclude_dump_test_schema => 1,
2562                         exclude_test_table => 1,
2563                         exclude_test_table_data => 1,
2564                         no_owner => 1,
2565                         schema_only => 1,
2566                         section_pre_data => 1,
2567                 },
2568                 unlike => {
2569                         only_dump_test_schema => 1,
2570                         only_dump_test_table => 1,
2571                         test_schema_plus_blobs => 1,
2572                 },
2573         },
2574         'GRANT SELECT (proname ...) ON TABLE pg_proc TO public' => {
2575                 create_order => 46,
2576                 create_sql => 'GRANT SELECT (
2577                                                    tableoid,
2578                                                    oid,
2579                                                    proname,
2580                                                    pronamespace,
2581                                                    proowner,
2582                                                    prolang,
2583                                                    procost,
2584                                                    prorows,
2585                                                    provariadic,
2586                                                    protransform,
2587                                                    proisagg,
2588                                                    proiswindow,
2589                                                    prosecdef,
2590                                                    proleakproof,
2591                                                    proisstrict,
2592                                                    proretset,
2593                                                    provolatile,
2594                                                    proparallel,
2595                                                    pronargs,
2596                                                    pronargdefaults,
2597                                                    prorettype,
2598                                                    proargtypes,
2599                                                    proallargtypes,
2600                                                    proargmodes,
2601                                                    proargnames,
2602                                                    proargdefaults,
2603                                                    protrftypes,
2604                                                    prosrc,
2605                                                    probin,
2606                                                    proconfig,
2607                                                    proacl
2608                                                 ) ON TABLE pg_proc TO public;',
2609                 regexp => qr/
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,
2641                 like => {
2642                         binary_upgrade => 1,
2643                         clean => 1,
2644                         clean_if_exists => 1,
2645                         createdb => 1,
2646                         defaults => 1,
2647                         exclude_dump_test_schema => 1,
2648                         exclude_test_table => 1,
2649                         exclude_test_table_data => 1,
2650                         no_owner => 1,
2651                         schema_only => 1,
2652                         section_pre_data => 1,
2653                 },
2654                 unlike => {
2655                         only_dump_test_schema => 1,
2656                         only_dump_test_table => 1,
2657                         test_schema_plus_blobs => 1,
2658                 },
2659         },
2660         'GRANT commands' => { # catch-all for GRANT commands
2661                 regexp => qr/^GRANT /m,
2662                 like => { }, # use more-specific options above
2663                 unlike => {
2664                         column_inserts => 1,
2665                         data_only => 1,
2666                         no_privs => 1,
2667                         section_data => 1,
2668                 },
2669         },
2670         'REFRESH MATERIALIZED VIEW matview' => {
2671                 regexp => qr/^REFRESH MATERIALIZED VIEW matview;/m,
2672                 like => {
2673                         clean => 1,
2674                         clean_if_exists => 1,
2675                         createdb => 1,
2676                         defaults => 1,
2677                         exclude_test_table => 1,
2678                         exclude_test_table_data => 1,
2679                         no_privs => 1,
2680                         no_owner => 1,
2681                         only_dump_test_schema => 1,
2682                         test_schema_plus_blobs => 1,
2683                         section_post_data => 1,
2684                 },
2685                 unlike => {
2686                         binary_upgrade => 1,
2687                         exclude_dump_test_schema => 1,
2688                         only_dump_test_table => 1,
2689                         pg_dumpall_globals => 1,
2690                         schema_only => 1,
2691                         section_pre_data => 1,
2692                 },
2693         },
2694         'REFRESH MATERIALIZED VIEW matview_second' => {
2695                 regexp => qr/^
2696                         \QREFRESH MATERIALIZED VIEW matview;\E
2697                         \n.*
2698                         \QREFRESH MATERIALIZED VIEW matview_second;\E
2699                         /xms,
2700                 like => {
2701                         clean => 1,
2702                         clean_if_exists => 1,
2703                         createdb => 1,
2704                         defaults => 1,
2705                         exclude_test_table => 1,
2706                         exclude_test_table_data => 1,
2707                         no_privs => 1,
2708                         no_owner => 1,
2709                         only_dump_test_schema => 1,
2710                         test_schema_plus_blobs => 1,
2711                         section_post_data => 1,
2712                 },
2713                 unlike => {
2714                         binary_upgrade => 1,
2715                         exclude_dump_test_schema => 1,
2716                         only_dump_test_table => 1,
2717                         pg_dumpall_globals => 1,
2718                         schema_only => 1,
2719                         section_pre_data => 1,
2720                 },
2721         },
2722         'REVOKE EXECUTE ON FUNCTION pg_sleep() FROM public' => {
2723                 create_order => 15,
2724                 create_sql => 'REVOKE EXECUTE ON FUNCTION pg_sleep(float8)
2725                                                    FROM public;',
2726                 regexp => qr/^
2727                         \QREVOKE ALL ON FUNCTION pg_sleep(double precision) FROM PUBLIC;\E
2728                         /xm,
2729                 like => {
2730                         binary_upgrade => 1,
2731                         clean => 1,
2732                         clean_if_exists => 1,
2733                         createdb => 1,
2734                         defaults => 1,
2735                         exclude_dump_test_schema => 1,
2736                         exclude_test_table => 1,
2737                         exclude_test_table_data => 1,
2738                         no_owner => 1,
2739                         schema_only => 1,
2740                         section_pre_data => 1,
2741                 },
2742                 unlike => {
2743                         only_dump_test_schema => 1,
2744                         only_dump_test_table => 1,
2745                         test_schema_plus_blobs => 1,
2746                 },
2747         },
2748         'REVOKE SELECT ON TABLE pg_proc FROM public' => {
2749                 create_order => 45,
2750                 create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;',
2751                 regexp => qr/^REVOKE SELECT ON TABLE pg_proc FROM PUBLIC;/m,
2752                 like => {
2753                         binary_upgrade => 1,
2754                         clean => 1,
2755                         clean_if_exists => 1,
2756                         createdb => 1,
2757                         defaults => 1,
2758                         exclude_dump_test_schema => 1,
2759                         exclude_test_table => 1,
2760                         exclude_test_table_data => 1,
2761                         no_owner => 1,
2762                         schema_only => 1,
2763                         section_pre_data => 1,
2764                 },
2765                 unlike => {
2766                         only_dump_test_schema => 1,
2767                         only_dump_test_table => 1,
2768                         test_schema_plus_blobs => 1,
2769                 },
2770         },
2771         'REVOKE CREATE ON SCHEMA public FROM public' => {
2772                 create_order => 16,
2773                 create_sql => 'REVOKE CREATE ON SCHEMA public FROM public;',
2774                 regexp => qr/^
2775                         \QREVOKE ALL ON SCHEMA public FROM PUBLIC;\E
2776                         \n\QGRANT USAGE ON SCHEMA public TO PUBLIC;\E
2777                         /xm,
2778                 like => {
2779                         binary_upgrade => 1,
2780                         clean => 1,
2781                         clean_if_exists => 1,
2782                         createdb => 1,
2783                         defaults => 1,
2784                         exclude_dump_test_schema => 1,
2785                         exclude_test_table => 1,
2786                         exclude_test_table_data => 1,
2787                         no_owner => 1,
2788                         schema_only => 1,
2789                         section_pre_data => 1,
2790                 },
2791                 unlike => {
2792                         only_dump_test_schema => 1,
2793                         only_dump_test_table => 1,
2794                         test_schema_plus_blobs => 1,
2795                 },
2796         },
2797         'REVOKE USAGE ON LANGUAGE plpgsql FROM public' => {
2798                 create_order => 16,
2799                 create_sql => 'REVOKE USAGE ON LANGUAGE plpgsql FROM public;',
2800                 regexp => qr/^REVOKE ALL ON LANGUAGE plpgsql FROM PUBLIC;/m,
2801                 like => {
2802                         binary_upgrade => 1,
2803                         clean => 1,
2804                         clean_if_exists => 1,
2805                         createdb => 1,
2806                         defaults => 1,
2807                         exclude_dump_test_schema => 1,
2808                         exclude_test_table => 1,
2809                         exclude_test_table_data => 1,
2810                         no_owner => 1,
2811                         schema_only => 1,
2812                         section_pre_data => 1,
2813                 },
2814                 unlike => {
2815                         only_dump_test_schema => 1,
2816                         only_dump_test_table => 1,
2817                         test_schema_plus_blobs => 1,
2818                 },
2819         },
2820         'REVOKE commands' => { # catch-all for REVOKE commands
2821                 regexp => qr/^REVOKE /m,
2822                 like => { }, # use more-specific options above
2823                 unlike => {
2824                         column_inserts => 1,
2825                         data_only => 1,
2826                         no_privs => 1,
2827                         pg_dumpall_globals => 1,
2828                 },
2829         },
2830 );
2831
2832 #########################################
2833 # Create a PG instance to test actually dumping from
2834
2835 my $node = get_new_node('main');
2836 $node->init;
2837 $node->start;
2838
2839 my $port = $node->port;
2840
2841 # Start with 2 because of command_exit_is() tests below
2842 my $num_tests = 2;
2843
2844 foreach my $run (sort keys %pgdump_runs) {
2845         my $test_key = $run;
2846
2847         # Each run of pg_dump is a test itself
2848         $num_tests++;
2849
2850         # If there is a restore cmd, that's another test
2851         if ($pgdump_runs{$run}->{restore_cmd}) {
2852                 $num_tests++;
2853         }
2854
2855         if ($pgdump_runs{$run}->{test_key}) {
2856                 $test_key = $pgdump_runs{$run}->{test_key};
2857         }
2858
2859         # Then count all the tests run against each run
2860         foreach my $test (sort keys %tests) {
2861                 if ($tests{$test}->{like}->{$test_key}) {
2862                         $num_tests++;
2863                 }
2864
2865                 if ($tests{$test}->{unlike}->{$test_key}) {
2866                         $num_tests++;
2867                 }
2868         }
2869 }
2870 plan tests => $num_tests;
2871
2872 #########################################
2873 # Set up schemas, tables, etc, to be dumped.
2874
2875 # Build up the create statements
2876 my $create_sql = '';
2877
2878 foreach my $test (
2879         sort {
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}) {
2883                         -1;
2884                 } elsif ($tests{$b}->{create_order}) {
2885                         1;
2886                 } else {
2887                         0;
2888                 }
2889         } keys %tests) {
2890         if ($tests{$test}->{create_sql}) {
2891                 $create_sql .= $tests{$test}->{create_sql};
2892         }
2893 }
2894
2895 # Send the combined set of commands to psql
2896 $node->safe_psql('postgres', $create_sql);
2897
2898 #########################################
2899 # Test connecting to a non-existent database
2900
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');
2903
2904 command_exit_is([ 'pg_dump', '-p', "$port", '--role=dump_test' ],
2905         1, 'pg_dump: [archiver (db)] query failed: ERROR:  permission denied for');
2906
2907 #########################################
2908 # Run all runs
2909
2910 foreach my $run (sort keys %pgdump_runs) {
2911
2912         my $test_key = $run;
2913
2914         $node->command_ok(\@{ $pgdump_runs{$run}->{dump_cmd} }, "$run: pg_dump runs");
2915
2916         if ($pgdump_runs{$run}->{restore_cmd}) {
2917                 $node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} }, "$run: pg_restore runs");
2918         }
2919
2920         if ($pgdump_runs{$run}->{test_key}) {
2921                 $test_key = $pgdump_runs{$run}->{test_key};
2922         }
2923
2924         my $output_file = slurp_file("$tempdir/${run}.sql");
2925
2926         #########################################
2927         # Run all tests where this run is included
2928         # as either a 'like' or 'unlike' test.
2929
2930         foreach my $test (sort keys %tests) {
2931                 if ($tests{$test}->{like}->{$test_key}) {
2932                         like($output_file, $tests{$test}->{regexp}, "$run: dumps $test");
2933                 }
2934
2935                 if ($tests{$test}->{unlike}->{$test_key}) {
2936                         unlike($output_file, $tests{$test}->{regexp}, "$run: does not dump $test");
2937                 }
2938         }
2939 }
2940
2941 #########################################
2942 # Stop the database instance, which will be removed at the end of the tests.
2943
2944 $node->stop('fast');