Commit b49d871f authored by Tom Lane's avatar Tom Lane

Fix pg_dumpall to do the right thing with "postgres" database, per

Dave Page.  Also, cause it to emit rather than ignore any ACL and
datconfig options that may be set for these two databases.
parent 6f7fc0ba
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.60 2005/06/21 04:02:32 tgl Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.61 2005/06/21 15:22:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -303,7 +303,7 @@ main(int argc, char *argv[])
if (verbose)
dumpTimestamp("Started on");
printf("\\connect \"postgres\"\n\n");
printf("\\connect postgres\n\n");
if (!data_only)
{
......@@ -661,14 +661,17 @@ dumpCreateDB(PGconn *conn)
char *dbtablespace = PQgetvalue(res, i, 5);
char *fdbname;
if (strcmp(dbname, "template1") == 0)
continue;
buf = createPQExpBuffer();
/* needed for buildACLCommands() */
fdbname = strdup(fmtId(dbname));
/*
* Skip the CREATE DATABASE commands for "template1" and "postgres",
* since they are presumably already there in the destination cluster.
* We do want to emit their ACLs and config options if any, however.
*/
if (strcmp(dbname, "template1") != 0 &&
strcmp(dbname, "postgres") != 0)
{
if (output_clean)
appendPQExpBuffer(buf, "DROP DATABASE %s;\n", fdbname);
......@@ -677,8 +680,7 @@ dumpCreateDB(PGconn *conn)
appendPQExpBuffer(buf, " WITH TEMPLATE = template0");
if (strlen(dbowner) != 0)
appendPQExpBuffer(buf, " OWNER = %s",
fmtId(dbowner));
appendPQExpBuffer(buf, " OWNER = %s", fmtId(dbowner));
appendPQExpBuffer(buf, " ENCODING = ");
appendStringLiteral(buf, dbencoding, true);
......@@ -696,6 +698,7 @@ dumpCreateDB(PGconn *conn)
appendStringLiteral(buf, dbname, true);
appendPQExpBuffer(buf, ";\n");
}
}
if (!skip_acls &&
!buildACLCommands(fdbname, "DATABASE", dbacl, dbowner,
......@@ -708,11 +711,12 @@ dumpCreateDB(PGconn *conn)
}
printf("%s", buf->data);
destroyPQExpBuffer(buf);
free(fdbname);
if (server_version >= 70300)
dumpDatabaseConfig(conn, dbname);
destroyPQExpBuffer(buf);
free(fdbname);
}
PQclear(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment