appendPQExpBuffer(&sql, ";\n");
+ /*
+ * Connect to the 'postgres' database by default, except have
+ * the 'postgres' user use 'template1' so he can create the
+ * 'postgres' database.
+ */
conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres",
host, port, username, prompt_password, progname);
}
PQclear(result);
- PQfinish(conn);
if (comment)
{
- conn = connectDatabase(dbname, host, port, username, prompt_password, progname);
-
printfPQExpBuffer(&sql, "COMMENT ON DATABASE %s IS ", fmtId(dbname));
appendStringLiteralConn(&sql, comment, conn);
appendPQExpBuffer(&sql, ";\n");
}
PQclear(result);
- PQfinish(conn);
}
+ PQfinish(conn);
+
exit(0);
}
appendPQExpBuffer(&sql, "DROP DATABASE %s;\n",
fmtId(dbname));
+ /*
+ * Connect to the 'postgres' database by default, except have
+ * the 'postgres' user use 'template1' so he can drop the
+ * 'postgres' database.
+ */
conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres",
host, port, username, prompt_password, progname);