diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-14 18:37:49 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-14 18:37:49 +0000 |
commit | 2cf48ca04bf59985117e04dd71644a507be90dbb (patch) | |
tree | 6b1033da07f1805a79bcfb67345aba778559d74e /src/backend/utils/misc/database.c | |
parent | 8a9315ca92804bd32b3ee864bf83d98840e1a947 (diff) | |
download | postgresql-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/misc/database.c')
-rw-r--r-- | src/backend/utils/misc/database.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index f415e5aee18..364075c8bed 100644 --- a/src/backend/utils/misc/database.c +++ b/src/backend/utils/misc/database.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.40 2000/10/16 14:52:19 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.41 2000/11/14 18:37:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -186,7 +186,7 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) max = PageGetMaxOffsetNumber(pg); /* look at each tuple on the page */ - for (i = 0; i <= max; i++) + for (i = 0; i < max; i++) { int offset; @@ -221,8 +221,11 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) * database OID from a flat file, handled the same way we * handle the password relation? */ - if (TransactionIdIsValid((TransactionId) tup.t_data->t_xmax)) - continue; + if (tup.t_data->t_infomask & HEAP_XMIN_INVALID) + continue; /* inserting xact known aborted */ + if (TransactionIdIsValid((TransactionId) tup.t_data->t_xmax) && + !(tup.t_data->t_infomask & HEAP_XMAX_INVALID)) + continue; /* deleting xact happened, not known aborted */ /* * Okay, see if this is the one we want. @@ -241,6 +244,10 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) } } + /* failed to find it... */ + *db_id = InvalidOid; + *path = '\0'; + done: close(dbfd); pfree(pg); |