Skip to content
Snippets Groups Projects
Commit 3ae4edb2 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev
Browse files

Fix relation path constraction in mdblindwrt().

parent d036a699
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.27 1998/01/13 04:04:31 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.28 1998/02/23 13:58:04 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -503,22 +503,35 @@ mdblindwrt(char *dbstr, ...@@ -503,22 +503,35 @@ mdblindwrt(char *dbstr,
sprintf(path, "%s/%s.%d", DataDir, relstr, segno); sprintf(path, "%s/%s.%d", DataDir, relstr, segno);
} }
/* user table? then put in user database area... */ /* user table? then put in user database area... */
else else if (dbid == MyDatabaseId)
{ {
#if FALSE extern char *DatabasePath;
path = (char *) palloc(strlen(DataDir) + strlen("/base/") + 2 * sizeof(NameData) + 2 + nchars);
path = (char *) palloc(strlen(DatabasePath) + 2 * sizeof(NameData) + 2 + nchars);
if (segno == 0) if (segno == 0)
sprintf(path, "%s/base/%s/%s", DataDir, sprintf(path, "%s%c%s", DatabasePath, SEP_CHAR, relstr);
dbstr, relstr);
else else
sprintf(path, "%s/base/%s/%s.%d", DataDir, dbstr, sprintf(path, "%s%c%s.%d", DatabasePath, SEP_CHAR, relstr, segno);
relstr, segno); }
#endif else /* this is work arround only !!! */
path = (char *) palloc(strlen(GetDatabasePath()) + 2 * sizeof(NameData) + 2 + nchars); {
char dbpath[MAXPGPATH+1];
Oid owner, id;
char *tmpPath;
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath);
if (id != dbid)
elog (FATAL, "mdblindwrt: oid of db %s is not %u", dbstr, dbid);
tmpPath = ExpandDatabasePath(dbpath);
if (tmpPath == NULL)
elog (FATAL, "mdblindwrt: can't expand path for db %s", dbstr);
path = (char *) palloc(strlen(tmpPath) + 2 * sizeof(NameData) + 2 + nchars);
if (segno == 0) if (segno == 0)
sprintf(path, "%s%c%s", GetDatabasePath(), SEP_CHAR, relstr); sprintf(path, "%s%c%s", tmpPath, SEP_CHAR, relstr);
else else
sprintf(path, "%s%c%s.%d", GetDatabasePath(), SEP_CHAR, relstr, segno); sprintf(path, "%s%c%s.%d", tmpPath, SEP_CHAR, relstr, segno);
pfree (tmpPath);
} }
if ((fd = open(path, O_RDWR, 0600)) < 0) if ((fd = open(path, O_RDWR, 0600)) < 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment