Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6693c9d

Browse files
committed
Fix pg_dump's handling of public schema with both -c and -C options.
Since -c plus -C requests dropping and recreating the target databaseas a whole, not dropping individual objects in it, we should assume thatthe public schema already exists and need not be created. The previouscoding 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 theissue doesn't arise there. (The logic being patched here dates to 8.0,cf commit2193121, so it's not really wrong that it didn't considerthe case at the time.)Note that versions before 9.6 will still attempt to emit REVOKE/GRANTon the public schema; but that happens without -c/-C too, and doesn'tseem to be the focus of this complaint. I considered extending thisstanza to also skip the public schema's ACL, but that would be amisfeature, as it'd break cases where users intentionally changed thatACL. The real fix for this aspect is Stephen Frost's work to not dumpbuilt-in ACLs, and that's not going to get back-ported.Per bugs #13804 and #14271. Solution found by David Johnston and laterrediscovered by me.Report: <20151207163520.2628.95990@wrigleys.postgresql.org>Report: <20160801021955.1430.47434@wrigleys.postgresql.org>
1 parent3ca3594 commit6693c9d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,15 +3008,22 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
30083008

30093009
/*
30103010
* Avoid dumping the public schema, as it will already be created ...
3011-
* unless we are using --clean mode, in which case it's been deleted and
3012-
* we'd better recreate it. Likewise for its comment, if any.
3011+
* unless we are using --clean mode (and *not* --create mode), in which
3012+
* case we've previously issued a DROP for it so we'd better recreate it.
3013+
*
3014+
* Likewise for its comment, if any. (We could try issuing the COMMENT
3015+
* command anyway; but it'd fail if the restore is done as non-super-user,
3016+
* so let's not.)
3017+
*
3018+
* XXX it looks pretty ugly to hard-wire the public schema like this, but
3019+
* it sits in a sort of no-mans-land between being a system object and a
3020+
* user object, so it really is special in a way.
30133021
*/
3014-
if (!ropt->dropSchema)
3022+
if (!(ropt->dropSchema&& !ropt->createDB))
30153023
{
30163024
if (strcmp(te->desc,"SCHEMA")==0&&
30173025
strcmp(te->tag,"public")==0)
30183026
return;
3019-
/* The comment restore would require super-user privs, so avoid it. */
30203027
if (strcmp(te->desc,"COMMENT")==0&&
30213028
strcmp(te->tag,"SCHEMA public")==0)
30223029
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp