git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9f1ca6c)
Avoid harmless warning from pg_dump --if-exists mode.
2023年1月20日 00:32:46 +0000 (19:32 -0500)
2023年1月20日 00:32:50 +0000 (19:32 -0500)
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
a7a7be1f2, 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


diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 7f7a0f1ce7b8db6fac21d08be4288555370e28ff..ba5e6acbbb8bab3b6d5d1ca2fca1439524230c7e 100644 (file)
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -538,9 +538,14 @@ RestoreArchive(Archive *AHX)
*/
if (*te->dropStmt != '0円')
{
- if (!ropt->if_exists)
+ if (!ropt->if_exists ||
+ strncmp(te->dropStmt, "--", 2) == 0)
{
- /* No --if-exists? Then just use the original */
+ /*
+ * Without --if-exists, or if it's just a comment (as
+ * happens for the public schema), print the dropStmt
+ * as-is.
+ */
ahprintf(AH, "%s", te->dropStmt);
}
else
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /