diff options
author | Michael Paquier <michael@paquier.xyz> | 2024-09-03 09:11:54 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2024-09-03 09:11:54 +0900 |
commit | c7cd2d6ed082a4638172acece33ed6f36da96263 (patch) | |
tree | f4a8ab1b49eac09019d6b6a6114e9d9a00e9f1a8 /src/backend/storage/file/fd.c | |
parent | 94eec79633f284488de69e253857e44aad10c730 (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/ZryVvjqS9SnV1GPP@ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 368cc9455cf..d5204b1eb91 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -1790,8 +1790,8 @@ TempTablespacePath(char *path, Oid tablespace) else { /* All other tablespaces are accessed via symlinks */ - snprintf(path, MAXPGPATH, "pg_tblspc/%u/%s/%s", - tablespace, TABLESPACE_VERSION_DIRECTORY, + snprintf(path, MAXPGPATH, "%s/%u/%s/%s", + PG_TBLSPC_DIR, tablespace, TABLESPACE_VERSION_DIRECTORY, PG_TEMP_FILES_DIR); } } @@ -3296,7 +3296,7 @@ CleanupTempFiles(bool isCommit, bool isProcExit) void RemovePgTempFiles(void) { - char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY) + sizeof(PG_TEMP_FILES_DIR)]; + char temp_path[MAXPGPATH + sizeof(PG_TBLSPC_DIR) + sizeof(TABLESPACE_VERSION_DIRECTORY) + sizeof(PG_TEMP_FILES_DIR)]; DIR *spc_dir; struct dirent *spc_de; @@ -3310,20 +3310,21 @@ RemovePgTempFiles(void) /* * Cycle through temp directories for all non-default tablespaces. */ - spc_dir = AllocateDir("pg_tblspc"); + spc_dir = AllocateDir(PG_TBLSPC_DIR); - while ((spc_de = ReadDirExtended(spc_dir, "pg_tblspc", LOG)) != NULL) + while ((spc_de = ReadDirExtended(spc_dir, PG_TBLSPC_DIR, LOG)) != NULL) { if (strcmp(spc_de->d_name, ".") == 0 || strcmp(spc_de->d_name, "..") == 0) continue; - snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s/%s", - spc_de->d_name, TABLESPACE_VERSION_DIRECTORY, PG_TEMP_FILES_DIR); + snprintf(temp_path, sizeof(temp_path), "%s/%s/%s/%s", + PG_TBLSPC_DIR, spc_de->d_name, TABLESPACE_VERSION_DIRECTORY, + PG_TEMP_FILES_DIR); RemovePgTempFilesInDir(temp_path, true, false); - snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s", - spc_de->d_name, TABLESPACE_VERSION_DIRECTORY); + snprintf(temp_path, sizeof(temp_path), "%s/%s/%s", + PG_TBLSPC_DIR, spc_de->d_name, TABLESPACE_VERSION_DIRECTORY); RemovePgTempRelationFiles(temp_path); } @@ -3610,15 +3611,15 @@ SyncDataDirectory(void) /* Sync the top level pgdata directory. */ do_syncfs("."); /* If any tablespaces are configured, sync each of those. */ - dir = AllocateDir("pg_tblspc"); - while ((de = ReadDirExtended(dir, "pg_tblspc", LOG))) + dir = AllocateDir(PG_TBLSPC_DIR); + while ((de = ReadDirExtended(dir, PG_TBLSPC_DIR, LOG))) { char path[MAXPGPATH]; if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue; - snprintf(path, MAXPGPATH, "pg_tblspc/%s", de->d_name); + snprintf(path, MAXPGPATH, "%s/%s", PG_TBLSPC_DIR, de->d_name); do_syncfs(path); } FreeDir(dir); @@ -3641,7 +3642,7 @@ SyncDataDirectory(void) walkdir(".", pre_sync_fname, false, DEBUG1); if (xlog_is_symlink) walkdir("pg_wal", pre_sync_fname, false, DEBUG1); - walkdir("pg_tblspc", pre_sync_fname, true, DEBUG1); + walkdir(PG_TBLSPC_DIR, pre_sync_fname, true, DEBUG1); #endif /* Prepare to report progress syncing the data directory via fsync. */ @@ -3659,7 +3660,7 @@ SyncDataDirectory(void) walkdir(".", datadir_fsync_fname, false, LOG); if (xlog_is_symlink) walkdir("pg_wal", datadir_fsync_fname, false, LOG); - walkdir("pg_tblspc", datadir_fsync_fname, true, LOG); + walkdir(PG_TBLSPC_DIR, datadir_fsync_fname, true, LOG); } /* |