]> granicus.if.org Git - postgresql/commit
Fix pg_dump's handling of public schema with both -c and -C options.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 2 Aug 2016 16:48:51 +0000 (12:48 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 2 Aug 2016 16:49:41 +0000 (12:49 -0400)
commit89c30d1133be5ba4da6098da2ee12114e527f03b
tree3f45a179acf9c67e8421417a1b9fdf4f4d30dddd
parentb2148e176f28ad3a7e468742b27eb6fdff348b9a
Fix pg_dump's handling of public schema with both -c and -C options.

Since -c plus -C requests dropping and recreating the target database
as a whole, not dropping individual objects in it, we should assume that
the public schema already exists and need not be created.  The previous
coding considered only the state of the -c option, so it would emit
"CREATE SCHEMA public" anyway, leading to an unexpected error in restore.

Back-patch to 9.2.  Older versions did not accept -c with -C so the
issue doesn't arise there.  (The logic being patched here dates to 8.0,
cf commit 2193121fa, so it's not really wrong that it didn't consider
the case at the time.)

Note that versions before 9.6 will still attempt to emit REVOKE/GRANT
on the public schema; but that happens without -c/-C too, and doesn't
seem to be the focus of this complaint.  I considered extending this
stanza to also skip the public schema's ACL, but that would be a
misfeature, as it'd break cases where users intentionally changed that
ACL.  The real fix for this aspect is Stephen Frost's work to not dump
built-in ACLs, and that's not going to get back-ported.

Per bugs #13804 and #14271.  Solution found by David Johnston and later
rediscovered by me.

Report: <20151207163520.2628.95990@wrigleys.postgresql.org>
Report: <20160801021955.1430.47434@wrigleys.postgresql.org>
src/bin/pg_dump/pg_backup_archiver.c