aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_dump/pg_dump.c22
-rw-r--r--src/bin/pg_dump/t/002_pg_dump.pl26
2 files changed, 45 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 0e41817d7ac..1148d6a1640 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3638,13 +3638,33 @@ getNamespaces(Archive *fout, int *numNamespaces)
"LEFT JOIN pg_init_privs pip "
"ON (n.oid = pip.objoid "
"AND pip.classoid = 'pg_namespace'::regclass "
- "AND pip.objsubid = 0) ",
+ "AND pip.objsubid = 0",
username_subquery,
acl_subquery->data,
racl_subquery->data,
init_acl_subquery->data,
init_racl_subquery->data);
+ /*
+ * When we are doing a 'clean' run, we will be dropping and recreating
+ * the 'public' schema (the only object which has that kind of
+ * treatment in the backend and which has an entry in pg_init_privs)
+ * and therefore we should not consider any initial privileges in
+ * pg_init_privs in that case.
+ *
+ * See pg_backup_archiver.c:_printTocEntry() for the details on why
+ * the public schema is special in this regard.
+ *
+ * Note that if the public schema is dropped and re-created, this is
+ * essentially a no-op because the new public schema won't have an
+ * entry in pg_init_privs anyway, as the entry will be removed when
+ * the public schema is dropped.
+ */
+ if (dopt->outputClean)
+ appendPQExpBuffer(query," AND pip.objoid <> 'public'::regnamespace");
+
+ appendPQExpBuffer(query,") ");
+
destroyPQExpBuffer(acl_subquery);
destroyPQExpBuffer(racl_subquery);
destroyPQExpBuffer(init_acl_subquery);
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index bb2ea34ccbe..1f8db16cf16 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2443,6 +2443,28 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
only_dump_test_schema => 1,
only_dump_test_table => 1,
test_schema_plus_blobs => 1, }, },
+ 'GRANT USAGE ON SCHEMA public TO public' => {
+ regexp => qr/^
+ \Q--\E\n\n
+ \QGRANT USAGE ON SCHEMA public TO PUBLIC;\E
+ /xm,
+ like => {
+ clean => 1,
+ clean_if_exists => 1, },
+ unlike => {
+ binary_upgrade => 1,
+ createdb => 1,
+ defaults => 1,
+ exclude_dump_test_schema => 1,
+ exclude_test_table => 1,
+ exclude_test_table_data => 1,
+ no_owner => 1,
+ pg_dumpall_dbprivs => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ only_dump_test_schema => 1,
+ only_dump_test_table => 1,
+ test_schema_plus_blobs => 1, }, },
'GRANT commands' => { # catch-all for GRANT commands
regexp => qr/^GRANT /m,
like => {}, # use more-specific options above
@@ -2576,8 +2598,6 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
/xm,
like => {
binary_upgrade => 1,
- clean => 1,
- clean_if_exists => 1,
createdb => 1,
defaults => 1,
exclude_dump_test_schema => 1,
@@ -2588,6 +2608,8 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
schema_only => 1,
section_pre_data => 1, },
unlike => {
+ clean => 1,
+ clean_if_exists => 1,
only_dump_test_schema => 1,
only_dump_test_table => 1,
test_schema_plus_blobs => 1, }, },