aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 796a0aa7168..17a3050c30a 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -3268,15 +3268,22 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData, bool acl_pass)
/*
* Avoid dumping the public schema, as it will already be created ...
- * unless we are using --clean mode, in which case it's been deleted and
- * we'd better recreate it. Likewise for its comment, if any.
+ * unless we are using --clean mode (and *not* --create mode), in which
+ * case we've previously issued a DROP for it so we'd better recreate it.
+ *
+ * Likewise for its comment, if any. (We could try issuing the COMMENT
+ * command anyway; but it'd fail if the restore is done as non-super-user,
+ * so let's not.)
+ *
+ * XXX it looks pretty ugly to hard-wire the public schema like this, but
+ * it sits in a sort of no-mans-land between being a system object and a
+ * user object, so it really is special in a way.
*/
- if (!ropt->dropSchema)
+ if (!(ropt->dropSchema && !ropt->createDB))
{
if (strcmp(te->desc, "SCHEMA") == 0 &&
strcmp(te->tag, "public") == 0)
return;
- /* The comment restore would require super-user privs, so avoid it. */
if (strcmp(te->desc, "COMMENT") == 0 &&
strcmp(te->tag, "SCHEMA public") == 0)
return;