1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +03:00

Define PG_TBLSPC_DIR for path pg_tblspc/ in data folder

Similarly to 2065ddf5e3, 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
This commit is contained in:
Michael Paquier
2024-09-03 09:11:54 +09:00
parent 94eec79633
commit c7cd2d6ed0
18 changed files with 88 additions and 70 deletions

View File

@@ -143,7 +143,7 @@ calculate_database_size(Oid dbOid)
totalsize = db_dir_size(pathname);
/* Scan the non-default tablespaces */
snprintf(dirpath, MAXPGPATH, "pg_tblspc");
snprintf(dirpath, MAXPGPATH, PG_TBLSPC_DIR);
dirdesc = AllocateDir(dirpath);
while ((direntry = ReadDir(dirdesc, dirpath)) != NULL)
@@ -154,8 +154,8 @@ calculate_database_size(Oid dbOid)
strcmp(direntry->d_name, "..") == 0)
continue;
snprintf(pathname, sizeof(pathname), "pg_tblspc/%s/%s/%u",
direntry->d_name, TABLESPACE_VERSION_DIRECTORY, dbOid);
snprintf(pathname, sizeof(pathname), "%s/%s/%s/%u",
PG_TBLSPC_DIR, direntry->d_name, TABLESPACE_VERSION_DIRECTORY, dbOid);
totalsize += db_dir_size(pathname);
}
@@ -227,7 +227,7 @@ calculate_tablespace_size(Oid tblspcOid)
else if (tblspcOid == GLOBALTABLESPACE_OID)
snprintf(tblspcPath, MAXPGPATH, "global");
else
snprintf(tblspcPath, MAXPGPATH, "pg_tblspc/%u/%s", tblspcOid,
snprintf(tblspcPath, MAXPGPATH, "%s/%u/%s", PG_TBLSPC_DIR, tblspcOid,
TABLESPACE_VERSION_DIRECTORY);
dirdesc = AllocateDir(tblspcPath);

View File

@@ -242,7 +242,7 @@ pg_tablespace_databases(PG_FUNCTION_ARGS)
if (tablespaceOid == DEFAULTTABLESPACE_OID)
location = "base";
else
location = psprintf("pg_tblspc/%u/%s", tablespaceOid,
location = psprintf("%s/%u/%s", PG_TBLSPC_DIR, tablespaceOid,
TABLESPACE_VERSION_DIRECTORY);
dirdesc = AllocateDir(location);
@@ -325,7 +325,7 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
* Find the location of the tablespace by reading the symbolic link that
* is in pg_tblspc/<oid>.
*/
snprintf(sourcepath, sizeof(sourcepath), "pg_tblspc/%u", tablespaceOid);
snprintf(sourcepath, sizeof(sourcepath), "%s/%u", PG_TBLSPC_DIR, tablespaceOid);
/*
* Before reading the link, check if the source path is a link or a

View File

@@ -6800,10 +6800,10 @@ RelationCacheInitFilePostInvalidate(void)
void
RelationCacheInitFileRemove(void)
{
const char *tblspcdir = "pg_tblspc";
const char *tblspcdir = PG_TBLSPC_DIR;
DIR *dir;
struct dirent *de;
char path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
char path[MAXPGPATH + sizeof(PG_TBLSPC_DIR) + sizeof(TABLESPACE_VERSION_DIRECTORY)];
snprintf(path, sizeof(path), "global/%s",
RELCACHE_INIT_FILENAME);