From ff29917ff0802ef51d42ff8d4ae461b2aa2fcfff Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Fri, 10 Apr 2020 19:54:29 +0000 Subject: [PATCH v1 1/1] Do not consider pg_init_privs entries when dumping renamed system schemas. --- src/bin/pg_dump/pg_dump.c | 2 ++ src/bin/pg_dump/t/002_pg_dump.pl | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index c579227b19..3070fe17e1 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -4715,6 +4715,8 @@ getNamespaces(Archive *fout, int *numNamespaces) "FROM pg_namespace n " "LEFT JOIN pg_init_privs pip " "ON (n.oid = pip.objoid " + "AND (pip.objoid IN (SELECT oid FROM pg_namespace WHERE nspname IN ('public', 'pg_catalog')) " + "OR pip.privtype != 'i') " "AND pip.classoid = 'pg_namespace'::regclass " "AND pip.objsubid = 0", username_subquery, diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 1b90cbd9b5..3bf6f5d57a 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -268,6 +268,15 @@ my %pgdump_runs = ( 'postgres', ], }, + renamed_default_schema => { + database => 'renamed_default_schema', + dump_cmd => [ + 'pg_dump', + '--no-sync', + "--file=$tempdir/renamed_default_schema.sql", + 'renamed_default_schema', + ], + }, role => { dump_cmd => [ 'pg_dump', @@ -3037,6 +3046,14 @@ my %tests = ( }, }, + 'GRANT ALL ON renamed_public_schema TO public' => { + database => 'renamed_default_schema', + create_order => 100, + create_sql => 'ALTER SCHEMA public RENAME TO renamed_public_schema;', + regexp => qr/^GRANT ALL ON SCHEMA renamed_public_schema TO PUBLIC;/m, + like => { renamed_default_schema => 1, }, + }, + 'GRANT INSERT(col1) ON TABLE test_second_table' => { create_order => 8, create_sql => @@ -3322,8 +3339,9 @@ if ($collation_check_stderr !~ /ERROR: /) $collation_support = 1; } -# Create a second database for certain tests to work against +# Create extra databases for certain tests to work against $node->psql('postgres', 'create database regress_pg_dump_test;'); +$node->psql('postgres', 'create database renamed_default_schema;'); # Start with number of command_fails_like()*2 tests below (each # command_fails_like is actually 2 tests) -- 2.16.6