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

Appearance settings

Commit 74739d1

Browse filesBrowse files
committed
Avoid harmless warning from pg_dump --if-exists mode.
If the public schema has a non-default owner (perhaps due to dropping and recreating it) then use of pg_dump's "--if-exists" option results in a warning message: warning: could not find where to insert IF EXISTS in statement "-- *not* dropping schema, since initdb creates it" This is harmless since the dump output is the same either way, but nonetheless it's undesirable. It's the fault of commit a7a7be1, which created situations where a TOC entry's "defn" or "dropStmt" fields could be just comments. Although that commit fixed up the kluges in pg_backup_archiver.c that munge defn strings, it missed doing so for the one that munges dropStmts. Per bug# 17753 from Justin Zhang. Discussion: https://postgr.es/m/17753-9c8773631747ee1c@postgresql.org
1 parent 9f1ca6c commit 74739d1
Copy full SHA for 74739d1

File tree

1 file changed

+7
-2
lines changed
Filter options

1 file changed

+7
-2
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Copy file name to clipboardExpand all lines: src/bin/pg_dump/pg_backup_archiver.c
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,14 @@ RestoreArchive(Archive *AHX)
538538
*/
539539
if (*te->dropStmt != '\0')
540540
{
541-
if (!ropt->if_exists)
541+
if (!ropt->if_exists ||
542+
strncmp(te->dropStmt, "--", 2) == 0)
542543
{
543-
/* No --if-exists? Then just use the original */
544+
/*
545+
* Without --if-exists, or if it's just a comment (as
546+
* happens for the public schema), print the dropStmt
547+
* as-is.
548+
*/
544549
ahprintf(AH, "%s", te->dropStmt);
545550
}
546551
else

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.