Skip to content

Commit a2de017

Browse files
committed
Do not require 'public' to exist for pg_dump -c
Commit 330b84d 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
1 parent 55968ed commit a2de017

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3659,9 +3659,14 @@ getNamespaces(Archive *fout, int *numNamespaces)
36593659
* essentially a no-op because the new public schema won't have an
36603660
* entry in pg_init_privs anyway, as the entry will be removed when
36613661
* the public schema is dropped.
3662+
*
3663+
* Further, we have to handle the case where the public schema does
3664+
* not exist at all.
36623665
*/
36633666
if (dopt->outputClean)
3664-
appendPQExpBuffer(query," AND pip.objoid <> 'public'::regnamespace");
3667+
appendPQExpBuffer(query," AND pip.objoid <> "
3668+
"coalesce((select oid from pg_namespace "
3669+
"where nspname = 'public'),0)");
36653670

36663671
appendPQExpBuffer(query,") ");
36673672

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy