|
97 | 97 | 'pg_dump', '--no-sync',
|
98 | 98 | '-f', "$tempdir/defaults.sql",
|
99 | 99 | 'postgres', ], },
|
| 100 | + defaults_no_public => { |
| 101 | + database => 'regress_pg_dump_test', |
| 102 | + dump_cmd => [ |
| 103 | + 'pg_dump', |
| 104 | + '--no-sync', |
| 105 | + '-f', |
| 106 | + "$tempdir/defaults_no_public.sql", |
| 107 | + 'regress_pg_dump_test', ], }, |
| 108 | + defaults_no_public_clean => { |
| 109 | + database => 'regress_pg_dump_test', |
| 110 | + dump_cmd => [ |
| 111 | + 'pg_dump', |
| 112 | + '--no-sync', |
| 113 | + '-c', |
| 114 | + '-f', |
| 115 | + "$tempdir/defaults_no_public_clean.sql", |
| 116 | + 'regress_pg_dump_test', ], }, |
100 | 117 |
|
101 | 118 | # Do not use --no-sync to give test coverage for data sync.
|
102 | 119 | defaults_custom_format => {
|
|
4524 | 4541 | pg_dumpall_globals_clean => 1,
|
4525 | 4542 | test_schema_plus_blobs => 1, }, },
|
4526 | 4543 |
|
| 4544 | + 'CREATE SCHEMA public' => { |
| 4545 | + all_runs => 1, |
| 4546 | + catch_all => 'CREATE ... commands', |
| 4547 | + regexp => qr/^CREATE SCHEMA public;/m, |
| 4548 | + like => { |
| 4549 | + clean => 1, |
| 4550 | + clean_if_exists => 1, }, |
| 4551 | + unlike => { |
| 4552 | + binary_upgrade => 1, |
| 4553 | + createdb => 1, |
| 4554 | + defaults => 1, |
| 4555 | + exclude_test_table => 1, |
| 4556 | + exclude_test_table_data => 1, |
| 4557 | + no_blobs => 1, |
| 4558 | + no_privs => 1, |
| 4559 | + no_owner => 1, |
| 4560 | + only_dump_test_schema => 1, |
| 4561 | + pg_dumpall_dbprivs => 1, |
| 4562 | + schema_only => 1, |
| 4563 | + section_pre_data => 1, |
| 4564 | + test_schema_plus_blobs => 1, |
| 4565 | + with_oids => 1, |
| 4566 | + exclude_dump_test_schema => 1, |
| 4567 | + only_dump_test_table => 1, |
| 4568 | + pg_dumpall_globals => 1, |
| 4569 | + pg_dumpall_globals_clean => 1, |
| 4570 | + role => 1, |
| 4571 | + section_post_data => 1, }, }, |
| 4572 | +
|
4527 | 4573 | 'CREATE SCHEMA dump_test' => {
|
4528 | 4574 | all_runs => 1,
|
4529 | 4575 | catch_all => 'CREATE ... commands',
|
|
5219 | 5265 | data_only => 1,
|
5220 | 5266 | section_data => 1, }, },
|
5221 | 5267 |
|
| 5268 | + 'DROP SCHEMA public (for testing without public schema)' => { |
| 5269 | + all_runs => 1, |
| 5270 | + database => 'regress_pg_dump_test', |
| 5271 | + create_order => 100, |
| 5272 | + create_sql => 'DROP SCHEMA public;', |
| 5273 | + regexp => qr/^DROP SCHEMA public;/m, |
| 5274 | + like => { }, |
| 5275 | + unlike => { defaults_no_public => 1, |
| 5276 | + defaults_no_public_clean => 1, } }, |
| 5277 | +
|
| 5278 | + 'DROP SCHEMA public' => { |
| 5279 | + all_runs => 1, |
| 5280 | + catch_all => 'DROP ... commands', |
| 5281 | + regexp => qr/^DROP SCHEMA public;/m, |
| 5282 | + like => { clean => 1 }, |
| 5283 | + unlike => { |
| 5284 | + clean_if_exists => 1, |
| 5285 | + pg_dumpall_globals_clean => 1, }, }, |
| 5286 | +
|
| 5287 | + 'DROP SCHEMA IF EXISTS public' => { |
| 5288 | + all_runs => 1, |
| 5289 | + catch_all => 'DROP ... commands', |
| 5290 | + regexp => qr/^DROP SCHEMA IF EXISTS public;/m, |
| 5291 | + like => { clean_if_exists => 1 }, |
| 5292 | + unlike => { |
| 5293 | + clean => 1, |
| 5294 | + pg_dumpall_globals_clean => 1, }, }, |
| 5295 | +
|
5222 | 5296 | 'DROP EXTENSION plpgsql' => {
|
5223 | 5297 | all_runs => 1,
|
5224 | 5298 | catch_all => 'DROP ... commands',
|
|
6433 | 6507 | $collation_support = 1;
|
6434 | 6508 | }
|
6435 | 6509 |
|
| 6510 | +# Create a second database for certain tests to work against |
| 6511 | +$node->psql('postgres','create database regress_pg_dump_test;'); |
| 6512 | +
|
6436 | 6513 | # Start with number of command_fails_like()*2 tests below (each
|
6437 | 6514 | # command_fails_like is actually 2 tests)
|
6438 | 6515 | my $num_tests = 12;
|
6439 | 6516 |
|
6440 | 6517 | foreach my $run (sort keys %pgdump_runs)
|
6441 | 6518 | {
|
6442 | 6519 | my $test_key = $run;
|
| 6520 | + my $run_db = 'postgres'; |
| 6521 | +
|
| 6522 | + if (defined($pgdump_runs{$run}->{database})) { |
| 6523 | + $run_db = $pgdump_runs{$run}->{database}; |
| 6524 | + } |
6443 | 6525 |
|
6444 | 6526 | # Each run of pg_dump is a test itself
|
6445 | 6527 | $num_tests++;
|
|
6458 | 6540 | # Then count all the tests run against each run
|
6459 | 6541 | foreach my $test (sort keys %tests)
|
6460 | 6542 | {
|
| 6543 | + # postgres is the default database, if it isn't overridden |
| 6544 | + my $test_db = 'postgres'; |
| 6545 | +
|
| 6546 | + # Specific tests can override the database to use |
| 6547 | + if (defined($tests{$test}->{database})) { |
| 6548 | + $test_db = $tests{$test}->{database}; |
| 6549 | + } |
| 6550 | +
|
| 6551 | + # The database to test against needs to match the database the run is |
| 6552 | + # for, so skip combinations where they don't match up. |
| 6553 | + if ($run_db ne $test_db) { |
| 6554 | + next; |
| 6555 | + } |
6461 | 6556 |
|
6462 | 6557 | # Skip any collation-related commands if there is no collation support
|
6463 | 6558 | if (!$collation_support && defined($tests{$test}->{collation}))
|
|
6507 | 6602 | # Set up schemas, tables, etc, to be dumped.
|
6508 | 6603 |
|
6509 | 6604 | # Build up the create statements
|
6510 |
| -my $create_sql = ''; |
| 6605 | +my %create_sql = (); |
6511 | 6606 |
|
6512 | 6607 | foreach my $test (
|
6513 | 6608 | sort {
|
|
6529 | 6624 | }
|
6530 | 6625 | } keys %tests)
|
6531 | 6626 | {
|
| 6627 | + my $test_db = 'postgres'; |
| 6628 | +
|
| 6629 | + if (defined($tests{$test}->{database})) { |
| 6630 | + $test_db = $tests{$test}->{database}; |
| 6631 | + } |
| 6632 | +
|
6532 | 6633 | if ($tests{$test}->{create_sql})
|
6533 | 6634 | {
|
6534 | 6635 |
|
|
6539 | 6640 | }
|
6540 | 6641 |
|
6541 | 6642 | # Add terminating semicolon
|
6542 |
| - $create_sql .= $tests{$test}->{create_sql} . ";"; |
| 6643 | + $create_sql{$test_db} .= $tests{$test}->{create_sql} . ";"; |
6543 | 6644 | }
|
6544 | 6645 | }
|
6545 | 6646 |
|
6546 | 6647 | # Send the combined set of commands to psql
|
6547 |
| -$node->safe_psql('postgres', $create_sql); |
| 6648 | +foreach my $db (sort keys %create_sql) |
| 6649 | +{ |
| 6650 | + $node->safe_psql($db, $create_sql{$db}); |
| 6651 | +} |
6548 | 6652 |
|
6549 | 6653 | #########################################
|
6550 | 6654 | # Test connecting to a non-existent database
|
|
0 commit comments