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/utils/adt/misc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/backend/utils/adt/misc.c') diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 45532539664..867f7da7e2a 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.44 2005/06/19 21:34:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.45 2005/07/04 04:51:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -145,10 +145,10 @@ pg_tablespace_databases(PG_FUNCTION_ARGS) fctx = palloc(sizeof(ts_db_fctx)); /* - * size = path length + tablespace dirname length + 2 dir sep - * chars + oid + terminator + * size = tablespace dirname length + dir sep + * char + oid + terminator */ - fctx->location = (char *) palloc(strlen(DataDir) + 11 + 10 + 1); + fctx->location = (char *) palloc(10 + 10 + 1); if (tablespaceOid == GLOBALTABLESPACE_OID) { fctx->dirdesc = NULL; @@ -158,10 +158,9 @@ pg_tablespace_databases(PG_FUNCTION_ARGS) else { if (tablespaceOid == DEFAULTTABLESPACE_OID) - sprintf(fctx->location, "%s/base", DataDir); + sprintf(fctx->location, "base"); else - sprintf(fctx->location, "%s/pg_tblspc/%u", DataDir, - tablespaceOid); + sprintf(fctx->location, "pg_tblspc/%u", tablespaceOid); fctx->dirdesc = AllocateDir(fctx->location); -- cgit v1.2.3