aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_dump/pg_dump.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 27a2a0c0a52..d1db3702bea 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3659,9 +3659,14 @@ getNamespaces(Archive *fout, int *numNamespaces)
* 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.
+ *
+ * Further, we have to handle the case where the public schema does
+ * not exist at all.
*/
if (dopt->outputClean)
- appendPQExpBuffer(query," AND pip.objoid <> 'public'::regnamespace");
+ appendPQExpBuffer(query," AND pip.objoid <> "
+ "coalesce((select oid from pg_namespace "
+ "where nspname = 'public'),0)");
appendPQExpBuffer(query,") ");