aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/dbcommands.c4
-rw-r--r--src/bin/initdb/initdb.c49
-rw-r--r--src/bin/pg_ctl/pg_ctl.c4
-rw-r--r--src/bin/pg_dump/pg_dumpall.c8
-rw-r--r--src/bin/psql/startup.c4
-rw-r--r--src/bin/scripts/clusterdb.c4
-rw-r--r--src/bin/scripts/createdb.c5
-rw-r--r--src/bin/scripts/createuser.c4
-rw-r--r--src/bin/scripts/dropdb.c5
-rw-r--r--src/bin/scripts/dropuser.c4
-rw-r--r--src/bin/scripts/vacuumdb.c4
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/interfaces/ecpg/test/testdynalloc.pgc2
-rw-r--r--src/interfaces/libpq/pg_service.conf.sample6
-rwxr-xr-xsrc/test/bench/create.sh6
-rw-r--r--src/test/examples/testlibpq.c4
-rw-r--r--src/test/examples/testlibpq2.c4
-rw-r--r--src/test/examples/testlibpq3.c4
-rw-r--r--src/test/regress/pg_regress.sh4
19 files changed, 84 insertions, 45 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 40cfb3e6586..135c8a73f53 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.159 2005/06/06 20:22:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.160 2005/06/21 04:02:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -93,7 +93,7 @@ createdb(const CreatedbStmt *stmt)
DefElem *dencoding = NULL;
char *dbname = stmt->dbname;
char *dbowner = NULL;
- char *dbtemplate = NULL;
+ const char *dbtemplate = NULL;
int encoding = -1;
#ifndef WIN32
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 9e42c902f1c..dd830f7c037 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -8,14 +8,19 @@
*
* To create the database cluster, we create the directory that contains
* all its data, create the files that hold the global tables, create
- * a few other control files for it, and create two databases: the
- * template0 and template1 databases.
+ * a few other control files for it, and create three databases: the
+ * template databases "template0" and "template1", and a default user
+ * database "postgres".
*
* The template databases are ordinary PostgreSQL databases. template0
* is never supposed to change after initdb, whereas template1 can be
* changed to add site-local standard data. Either one can be copied
* to produce a new database.
*
+ * For largely-historical reasons, the template1 database is the one built
+ * by the basic bootstrap process. After it is complete, template0 and
+ * the default database, postgres, are made just by copying template1.
+ *
* To create template1, we run the postgres (backend) program in bootstrap
* mode and feed it data from the postgres.bki library file. After this
* initial bootstrap phase, some additional stuff is created by normal
@@ -23,12 +28,10 @@
* just embedded into this program (yeah, it's ugly), but larger chunks
* are taken from script files.
*
- * template0 is made just by copying the completed template1.
*
* Note:
* The program has some memory leakage - it isn't worth cleaning it up.
*
- *
* This is a C implementation of the previous shell script for setting up a
* PostgreSQL cluster location, and should be highly compatible with it.
* author of C translation: Andrew Dunstan mailto:andrew@dunslane.net
@@ -39,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.84 2005/06/17 22:32:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.85 2005/06/21 04:02:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -178,6 +181,7 @@ static void set_info_version(void);
static void setup_schema(void);
static void vacuum_db(void);
static void make_template0(void);
+static void make_postgres(void);
static void trapsig(int signum);
static void check_ok(void);
static char *escape_quotes(const char *src);
@@ -1846,7 +1850,7 @@ make_template0(void)
* We use the OID of template0 to determine lastsysoid
*/
"UPDATE pg_database SET datlastsysoid = "
- " (SELECT oid::int4 - 1 FROM pg_database "
+ " (SELECT oid FROM pg_database "
" WHERE datname = 'template0');\n",
/*
@@ -1882,6 +1886,37 @@ make_template0(void)
check_ok();
}
+/*
+ * copy template1 to postgres
+ */
+static void
+make_postgres(void)
+{
+ PG_CMD_DECL;
+ char **line;
+ static char *postgres_setup[] = {
+ "CREATE DATABASE postgres;\n",
+ NULL
+ };
+
+ fputs(_("copying template1 to postgres ... "), stdout);
+ fflush(stdout);
+
+ snprintf(cmd, sizeof(cmd),
+ "\"%s\" %s template1 >%s",
+ backend_exec, backend_options,
+ DEVNULL);
+
+ PG_CMD_OPEN;
+
+ for (line = postgres_setup; *line; line++)
+ PG_CMD_PUTS(*line);
+
+ PG_CMD_CLOSE;
+
+ check_ok();
+}
+
/*
* signal handler in case we are interrupted.
@@ -2609,6 +2644,8 @@ main(int argc, char *argv[])
make_template0();
+ make_postgres();
+
if (authwarning != NULL)
fprintf(stderr, "%s", authwarning);
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 30c95d13213..31547cbbf04 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.57 2005/05/04 22:35:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.58 2005/06/21 04:02:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -442,7 +442,7 @@ test_postmaster_connection(void)
for (i = 0; i < wait_seconds; i++)
{
if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
- "template1", NULL, NULL)) != NULL &&
+ "postgres", NULL, NULL)) != NULL &&
(PQstatus(conn) == CONNECTION_OK ||
(strcmp(PQerrorMessage(conn),
PQnoPasswordSupplied) == 0)))
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 07a08c41d83..0ed8b921b89 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -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.59 2005/04/18 23:47:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.60 2005/06/21 04:02:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -297,13 +297,13 @@ main(int argc, char *argv[])
}
- conn = connectDatabase("template1", pghost, pgport, pguser, force_password);
+ conn = connectDatabase("postgres", pghost, pgport, pguser, force_password);
printf("--\n-- PostgreSQL database cluster dump\n--\n\n");
if (verbose)
dumpTimestamp("Started on");
- printf("\\connect \"template1\"\n\n");
+ printf("\\connect \"postgres\"\n\n");
if (!data_only)
{
@@ -880,7 +880,7 @@ runPgDump(const char *dbname)
/*
* Win32 has to use double-quotes for args, rather than single quotes.
* Strangely enough, this is the only place we pass a database name on
- * the command line, except template1 that doesn't need quoting.
+ * the command line, except "postgres" which doesn't need quoting.
*/
#ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index ff8a5c2431b..9caecbe4498 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.117 2005/06/14 02:57:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.118 2005/06/21 04:02:33 tgl Exp $
*/
#include "postgres_fe.h"
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
{
need_pass = false;
pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
- options.action == ACT_LIST_DB ? "template1" : options.dbname,
+ options.action == ACT_LIST_DB ? "postgres" : options.dbname,
username, password);
if (PQstatus(pset.db) == CONNECTION_BAD &&
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c
index 4b5bc6f15fb..3ab0be575ed 100644
--- a/src/bin/scripts/clusterdb.c
+++ b/src/bin/scripts/clusterdb.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 2002-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.12 2005/01/01 05:43:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.13 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -207,7 +207,7 @@ cluster_all_databases(const char *host, const char *port,
PGresult *result;
int i;
- conn = connectDatabase("template1", host, port, username, password, progname);
+ conn = connectDatabase("postgres", host, port, username, password, progname);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo);
PQfinish(conn);
diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c
index f85e4e84fee..1585523ab9c 100644
--- a/src/bin/scripts/createdb.c
+++ b/src/bin/scripts/createdb.c
@@ -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/createdb.c,v 1.14 2004/12/31 22:03:17 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.15 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -157,7 +157,8 @@ main(int argc, char *argv[])
appendPQExpBuffer(&sql, " TEMPLATE %s", fmtId(template));
appendPQExpBuffer(&sql, ";\n");
- 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);
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index 67758e00d79..db85837952d 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -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/createuser.c,v 1.16 2004/12/31 22:03:17 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.17 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -209,7 +209,7 @@ main(int argc, char *argv[])
appendPQExpBuffer(&sql, " NOCREATEUSER");
appendPQExpBuffer(&sql, ";\n");
- conn = connectDatabase("template1", host, port, username, password, progname);
+ conn = connectDatabase("postgres", host, port, username, password, progname);
if (echo)
printf("%s", sql.data);
diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c
index d58ffcb4eff..944c68dbe33 100644
--- a/src/bin/scripts/dropdb.c
+++ b/src/bin/scripts/dropdb.c
@@ -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);
diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c
index 343cae39b8d..32aa83557a6 100644
--- a/src/bin/scripts/dropuser.c
+++ b/src/bin/scripts/dropuser.c
@@ -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/dropuser.c,v 1.13 2004/12/31 22:03:17 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.14 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -116,7 +116,7 @@ main(int argc, char *argv[])
initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "DROP USER %s;\n", fmtId(dropuser));
- conn = connectDatabase("template1", host, port, username, password, progname);
+ conn = connectDatabase("postgres", host, port, username, password, progname);
if (echo)
printf("%s", sql.data);
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 2015e44242c..8998d5da6c7 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -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/vacuumdb.c,v 1.12 2004/12/31 22:03:17 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.13 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -233,7 +233,7 @@ vacuum_all_databases(bool full, bool verbose, bool analyze,
PGresult *result;
int i;
- conn = connectDatabase("template1", host, port, username, password, progname);
+ conn = connectDatabase("postgres", host, port, username, password, progname);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo);
PQfinish(conn);
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 458cddd134c..84e07725cf8 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.279 2005/06/20 10:29:37 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.280 2005/06/21 04:02:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200506201
+#define CATALOG_VERSION_NO 200506202
#endif
diff --git a/src/interfaces/ecpg/test/testdynalloc.pgc b/src/interfaces/ecpg/test/testdynalloc.pgc
index c0023f8640c..a2f67412b7f 100644
--- a/src/interfaces/ecpg/test/testdynalloc.pgc
+++ b/src/interfaces/ecpg/test/testdynalloc.pgc
@@ -13,7 +13,7 @@ int main()
if (getenv("SQLOPT")) ECPGdebug(1,stderr);
exec sql whenever sqlerror do sqlprint();
- exec sql connect to template1;
+ exec sql connect to postgres;
exec sql allocate descriptor mydesc;
exec sql select tablename into descriptor mydesc from pg_tables;
diff --git a/src/interfaces/libpq/pg_service.conf.sample b/src/interfaces/libpq/pg_service.conf.sample
index e15d79b91ea..8a22fda95a2 100644
--- a/src/interfaces/libpq/pg_service.conf.sample
+++ b/src/interfaces/libpq/pg_service.conf.sample
@@ -4,13 +4,13 @@
# A service is a set of named connection parameters. You may specify
# multiple services in this file. Each starts with a service name in
# brackets. Subsequent lines have connection configuration parameters of
-# the pattern "param=value". A sample configuration for template1 is
+# the pattern "param=value". A sample configuration for postgres is
# included in this file. Lines beginning with '#' are comments.
#
# Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
# rename it pg_service.conf.
#
#
-#[template1]
-#dbname=template1
+#[postgres]
+#dbname=postgres
#user=postgres
diff --git a/src/test/bench/create.sh b/src/test/bench/create.sh
index 77c08368303..a865e68f8fa 100755
--- a/src/test/bench/create.sh
+++ b/src/test/bench/create.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $PostgreSQL: pgsql/src/test/bench/create.sh,v 1.4 2004/09/01 17:25:40 tgl Exp $
+# $PostgreSQL: pgsql/src/test/bench/create.sh,v 1.5 2005/06/21 04:02:34 tgl Exp $
#
if [ ! -d $1 ]; then
echo " you must specify a valid data directory " >&2
@@ -10,10 +10,10 @@ if [ -d ./obj ]; then
fi
echo =============== destroying old bench database... =================
-echo "drop database bench" | postgres -D${1} template1 > /dev/null
+echo "drop database bench" | postgres -D${1} postgres > /dev/null
echo =============== creating new bench database... =================
-echo "create database bench" | postgres -D${1} template1 > /dev/null
+echo "create database bench" | postgres -D${1} postgres > /dev/null
if [ $? -ne 0 ]; then
echo createdb failed
exit 1
diff --git a/src/test/examples/testlibpq.c b/src/test/examples/testlibpq.c
index b9d396a2dcb..3295076481e 100644
--- a/src/test/examples/testlibpq.c
+++ b/src/test/examples/testlibpq.c
@@ -26,14 +26,14 @@ main(int argc, char **argv)
/*
* If the user supplies a parameter on the command line, use it as the
- * conninfo string; otherwise default to setting dbname=template1 and
+ * conninfo string; otherwise default to setting dbname=postgres and
* using environment variables or defaults for all other connection
* parameters.
*/
if (argc > 1)
conninfo = argv[1];
else
- conninfo = "dbname = template1";
+ conninfo = "dbname = postgres";
/* Make a connection to the database */
conn = PQconnectdb(conninfo);
diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c
index 1cb7616f24b..9f1e96d8dac 100644
--- a/src/test/examples/testlibpq2.c
+++ b/src/test/examples/testlibpq2.c
@@ -46,14 +46,14 @@ main(int argc, char **argv)
/*
* If the user supplies a parameter on the command line, use it as the
- * conninfo string; otherwise default to setting dbname=template1 and
+ * conninfo string; otherwise default to setting dbname=postgres and
* using environment variables or defaults for all other connection
* parameters.
*/
if (argc > 1)
conninfo = argv[1];
else
- conninfo = "dbname = template1";
+ conninfo = "dbname = postgres";
/* Make a connection to the database */
conn = PQconnectdb(conninfo);
diff --git a/src/test/examples/testlibpq3.c b/src/test/examples/testlibpq3.c
index 7036d3e81fb..49b03066cd8 100644
--- a/src/test/examples/testlibpq3.c
+++ b/src/test/examples/testlibpq3.c
@@ -51,14 +51,14 @@ main(int argc, char **argv)
/*
* If the user supplies a parameter on the command line, use it as the
- * conninfo string; otherwise default to setting dbname=template1 and
+ * conninfo string; otherwise default to setting dbname=postgres and
* using environment variables or defaults for all other connection
* parameters.
*/
if (argc > 1)
conninfo = argv[1];
else
- conninfo = "dbname = template1";
+ conninfo = "dbname = postgres";
/* Make a connection to the database */
conn = PQconnectdb(conninfo);
diff --git a/src/test/regress/pg_regress.sh b/src/test/regress/pg_regress.sh
index 58534346df0..c192edc5156 100644
--- a/src/test/regress/pg_regress.sh
+++ b/src/test/regress/pg_regress.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.56 2005/06/20 02:26:50 tgl Exp $
+# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.57 2005/06/21 04:02:34 tgl Exp $
me=`basename $0`
: ${TMPDIR=/tmp}
@@ -441,7 +441,7 @@ then
# wait forever, however.
i=0
max=60
- until "$bindir/psql" -X $psql_options template1 </dev/null 2>/dev/null
+ until "$bindir/psql" -X $psql_options postgres </dev/null 2>/dev/null
do
i=`expr $i + 1`
if [ $i -ge $max ]