mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Arrange for the postmaster (and standalone backends, initdb, etc) to
chdir into PGDATA and subsequently use relative paths instead of absolute paths to access all files under PGDATA. This seems to give a small performance improvement, and it should make the system more robust against naive DBAs doing things like moving a database directory that has a live postmaster in it. Per recent discussion.
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.23 2005/06/28 05:08:54 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.24 2005/07/04 04:51:46 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -338,8 +338,8 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
|
||||
/*
|
||||
* All seems well, create the symlink
|
||||
*/
|
||||
linkloc = (char *) palloc(strlen(DataDir) + 11 + 10 + 1);
|
||||
sprintf(linkloc, "%s/pg_tblspc/%u", DataDir, tablespaceoid);
|
||||
linkloc = (char *) palloc(10 + 10 + 1);
|
||||
sprintf(linkloc, "pg_tblspc/%u", tablespaceoid);
|
||||
|
||||
if (symlink(location, linkloc) < 0)
|
||||
ereport(ERROR,
|
||||
@ -491,8 +491,8 @@ remove_tablespace_directories(Oid tablespaceoid, bool redo)
|
||||
char *subfile;
|
||||
struct stat st;
|
||||
|
||||
location = (char *) palloc(strlen(DataDir) + 11 + 10 + 1);
|
||||
sprintf(location, "%s/pg_tblspc/%u", DataDir, tablespaceoid);
|
||||
location = (char *) palloc(10 + 10 + 1);
|
||||
sprintf(location, "pg_tblspc/%u", tablespaceoid);
|
||||
|
||||
/*
|
||||
* Check if the tablespace still contains any files. We try to rmdir
|
||||
@ -989,8 +989,8 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
set_short_version(location);
|
||||
|
||||
/* Create the symlink if not already present */
|
||||
linkloc = (char *) palloc(strlen(DataDir) + 11 + 10 + 1);
|
||||
sprintf(linkloc, "%s/pg_tblspc/%u", DataDir, xlrec->ts_id);
|
||||
linkloc = (char *) palloc(10 + 10 + 1);
|
||||
sprintf(linkloc, "pg_tblspc/%u", xlrec->ts_id);
|
||||
|
||||
if (symlink(location, linkloc) < 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user