diff options
Diffstat (limited to 'src/bin/scripts/dropdb.c')
-rw-r--r-- | src/bin/scripts/dropdb.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c index 57656ba8988..435837b65ff 100644 --- a/src/bin/scripts/dropdb.c +++ b/src/bin/scripts/dropdb.c @@ -129,13 +129,6 @@ main(int argc, char *argv[]) exit(0); } - initPQExpBuffer(&sql); - - appendPQExpBuffer(&sql, "DROP DATABASE %s%s%s;", - (if_exists ? "IF EXISTS " : ""), - fmtId(dbname), - force ? " WITH (FORCE)" : ""); - /* Avoid trying to drop postgres db while we are connected to it. */ if (maintenance_db == NULL && strcmp(dbname, "postgres") == 0) maintenance_db = "template1"; @@ -149,6 +142,12 @@ main(int argc, char *argv[]) conn = connectMaintenanceDatabase(&cparams, progname, echo); + initPQExpBuffer(&sql); + appendPQExpBuffer(&sql, "DROP DATABASE %s%s%s;", + (if_exists ? "IF EXISTS " : ""), + fmtIdEnc(dbname, PQclientEncoding(conn)), + force ? " WITH (FORCE)" : ""); + if (echo) printf("%s\n", sql.data); result = PQexec(conn, sql.data); |