1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

New file naming. Database OID is used as "tablespace" id and

relation OID is used as file node on creation but may be changed later
if required. Regression Tests Approved (c) -:)))
This commit is contained in:
Vadim B. Mikheev
2000-10-16 14:52:28 +00:00
parent 07a55ebf64
commit 2c7de17b07
19 changed files with 488 additions and 154 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.111 2000/09/12 04:49:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.112 2000/10/16 14:52:13 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1017,6 +1017,12 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
*/
RelationInitLockInfo(relation); /* see lmgr.c */
if (IsSharedSystemRelationName(NameStr(relation->rd_rel->relname)))
relation->rd_node.tblNode = InvalidOid;
else
relation->rd_node.tblNode = MyDatabaseId;
relation->rd_node.relNode = relation->rd_rel->relfilenode;
/* ----------------
* open the relation and assign the file descriptor returned
* by the storage manager code to rd_fd.
@@ -1192,6 +1198,13 @@ formrdesc(char *relationName,
*/
RelationCacheInsert(relation);
if (IsSharedSystemRelationName(relationName))
relation->rd_node.tblNode = InvalidOid;
else
relation->rd_node.tblNode = MyDatabaseId;
relation->rd_node.relNode =
relation->rd_rel->relfilenode = RelationGetRelid(relation);
/*
* Determining this requires a scan on pg_class, but to do the scan
* the rdesc for pg_class must already exist. Therefore we must do
@@ -2438,6 +2451,8 @@ init_irels(void)
/* the file descriptor is not yet opened */
ird->rd_fd = -1;
ird->rd_node.tblNode = MyDatabaseId;
/* next, read the access method tuple form */
if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.67 2000/10/02 19:42:54 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.68 2000/10/16 14:52:15 vadim Exp $
*
*
*-------------------------------------------------------------------------
@@ -21,6 +21,10 @@
#include <math.h>
#include <unistd.h>
#ifndef OLD_FILE_NAMING
#include "catalog/catalog.h"
#endif
#include "access/heapam.h"
#include "catalog/catname.h"
#include "catalog/pg_database.h"
@@ -242,7 +246,12 @@ InitPostgres(const char *dbname, const char *username)
*/
if (bootstrap)
{
MyDatabaseId = TemplateDbOid;
#ifdef OLD_FILE_NAMING
SetDatabasePath(ExpandDatabasePath(dbname));
#else
SetDatabasePath(GetDatabasePath(MyDatabaseId));
#endif
LockDisable(true);
}
else
@@ -276,9 +285,13 @@ InitPostgres(const char *dbname, const char *username)
"Database \"%s\" does not exist in the system catalog.",
dbname);
#ifdef OLD_FILE_NAMING
fullpath = ExpandDatabasePath(datpath);
if (!fullpath)
elog(FATAL, "Database path could not be resolved.");
#else
fullpath = GetDatabasePath(MyDatabaseId);
#endif
/* Verify the database path */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.39 2000/07/03 20:48:42 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.40 2000/10/16 14:52:19 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,7 @@
#include "access/xact.h"
#include "catalog/catname.h"
#include "catalog/catalog.h"
#include "catalog/pg_database.h"
#include "miscadmin.h"
#include "utils/syscache.h"
@@ -143,8 +144,17 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
char *dbfname;
Form_pg_database tup_db;
#ifdef OLD_FILE_NAMING
dbfname = (char *) palloc(strlen(DataDir) + 8 + strlen(DatabaseRelationName) + 2);
sprintf(dbfname, "%s/global/%s", DataDir, DatabaseRelationName);
#else
{
RelFileNode rnode;
rnode.tblNode = 0;
rnode.relNode = RelOid_pg_database;
dbfname = relpath(rnode);
}
#endif
if ((dbfd = open(dbfname, O_RDONLY | PG_BINARY, 0)) < 0)
elog(FATAL, "cannot open %s: %s", dbfname, strerror(errno));