summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorMichael Paquier2024-09-03 00:11:54 +0000
committerMichael Paquier2024-09-03 00:11:54 +0000
commitc7cd2d6ed082a4638172acece33ed6f36da96263 (patch)
treef4a8ab1b49eac09019d6b6a6114e9d9a00e9f1a8 /src/common
parent94eec79633f284488de69e253857e44aad10c730 (diff)
Define PG_TBLSPC_DIR for path pg_tblspc/ in data folder
Similarly to 2065ddf5e34c, this introduces a define for "pg_tblspc". This makes the style more consistent with the existing PG_STAT_TMP_DIR, for example. There is a difference with the other cases with the introduction of PG_TBLSPC_DIR_SLASH, required in two places for recovery and backups. Author: Bertrand Drouvot Reviewed-by: Ashutosh Bapat, Álvaro Herrera, Yugo Nagata, Michael Paquier Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/common')
-rw-r--r--src/common/file_utils.c3
-rw-r--r--src/common/relpath.c25
2 files changed, 17 insertions, 11 deletions
diff --git a/src/common/file_utils.c b/src/common/file_utils.c
index 6bac537a1e5..398fe1c334d 100644
--- a/src/common/file_utils.c
+++ b/src/common/file_utils.c
@@ -28,6 +28,7 @@
#ifdef FRONTEND
#include "common/logging.h"
#endif
+#include "common/relpath.h"
#include "port/pg_iovec.h"
#ifdef FRONTEND
@@ -105,7 +106,7 @@ sync_pgdata(const char *pg_data,
/* handle renaming of pg_xlog to pg_wal in post-10 clusters */
snprintf(pg_wal, MAXPGPATH, "%s/%s", pg_data,
serverVersion < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal");
- snprintf(pg_tblspc, MAXPGPATH, "%s/pg_tblspc", pg_data);
+ snprintf(pg_tblspc, MAXPGPATH, "%s/%s", pg_data, PG_TBLSPC_DIR);
/*
* If pg_wal is a symlink, we'll need to recurse into it separately,
diff --git a/src/common/relpath.c b/src/common/relpath.c
index f54c36ef7ac..9f2e00e83e4 100644
--- a/src/common/relpath.c
+++ b/src/common/relpath.c
@@ -123,8 +123,9 @@ GetDatabasePath(Oid dbOid, Oid spcOid)
else
{
/* All other tablespaces are accessed via symlinks */
- return psprintf("pg_tblspc/%u/%s/%u",
- spcOid, TABLESPACE_VERSION_DIRECTORY, dbOid);
+ return psprintf("%s/%u/%s/%u",
+ PG_TBLSPC_DIR, spcOid,
+ TABLESPACE_VERSION_DIRECTORY, dbOid);
}
}
@@ -184,25 +185,29 @@ GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
if (procNumber == INVALID_PROC_NUMBER)
{
if (forkNumber != MAIN_FORKNUM)
- path = psprintf("pg_tblspc/%u/%s/%u/%u_%s",
- spcOid, TABLESPACE_VERSION_DIRECTORY,
+ path = psprintf("%s/%u/%s/%u/%u_%s",
+ PG_TBLSPC_DIR, spcOid,
+ TABLESPACE_VERSION_DIRECTORY,
dbOid, relNumber,
forkNames[forkNumber]);
else
- path = psprintf("pg_tblspc/%u/%s/%u/%u",
- spcOid, TABLESPACE_VERSION_DIRECTORY,
+ path = psprintf("%s/%u/%s/%u/%u",
+ PG_TBLSPC_DIR, spcOid,
+ TABLESPACE_VERSION_DIRECTORY,
dbOid, relNumber);
}
else
{
if (forkNumber != MAIN_FORKNUM)
- path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u_%s",
- spcOid, TABLESPACE_VERSION_DIRECTORY,
+ path = psprintf("%s/%u/%s/%u/t%d_%u_%s",
+ PG_TBLSPC_DIR, spcOid,
+ TABLESPACE_VERSION_DIRECTORY,
dbOid, procNumber, relNumber,
forkNames[forkNumber]);
else
- path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u",
- spcOid, TABLESPACE_VERSION_DIRECTORY,
+ path = psprintf("%s/%u/%s/%u/t%d_%u",
+ PG_TBLSPC_DIR, spcOid,
+ TABLESPACE_VERSION_DIRECTORY,
dbOid, procNumber, relNumber);
}
}