mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Support alternate database locations.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Id: fd.c,v 1.26 1997/09/18 20:21:24 momjian Exp $
|
||||
* $Id: fd.c,v 1.27 1997/11/07 06:38:15 thomas Exp $
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
@@ -125,8 +125,6 @@ static Size SizeVfdCache = 0;
|
||||
*/
|
||||
static int nfile = 0;
|
||||
|
||||
static char Sep_char = '/';
|
||||
|
||||
/*
|
||||
* Private Routines
|
||||
*
|
||||
@@ -458,23 +456,25 @@ FreeVfd(File file)
|
||||
VfdCache[0].nextFree = file;
|
||||
}
|
||||
|
||||
/* filepath()
|
||||
* Open specified file name.
|
||||
* Fill in absolute path fields if necessary.
|
||||
*
|
||||
* Modify to use GetDatabasePath() rather than hardcoded paths.
|
||||
* - thomas 1997-11-02
|
||||
*/
|
||||
static char *
|
||||
filepath(char *filename)
|
||||
{
|
||||
char *buf;
|
||||
char basename[16];
|
||||
int len;
|
||||
|
||||
if (*filename != Sep_char)
|
||||
/* Not an absolute path name? Then fill in with database path... */
|
||||
if (*filename != SEP_CHAR)
|
||||
{
|
||||
/* Either /base/ or \base\ */
|
||||
sprintf(basename, "%cbase%c", Sep_char, Sep_char);
|
||||
|
||||
len = strlen(DataDir) + strlen(basename) + strlen(GetDatabaseName())
|
||||
+ strlen(filename) + 2;
|
||||
len = strlen(GetDatabasePath()) + strlen(filename) + 2;
|
||||
buf = (char *) palloc(len);
|
||||
sprintf(buf, "%s%s%s%c%s",
|
||||
DataDir, basename, GetDatabaseName(), Sep_char, filename);
|
||||
sprintf(buf, "%s%c%s", GetDatabasePath(), SEP_CHAR, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -482,6 +482,10 @@ filepath(char *filename)
|
||||
strcpy(buf, filename);
|
||||
}
|
||||
|
||||
#ifdef FILEDEBUG
|
||||
printf("filepath: path is %s\n", buf);
|
||||
#endif
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.23 1997/10/25 01:10:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.24 1997/11/07 06:38:19 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -480,6 +480,7 @@ mdblindwrt(char *dbstr,
|
||||
nchars = 0;
|
||||
|
||||
/* construct the path to the file and open it */
|
||||
/* system table? then put in system area... */
|
||||
if (dbid == (Oid) 0)
|
||||
{
|
||||
path = (char *) palloc(strlen(DataDir) + sizeof(NameData) + 2 + nchars);
|
||||
@@ -488,8 +489,10 @@ mdblindwrt(char *dbstr,
|
||||
else
|
||||
sprintf(path, "%s/%s.%d", DataDir, relstr, segno);
|
||||
}
|
||||
/* user table? then put in user database area... */
|
||||
else
|
||||
{
|
||||
#if FALSE
|
||||
path = (char *) palloc(strlen(DataDir) + strlen("/base/") + 2 * sizeof(NameData) + 2 + nchars);
|
||||
if (segno == 0)
|
||||
sprintf(path, "%s/base/%s/%s", DataDir,
|
||||
@@ -497,6 +500,12 @@ mdblindwrt(char *dbstr,
|
||||
else
|
||||
sprintf(path, "%s/base/%s/%s.%d", DataDir, dbstr,
|
||||
relstr, segno);
|
||||
#endif
|
||||
path = (char *) palloc(strlen(GetDatabasePath()) + 2 * sizeof(NameData) + 2 + nchars);
|
||||
if (segno == 0)
|
||||
sprintf(path, "%s%c%s", GetDatabasePath(), SEP_CHAR, relstr);
|
||||
else
|
||||
sprintf(path, "%s%c%s.%d", GetDatabasePath(), SEP_CHAR, relstr, segno);
|
||||
}
|
||||
|
||||
if ((fd = open(path, O_RDWR, 0600)) < 0)
|
||||
|
||||
Reference in New Issue
Block a user