aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2017-06-28 10:34:01 -0400
committerStephen Frost <sfrost@snowman.net>2017-06-28 10:34:01 -0400
commita2de017b30157c99e33cbc6457140e062a5ca26f (patch)
tree103f923c50b88eeba193690341d9726b2f3aa925
parent55968ed89496d215e86abf0b913b0464cac90edf (diff)
downloadpostgresql-a2de017b30157c99e33cbc6457140e062a5ca26f.tar.gz
postgresql-a2de017b30157c99e33cbc6457140e062a5ca26f.zip
Do not require 'public' to exist for pg_dump -c
Commit 330b84d8c4 didn't contemplate the case where the public schema has been dropped and introduced a query which fails when there is no public schema into pg_dump (when used with -c). Adjust the query used by pg_dump to handle the case where the public schema doesn't exist and add tests to check that such a case no longer fails. Back-patch the specific fix to 9.6, as the prior commit was. Adding tests for this case involved adding support to the pg_dump TAP tests to work with multiple databases, which, while not a large change, is a bit much to back-patch, so that's only done in master. Addresses bug #14650 Discussion: https://www.postgresql.org/message-id/20170512181801.1795.47483%40wrigleys.postgresql.org
-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,") ");