mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +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:
@@ -8944,10 +8944,10 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
|
||||
datadirpathlen = strlen(DataDir);
|
||||
|
||||
/* Collect information about all tablespaces */
|
||||
tblspcdir = AllocateDir("pg_tblspc");
|
||||
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
|
||||
tblspcdir = AllocateDir(PG_TBLSPC_DIR);
|
||||
while ((de = ReadDir(tblspcdir, PG_TBLSPC_DIR)) != NULL)
|
||||
{
|
||||
char fullpath[MAXPGPATH + 10];
|
||||
char fullpath[MAXPGPATH + sizeof(PG_TBLSPC_DIR)];
|
||||
char linkpath[MAXPGPATH];
|
||||
char *relpath = NULL;
|
||||
char *s;
|
||||
@@ -8970,7 +8970,7 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
|
||||
if (*badp != '\0' || errno == EINVAL || errno == ERANGE)
|
||||
continue;
|
||||
|
||||
snprintf(fullpath, sizeof(fullpath), "pg_tblspc/%s", de->d_name);
|
||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", PG_TBLSPC_DIR, de->d_name);
|
||||
|
||||
de_type = get_dirent_type(fullpath, de, false, ERROR);
|
||||
|
||||
@@ -9031,8 +9031,8 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
|
||||
* In this case, we store a relative path rather than an
|
||||
* absolute path into the tablespaceinfo.
|
||||
*/
|
||||
snprintf(linkpath, sizeof(linkpath), "pg_tblspc/%s",
|
||||
de->d_name);
|
||||
snprintf(linkpath, sizeof(linkpath), "%s/%s",
|
||||
PG_TBLSPC_DIR, de->d_name);
|
||||
relpath = pstrdup(linkpath);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -677,7 +677,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
|
||||
tablespaceinfo *ti = lfirst(lc);
|
||||
char *linkloc;
|
||||
|
||||
linkloc = psprintf("pg_tblspc/%u", ti->oid);
|
||||
linkloc = psprintf("%s/%u", PG_TBLSPC_DIR, ti->oid);
|
||||
|
||||
/*
|
||||
* Remove the existing symlink if any and Create the symlink
|
||||
@@ -2157,23 +2157,24 @@ CheckTablespaceDirectory(void)
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
|
||||
dir = AllocateDir("pg_tblspc");
|
||||
while ((de = ReadDir(dir, "pg_tblspc")) != NULL)
|
||||
dir = AllocateDir(PG_TBLSPC_DIR);
|
||||
while ((de = ReadDir(dir, PG_TBLSPC_DIR)) != NULL)
|
||||
{
|
||||
char path[MAXPGPATH + 10];
|
||||
char path[MAXPGPATH + sizeof(PG_TBLSPC_DIR)];
|
||||
|
||||
/* Skip entries of non-oid names */
|
||||
if (strspn(de->d_name, "0123456789") != strlen(de->d_name))
|
||||
continue;
|
||||
|
||||
snprintf(path, sizeof(path), "pg_tblspc/%s", de->d_name);
|
||||
snprintf(path, sizeof(path), "%s/%s", PG_TBLSPC_DIR, de->d_name);
|
||||
|
||||
if (get_dirent_type(path, de, false, ERROR) != PGFILETYPE_LNK)
|
||||
ereport(allow_in_place_tablespaces ? WARNING : PANIC,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg("unexpected directory entry \"%s\" found in %s",
|
||||
de->d_name, "pg_tblspc/"),
|
||||
errdetail("All directory entries in pg_tblspc/ should be symbolic links."),
|
||||
de->d_name, PG_TBLSPC_DIR),
|
||||
errdetail("All directory entries in %s/ should be symbolic links.",
|
||||
PG_TBLSPC_DIR),
|
||||
errhint("Remove those directories, or set \"allow_in_place_tablespaces\" to ON transiently to let recovery complete.")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user