From eb5949d190e80360386113fde0f05854f0c9824d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 4 Jul 2005 04:51:52 +0000 Subject: 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. --- src/backend/commands/tablespace.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/backend/commands/tablespace.c') diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index 15a263b8efd..b925825062f 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -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) { -- cgit v1.2.3