aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/dbcommands.c21
-rw-r--r--src/bin/initdb/initdb.sh7
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_attribute.h5
-rw-r--r--src/include/catalog/pg_class.h4
-rw-r--r--src/include/catalog/pg_database.h10
6 files changed, 35 insertions, 16 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index f12ce4e56c7..d68033d8975 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.61 2000/10/16 14:52:03 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.62 2000/10/22 17:55:36 pjw Exp $
*
*-------------------------------------------------------------------------
*/
@@ -44,7 +44,6 @@ static bool
get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP);
-
/*
* CREATE DATABASE
*/
@@ -62,7 +61,8 @@ createdb(const char *dbname, const char *dbpath, int encoding)
HeapTuple tuple;
TupleDesc pg_database_dsc;
Datum new_record[Natts_pg_database];
- char new_record_nulls[Natts_pg_database] = {' ', ' ', ' ', ' '};
+ char new_record_nulls[Natts_pg_database] = {' ', ' ', ' ', ' ', ' '};
+ Oid dboid;
if (!get_user_info(GetUserId(), &use_super, &use_createdb))
elog(ERROR, "current user name is invalid");
@@ -91,6 +91,8 @@ createdb(const char *dbname, const char *dbpath, int encoding)
"The database path '%s' is invalid. "
"This may be due to a character that is not allowed or because the chosen "
"path isn't permitted for databases", dbpath);
+#else
+ locbuf[0] = 0; /* Avoid junk in strings */
#endif
/*
@@ -99,16 +101,26 @@ createdb(const char *dbname, const char *dbpath, int encoding)
pg_database_rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
pg_database_dsc = RelationGetDescr(pg_database_rel);
+ /*
+ * Preassign OID for pg_database tuple, so that we know current
+ * OID counter value
+ */
+ dboid = newoid();
+
/* Form tuple */
new_record[Anum_pg_database_datname - 1] = DirectFunctionCall1(namein,
CStringGetDatum(dbname));
new_record[Anum_pg_database_datdba - 1] = Int32GetDatum(GetUserId());
new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding);
+ new_record[Anum_pg_database_datlastsysoid - 1] = ObjectIdGetDatum(dboid); /* Save current OID val */
new_record[Anum_pg_database_datpath - 1] = DirectFunctionCall1(textin,
CStringGetDatum(locbuf));
tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);
+ tuple->t_data->t_oid = dboid; /* override heap_insert */
+
+
/*
* Update table
*/
@@ -180,6 +192,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
else
elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
}
+
}
@@ -391,8 +404,6 @@ get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP)
return HeapTupleIsValid(tuple);
}
-
-
static bool
get_user_info(Oid use_sysid, bool *use_super, bool *use_createdb)
{
diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh
index 86d8d0289ea..fc5e8f04237 100644
--- a/src/bin/initdb/initdb.sh
+++ b/src/bin/initdb/initdb.sh
@@ -23,7 +23,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.105 2000/10/16 14:52:21 vadim Exp $
+# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.106 2000/10/22 17:55:45 pjw Exp $
#
#-------------------------------------------------------------------------
@@ -597,6 +597,11 @@ cat $TEMPFILE \
| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
rm -f "$TEMPFILE" || exit_nicely
+echo "Setting lastsysoid."
+echo "Update pg_database Set datlastsysoid = (Select max(oid) From pg_description) \
+ Where datname = 'template1'" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
echo "Vacuuming database."
echo "VACUUM ANALYZE" \
| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 15574e122bf..c16c6ae83ec 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.50 2000/10/13 00:33:47 pjw Exp $
+ * $Id: catversion.h,v 1.51 2000/10/22 17:55:49 pjw Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200010131
+#define CATALOG_VERSION_NO 200010231
#endif
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 4b1d8dc3439..de3ccdf5d83 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_attribute.h,v 1.65 2000/10/16 14:52:26 vadim Exp $
+ * $Id: pg_attribute.h,v 1.66 2000/10/22 17:55:49 pjw Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -281,7 +281,8 @@ DATA(insert OID = 0 ( 1247 tableoid 26 0 4 -7 0 -1 -1 t p f i f f));
DATA(insert OID = 0 ( 1262 datname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f));
DATA(insert OID = 0 ( 1262 datdba 23 0 4 2 0 -1 -1 t p f i f f));
DATA(insert OID = 0 ( 1262 encoding 23 0 4 3 0 -1 -1 t p f i f f));
-DATA(insert OID = 0 ( 1262 datpath 25 0 -1 4 0 -1 -1 f x f i f f));
+DATA(insert OID = 0 ( 1262 datlastsysoid 26 0 4 4 0 -1 -1 t p f i f f));
+DATA(insert OID = 0 ( 1262 datpath 25 0 -1 5 0 -1 -1 f x f i f f));
DATA(insert OID = 0 ( 1262 ctid 27 0 6 -1 0 -1 -1 f p f i f f));
DATA(insert OID = 0 ( 1262 oid 26 0 4 -2 0 -1 -1 t p f i f f));
DATA(insert OID = 0 ( 1262 xmin 28 0 4 -3 0 -1 -1 t p f i f f));
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index 6bf2d129e5d..a9592e7ddb8 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_class.h,v 1.42 2000/10/16 16:19:14 momjian Exp $
+ * $Id: pg_class.h,v 1.43 2000/10/22 17:55:49 pjw Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -142,7 +142,7 @@ DATA(insert OID = 1260 ( pg_shadow 86 PGUID 0 1260 0 0 0 0 f t r 8 0 0 0 0
DESCR("");
DATA(insert OID = 1261 ( pg_group 87 PGUID 0 1261 0 0 0 0 f t r 3 0 0 0 0 0 f f f _null_ ));
DESCR("");
-DATA(insert OID = 1262 ( pg_database 88 PGUID 0 1262 0 0 0 0 f t r 4 0 0 0 0 0 f f f _null_ ));
+DATA(insert OID = 1262 ( pg_database 88 PGUID 0 1262 0 0 0 0 f t r 5 0 0 0 0 0 f f f _null_ ));
DESCR("");
DATA(insert OID = 1264 ( pg_variable 90 PGUID 0 1264 0 0 0 0 f t s 1 0 0 0 0 0 f f f _null_ ));
DESCR("");
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index 27acca85f44..ca89738bbfe 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_database.h,v 1.11 2000/10/20 11:01:17 vadim Exp $
+ * $Id: pg_database.h,v 1.12 2000/10/22 17:55:49 pjw Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -36,6 +36,7 @@ CATALOG(pg_database) BOOTSTRAP
NameData datname;
int4 datdba;
int4 encoding;
+ int4 datlastsysoid;
text datpath; /* VARIABLE LENGTH FIELD */
} FormData_pg_database;
@@ -50,13 +51,14 @@ typedef FormData_pg_database *Form_pg_database;
* compiler constants for pg_database
* ----------------
*/
-#define Natts_pg_database 4
+#define Natts_pg_database 5
#define Anum_pg_database_datname 1
#define Anum_pg_database_datdba 2
#define Anum_pg_database_encoding 3
-#define Anum_pg_database_datpath 4
+#define Anum_pg_database_datlastsysoid 4
+#define Anum_pg_database_datpath 5
-DATA(insert OID = 1 ( template1 PGUID ENCODING template1 ));
+DATA(insert OID = 1 ( template1 PGUID ENCODING 0 template1 ));
DESCR("");
#define TemplateDbOid 1