1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Cause initdb to create a third standard database "postgres", which

unlike template0 and template1 does not have any special status in
terms of backend functionality.  However, all external utilities such
as createuser and createdb now connect to "postgres" instead of
template1, and the documentation is changed to encourage people to use
"postgres" instead of template1 as a play area.  This should fix some
longstanding gotchas involving unexpected propagation of database
objects by createdb (when you used template1 without understanding
the implications), as well as ameliorating the problem that CREATE
DATABASE is unhappy if anyone else is connected to template1.
Patch by Dave Page, minor editing by Tom Lane.  All per recent
pghackers discussions.
This commit is contained in:
Tom Lane
2005-06-21 04:02:34 +00:00
parent ec3a1af0a8
commit 6f7fc0bade
38 changed files with 167 additions and 107 deletions

View File

@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.14 2004/12/31 22:03:17 pgsql Exp $
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.15 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -117,7 +117,8 @@ main(int argc, char *argv[])
appendPQExpBuffer(&sql, "DROP DATABASE %s;\n",
fmtId(dbname));
conn = connectDatabase("template1", host, port, username, password, progname);
conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres",
host, port, username, password, progname);
if (echo)
printf("%s", sql.data);