aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/postinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-14 18:37:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-14 18:37:49 +0000
commit2cf48ca04bf59985117e04dd71644a507be90dbb (patch)
tree6b1033da07f1805a79bcfb67345aba778559d74e /src/backend/utils/init/postinit.c
parent8a9315ca92804bd32b3ee864bf83d98840e1a947 (diff)
downloadpostgresql-2cf48ca04bf59985117e04dd71644a507be90dbb.tar.gz
postgresql-2cf48ca04bf59985117e04dd71644a507be90dbb.zip
Extend CREATE DATABASE to allow selection of a template database to be
cloned, rather than always cloning template1. Modify initdb to generate two identical databases rather than one, template0 and template1. Connections to template0 are disallowed, so that it will always remain in its virgin as-initdb'd state. pg_dumpall now dumps databases with restore commands that say CREATE DATABASE foo WITH TEMPLATE = template0. This allows proper behavior when there is user-added data in template1. initdb forced!
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r--src/backend/utils/init/postinit.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index f786eb1d10d..3a9e5a1797b 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.70 2000/11/12 20:51:52 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.71 2000/11/14 18:37:44 tgl Exp $
*
*
*-------------------------------------------------------------------------
@@ -79,6 +79,7 @@ ReverifyMyDatabase(const char *name)
HeapScanDesc pgdbscan;
ScanKeyData key;
HeapTuple tup;
+ Form_pg_database dbform;
/*
* Because we grab AccessShareLock here, we can be sure that destroydb
@@ -106,25 +107,24 @@ ReverifyMyDatabase(const char *name)
*/
DropBuffers(MyDatabaseId);
/* Now I can commit hara-kiri with a clear conscience... */
- elog(FATAL, "Database '%s', OID %u, has disappeared from pg_database",
+ elog(FATAL, "Database \"%s\", OID %u, has disappeared from pg_database",
name, MyDatabaseId);
}
/*
+ * Also check that the database is currently allowing connections.
+ */
+ dbform = (Form_pg_database) GETSTRUCT(tup);
+ if (! dbform->datallowconn)
+ elog(FATAL, "Database \"%s\" is not currently accepting connections",
+ name);
+
+ /*
* OK, we're golden. Only other to-do item is to save the MULTIBYTE
- * encoding info out of the pg_database tuple. Note we also set the
- * "template encoding", which is the default encoding for any CREATE
- * DATABASE commands executed in this backend; essentially, you get
- * the same encoding of the database you connected to as the default.
- * (This replaces code that unreliably grabbed template1's encoding
- * out of pg_database. We could do an extra scan to find template1's
- * tuple, but for 99.99% of all backend startups it'd be wasted cycles
- * --- and the 'createdb' script connects to template1 anyway, so
- * there's no difference.)
+ * encoding info out of the pg_database tuple.
*/
#ifdef MULTIBYTE
- SetDatabaseEncoding(((Form_pg_database) GETSTRUCT(tup))->encoding);
- SetTemplateEncoding(((Form_pg_database) GETSTRUCT(tup))->encoding);
+ SetDatabaseEncoding(dbform->encoding);
#endif
heap_endscan(pgdbscan);