As per discussion on -hackers the attached patch creates the 'default'
database at initdb time as a default target for initial connections to
keep template1 free from connections and available as template source.
I consider this DB a system object, so it's created before
make_template0 sets the last_system_oid (wondering why template0 isn't
considered a system db too)
Regards,
Andreas
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/initdb/initdb.c,v
retrieving revision 1.83
diff -u -r1.83 initdb.c
--- src/bin/initdb/initdb.c 30 Apr 2005 08:08:51 -0000 1.83
+++ src/bin/initdb/initdb.c 18 Jun 2005 08:37:16 -0000
@@ -177,6 +177,7 @@
static void set_info_version(void);
static void setup_schema(void);
static void vacuum_db(void);
+static void make_default(void);
static void make_template0(void);
static void trapsig(int signum);
static void check_ok(void);
@@ -1828,6 +1829,38 @@
}
/*
+ * copy template1 to pg_system
+ */
+static void
+make_default(void)
+{
+ PG_CMD_DECL;
+ char **line;
+ static char *pg_system_setup[] = {
+ "CREATE DATABASE \"default\";\n",
+ "REVOKE CREATE,TEMPORARY ON DATABASE \"default\" FROM public;\n",
+ NULL
+ };
+
+ fputs(_("copying template1 to default ... "), stdout);
+ fflush(stdout);
+
+ snprintf(cmd, sizeof(cmd),
+ "\"%s\" %s template1 >%s",
+ backend_exec, backend_options,
+ DEVNULL);
+
+ PG_CMD_OPEN;
+
+ for (line = pg_system_setup; *line; line++)
+ PG_CMD_PUTS(*line);
+
+ PG_CMD_CLOSE;
+
+ check_ok();
+}
+
+/*
* copy template1 to template0
*/
static void
@@ -2606,6 +2639,8 @@
vacuum_db();
+ make_default();
+
make_template0();
if (authwarning != NULL)