diff options
| author | Michael Paquier | 2021-03-31 00:12:34 +0000 |
|---|---|---|
| committer | Michael Paquier | 2021-03-31 00:12:34 +0000 |
| commit | 6568cef26e0f40c25ae54b8e20aad8d1410a854b (patch) | |
| tree | 406b7986ec4939efef7ae24712dc0df5be1cadc8 /src/test | |
| parent | 65158f497a7d7523ad438b2034d01a560fafe6bd (diff) | |
Add support for --extension in pg_dump
When specified, only extensions matching the given pattern are included
in dumps. Similarly to --table and --schema, when --strict-names is
used, a perfect match is required. Also, like the two other options,
this new option offers no guarantee that dependent objects have been
dumped, so a restore may fail on a clean database.
Tests are added in test_pg_dump/, checking after a set of positive and
negative cases, with or without an extension's contents added to the
dump generated.
Author: Guillaume Lelarge
Reviewed-by: David Fetter, Tom Lane, Michael Paquier, Asif Rehman,
Julien Rouhaud
Discussion: https://postgr.es/m/CAECtzeXOt4cnMU5+XMZzxBPJ_wu76pNy6HZKPRBL-j7yj1E4+g@mail.gmail.com
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/modules/test_pg_dump/t/001_base.pl | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index 501aff09201..7c053c4e49d 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -194,6 +194,20 @@ my %pgdump_runs = ( 'pg_dump', '--no-sync', "--file=$tempdir/section_post_data.sql", '--section=post-data', 'postgres', ], + }, + with_extension => { + dump_cmd => [ + 'pg_dump', '--no-sync', "--file=$tempdir/with_extension.sql", + '--extension=test_pg_dump', '--no-sync', 'postgres', + ], + }, + + # plgsql in the list blocks the dump of extension test_pg_dump + without_extension => { + dump_cmd => [ + 'pg_dump', '--no-sync', "--file=$tempdir/without_extension.sql", + '--extension=plpgsql', '--no-sync', 'postgres', + ], },); ############################################################### @@ -228,14 +242,16 @@ my %pgdump_runs = ( # Tests which are considered 'full' dumps by pg_dump, but there # are flags used to exclude specific items (ACLs, blobs, etc). my %full_runs = ( - binary_upgrade => 1, - clean => 1, - clean_if_exists => 1, - createdb => 1, - defaults => 1, - exclude_table => 1, - no_privs => 1, - no_owner => 1,); + binary_upgrade => 1, + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + exclude_table => 1, + no_privs => 1, + no_owner => 1, + with_extension => 1, + without_extension => 1); my %tests = ( 'ALTER EXTENSION test_pg_dump' => { @@ -261,7 +277,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { binary_upgrade => 1, }, + unlike => { binary_upgrade => 1, without_extension => 1 }, }, 'CREATE ROLE regress_dump_test_role' => { @@ -320,6 +336,7 @@ my %tests = ( section_data => 1, extension_schema => 1, }, + unlike => { without_extension => 1, }, }, 'CREATE TABLE regress_pg_dump_table' => { @@ -343,8 +360,9 @@ my %tests = ( extension_schema => 1, }, unlike => { - binary_upgrade => 1, - exclude_table => 1, + binary_upgrade => 1, + exclude_table => 1, + without_extension => 1, }, }, @@ -367,7 +385,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { no_privs => 1, }, + unlike => { no_privs => 1, without_extension => 1, }, }, 'REVOKE GRANT OPTION FOR UPDATE ON SEQUENCE wgo_then_regular' => { @@ -384,7 +402,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { no_privs => 1, }, + unlike => { no_privs => 1, without_extension => 1, }, }, 'CREATE ACCESS METHOD regress_test_am' => { @@ -404,6 +422,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, + unlike => { without_extension => 1, }, }, 'GRANT SELECT regress_pg_dump_table_added pre-ALTER EXTENSION' => { @@ -428,7 +447,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { no_privs => 1, }, + unlike => { no_privs => 1, without_extension => 1, }, }, 'GRANT SELECT ON TABLE regress_pg_dump_table' => { @@ -462,7 +481,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { no_privs => 1, }, + unlike => { no_privs => 1, without_extension => 1 }, }, 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' @@ -478,7 +497,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { no_privs => 1, }, + unlike => { no_privs => 1, without_extension => 1, }, }, 'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => { @@ -500,7 +519,7 @@ my %tests = ( schema_only => 1, section_pre_data => 1, }, - unlike => { no_privs => 1, }, + unlike => { no_privs => 1, without_extension => 1, }, }, # Objects included in extension part of a schema created by this extension */ |
