diff options
author | Michael Paquier | 2024-09-03 00:11:54 +0000 |
---|---|---|
committer | Michael Paquier | 2024-09-03 00:11:54 +0000 |
commit | c7cd2d6ed082a4638172acece33ed6f36da96263 (patch) | |
tree | f4a8ab1b49eac09019d6b6a6114e9d9a00e9f1a8 /src/backend/storage/file | |
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/[email protected]
Diffstat (limited to 'src/backend/storage/file')
-rw-r--r-- | src/backend/storage/file/fd.c | 29 | ||||
-rw-r--r-- | src/backend/storage/file/reinit.c | 10 |
2 files changed, 20 insertions, 19 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); } /* diff --git a/src/backend/storage/file/reinit.c b/src/backend/storage/file/reinit.c index f1cd1a38d95..01e267abf9b 100644 --- a/src/backend/storage/file/reinit.c +++ b/src/backend/storage/file/reinit.c @@ -46,7 +46,7 @@ typedef struct void ResetUnloggedRelations(int op) { - char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)]; + char temp_path[MAXPGPATH + sizeof(PG_TBLSPC_DIR) + sizeof(TABLESPACE_VERSION_DIRECTORY)]; DIR *spc_dir; struct dirent *spc_de; MemoryContext tmpctx, @@ -77,16 +77,16 @@ ResetUnloggedRelations(int op) /* * Cycle through directories for all non-default tablespaces. */ - spc_dir = AllocateDir("pg_tblspc"); + spc_dir = AllocateDir(PG_TBLSPC_DIR); - while ((spc_de = ReadDir(spc_dir, "pg_tblspc")) != NULL) + while ((spc_de = ReadDir(spc_dir, PG_TBLSPC_DIR)) != 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", - 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); ResetUnloggedRelationsInTablespaceDir(temp_path, op); } |