Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f63853

Browse files
michaelpqpull[bot]
authored andcommitted
Define PG_TBLSPC_DIR for path pg_tblspc/ in data folder
Similarly to2065ddf, 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 ofPG_TBLSPC_DIR_SLASH, required in two places for recovery and backups.Author: Bertrand DrouvotReviewed-by: Ashutosh Bapat, Álvaro Herrera, Yugo Nagata, MichaelPaquierDiscussion:https://postgr.es/m/ZryVvjqS9SnV1GPP@ip-10-97-1-34.eu-west-3.compute.internal
1 parent536e506 commit2f63853

File tree

18 files changed

+88
-70
lines changed

18 files changed

+88
-70
lines changed

‎src/backend/access/transam/xlog.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8944,10 +8944,10 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
89448944
datadirpathlen=strlen(DataDir);
89458945

89468946
/* Collect information about all tablespaces */
8947-
tblspcdir=AllocateDir("pg_tblspc");
8948-
while ((de=ReadDir(tblspcdir,"pg_tblspc"))!=NULL)
8947+
tblspcdir=AllocateDir(PG_TBLSPC_DIR);
8948+
while ((de=ReadDir(tblspcdir,PG_TBLSPC_DIR))!=NULL)
89498949
{
8950-
charfullpath[MAXPGPATH+10];
8950+
charfullpath[MAXPGPATH+sizeof(PG_TBLSPC_DIR)];
89518951
charlinkpath[MAXPGPATH];
89528952
char*relpath=NULL;
89538953
char*s;
@@ -8970,7 +8970,7 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
89708970
if (*badp!='\0'||errno==EINVAL||errno==ERANGE)
89718971
continue;
89728972

8973-
snprintf(fullpath,sizeof(fullpath),"pg_tblspc/%s",de->d_name);
8973+
snprintf(fullpath,sizeof(fullpath),"%s/%s",PG_TBLSPC_DIR,de->d_name);
89748974

89758975
de_type=get_dirent_type(fullpath,de, false,ERROR);
89768976

@@ -9031,8 +9031,8 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
90319031
* In this case, we store a relative path rather than an
90329032
* absolute path into the tablespaceinfo.
90339033
*/
9034-
snprintf(linkpath,sizeof(linkpath),"pg_tblspc/%s",
9035-
de->d_name);
9034+
snprintf(linkpath,sizeof(linkpath),"%s/%s",
9035+
PG_TBLSPC_DIR,de->d_name);
90369036
relpath=pstrdup(linkpath);
90379037
}
90389038
else

‎src/backend/access/transam/xlogrecovery.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
677677
tablespaceinfo*ti=lfirst(lc);
678678
char*linkloc;
679679

680-
linkloc=psprintf("pg_tblspc/%u",ti->oid);
680+
linkloc=psprintf("%s/%u",PG_TBLSPC_DIR,ti->oid);
681681

682682
/*
683683
* Remove the existing symlink if any and Create the symlink
@@ -2157,23 +2157,24 @@ CheckTablespaceDirectory(void)
21572157
DIR*dir;
21582158
structdirent*de;
21592159

2160-
dir=AllocateDir("pg_tblspc");
2161-
while ((de=ReadDir(dir,"pg_tblspc"))!=NULL)
2160+
dir=AllocateDir(PG_TBLSPC_DIR);
2161+
while ((de=ReadDir(dir,PG_TBLSPC_DIR))!=NULL)
21622162
{
2163-
charpath[MAXPGPATH+10];
2163+
charpath[MAXPGPATH+sizeof(PG_TBLSPC_DIR)];
21642164

21652165
/* Skip entries of non-oid names */
21662166
if (strspn(de->d_name,"0123456789")!=strlen(de->d_name))
21672167
continue;
21682168

2169-
snprintf(path,sizeof(path),"pg_tblspc/%s",de->d_name);
2169+
snprintf(path,sizeof(path),"%s/%s",PG_TBLSPC_DIR,de->d_name);
21702170

21712171
if (get_dirent_type(path,de, false,ERROR)!=PGFILETYPE_LNK)
21722172
ereport(allow_in_place_tablespaces ?WARNING :PANIC,
21732173
(errcode(ERRCODE_DATA_CORRUPTED),
21742174
errmsg("unexpected directory entry \"%s\" found in %s",
2175-
de->d_name,"pg_tblspc/"),
2176-
errdetail("All directory entries in pg_tblspc/ should be symbolic links."),
2175+
de->d_name,PG_TBLSPC_DIR),
2176+
errdetail("All directory entries in %s/ should be symbolic links.",
2177+
PG_TBLSPC_DIR),
21772178
errhint("Remove those directories, or set \"allow_in_place_tablespaces\" to ON transiently to let recovery complete.")));
21782179
}
21792180
}

‎src/backend/backup/backup_manifest.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include"access/xlog.h"
1717
#include"backup/backup_manifest.h"
1818
#include"backup/basebackup_sink.h"
19+
#include"common/relpath.h"
1920
#include"mb/pg_wchar.h"
2021
#include"utils/builtins.h"
2122
#include"utils/json.h"
@@ -117,7 +118,7 @@ AddFileToBackupManifest(backup_manifest_info *manifest, Oid spcoid,
117118
*/
118119
if (OidIsValid(spcoid))
119120
{
120-
snprintf(pathbuf,sizeof(pathbuf),"pg_tblspc/%u/%s",spcoid,
121+
snprintf(pathbuf,sizeof(pathbuf),"%s/%u/%s",PG_TBLSPC_DIR,spcoid,
121122
pathname);
122123
pathname=pathbuf;
123124
}

‎src/backend/backup/basebackup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
14881488
if (OidIsValid(spcoid))
14891489
{
14901490
relspcoid=spcoid;
1491-
lookup_path=psprintf("pg_tblspc/%u/%s",spcoid,
1491+
lookup_path=psprintf("%s/%u/%s",PG_TBLSPC_DIR,spcoid,
14921492
tarfilename);
14931493
}
14941494
else

‎src/backend/commands/dbcommands.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3257,7 +3257,7 @@ recovery_create_dbdir(char *path, bool only_tblspc)
32573257
if (stat(path,&st)==0)
32583258
return;
32593259

3260-
if (only_tblspc&&strstr(path,"pg_tblspc/")==NULL)
3260+
if (only_tblspc&&strstr(path,PG_TBLSPC_DIR_SLASH)==NULL)
32613261
elog(PANIC,"requested to created invalid directory: %s",path);
32623262

32633263
if (reachedConsistency&& !allow_in_place_tablespaces)

‎src/backend/commands/tablespace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid)
576576
structstatst;
577577
boolin_place;
578578

579-
linkloc=psprintf("pg_tblspc/%u",tablespaceoid);
579+
linkloc=psprintf("%s/%u",PG_TBLSPC_DIR,tablespaceoid);
580580

581581
/*
582582
* If we're asked to make an 'in place' tablespace, create the directory
@@ -692,7 +692,7 @@ destroy_tablespace_directories(Oid tablespaceoid, bool redo)
692692
char*subfile;
693693
structstatst;
694694

695-
linkloc_with_version_dir=psprintf("pg_tblspc/%u/%s",tablespaceoid,
695+
linkloc_with_version_dir=psprintf("%s/%u/%s",PG_TBLSPC_DIR,tablespaceoid,
696696
TABLESPACE_VERSION_DIRECTORY);
697697

698698
/*

‎src/backend/storage/file/fd.c‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,8 +1790,8 @@ TempTablespacePath(char *path, Oid tablespace)
17901790
else
17911791
{
17921792
/* All other tablespaces are accessed via symlinks */
1793-
snprintf(path,MAXPGPATH,"pg_tblspc/%u/%s/%s",
1794-
tablespace,TABLESPACE_VERSION_DIRECTORY,
1793+
snprintf(path,MAXPGPATH,"%s/%u/%s/%s",
1794+
PG_TBLSPC_DIR,tablespace,TABLESPACE_VERSION_DIRECTORY,
17951795
PG_TEMP_FILES_DIR);
17961796
}
17971797
}
@@ -3296,7 +3296,7 @@ CleanupTempFiles(bool isCommit, bool isProcExit)
32963296
void
32973297
RemovePgTempFiles(void)
32983298
{
3299-
chartemp_path[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)+sizeof(PG_TEMP_FILES_DIR)];
3299+
chartemp_path[MAXPGPATH+sizeof(PG_TBLSPC_DIR)+sizeof(TABLESPACE_VERSION_DIRECTORY)+sizeof(PG_TEMP_FILES_DIR)];
33003300
DIR*spc_dir;
33013301
structdirent*spc_de;
33023302

@@ -3310,20 +3310,21 @@ RemovePgTempFiles(void)
33103310
/*
33113311
* Cycle through temp directories for all non-default tablespaces.
33123312
*/
3313-
spc_dir=AllocateDir("pg_tblspc");
3313+
spc_dir=AllocateDir(PG_TBLSPC_DIR);
33143314

3315-
while ((spc_de=ReadDirExtended(spc_dir,"pg_tblspc",LOG))!=NULL)
3315+
while ((spc_de=ReadDirExtended(spc_dir,PG_TBLSPC_DIR,LOG))!=NULL)
33163316
{
33173317
if (strcmp(spc_de->d_name,".")==0||
33183318
strcmp(spc_de->d_name,"..")==0)
33193319
continue;
33203320

3321-
snprintf(temp_path,sizeof(temp_path),"pg_tblspc/%s/%s/%s",
3322-
spc_de->d_name,TABLESPACE_VERSION_DIRECTORY,PG_TEMP_FILES_DIR);
3321+
snprintf(temp_path,sizeof(temp_path),"%s/%s/%s/%s",
3322+
PG_TBLSPC_DIR,spc_de->d_name,TABLESPACE_VERSION_DIRECTORY,
3323+
PG_TEMP_FILES_DIR);
33233324
RemovePgTempFilesInDir(temp_path, true, false);
33243325

3325-
snprintf(temp_path,sizeof(temp_path),"pg_tblspc/%s/%s",
3326-
spc_de->d_name,TABLESPACE_VERSION_DIRECTORY);
3326+
snprintf(temp_path,sizeof(temp_path),"%s/%s/%s",
3327+
PG_TBLSPC_DIR,spc_de->d_name,TABLESPACE_VERSION_DIRECTORY);
33273328
RemovePgTempRelationFiles(temp_path);
33283329
}
33293330

@@ -3610,15 +3611,15 @@ SyncDataDirectory(void)
36103611
/* Sync the top level pgdata directory. */
36113612
do_syncfs(".");
36123613
/* If any tablespaces are configured, sync each of those. */
3613-
dir=AllocateDir("pg_tblspc");
3614-
while ((de=ReadDirExtended(dir,"pg_tblspc",LOG)))
3614+
dir=AllocateDir(PG_TBLSPC_DIR);
3615+
while ((de=ReadDirExtended(dir,PG_TBLSPC_DIR,LOG)))
36153616
{
36163617
charpath[MAXPGPATH];
36173618

36183619
if (strcmp(de->d_name,".")==0||strcmp(de->d_name,"..")==0)
36193620
continue;
36203621

3621-
snprintf(path,MAXPGPATH,"pg_tblspc/%s",de->d_name);
3622+
snprintf(path,MAXPGPATH,"%s/%s",PG_TBLSPC_DIR,de->d_name);
36223623
do_syncfs(path);
36233624
}
36243625
FreeDir(dir);
@@ -3641,7 +3642,7 @@ SyncDataDirectory(void)
36413642
walkdir(".",pre_sync_fname, false,DEBUG1);
36423643
if (xlog_is_symlink)
36433644
walkdir("pg_wal",pre_sync_fname, false,DEBUG1);
3644-
walkdir("pg_tblspc",pre_sync_fname, true,DEBUG1);
3645+
walkdir(PG_TBLSPC_DIR,pre_sync_fname, true,DEBUG1);
36453646
#endif
36463647

36473648
/* Prepare to report progress syncing the data directory via fsync. */
@@ -3659,7 +3660,7 @@ SyncDataDirectory(void)
36593660
walkdir(".",datadir_fsync_fname, false,LOG);
36603661
if (xlog_is_symlink)
36613662
walkdir("pg_wal",datadir_fsync_fname, false,LOG);
3662-
walkdir("pg_tblspc",datadir_fsync_fname, true,LOG);
3663+
walkdir(PG_TBLSPC_DIR,datadir_fsync_fname, true,LOG);
36633664
}
36643665

36653666
/*

‎src/backend/storage/file/reinit.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ typedef struct
4646
void
4747
ResetUnloggedRelations(intop)
4848
{
49-
chartemp_path[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)];
49+
chartemp_path[MAXPGPATH+sizeof(PG_TBLSPC_DIR)+sizeof(TABLESPACE_VERSION_DIRECTORY)];
5050
DIR*spc_dir;
5151
structdirent*spc_de;
5252
MemoryContexttmpctx,
@@ -77,16 +77,16 @@ ResetUnloggedRelations(int op)
7777
/*
7878
* Cycle through directories for all non-default tablespaces.
7979
*/
80-
spc_dir=AllocateDir("pg_tblspc");
80+
spc_dir=AllocateDir(PG_TBLSPC_DIR);
8181

82-
while ((spc_de=ReadDir(spc_dir,"pg_tblspc"))!=NULL)
82+
while ((spc_de=ReadDir(spc_dir,PG_TBLSPC_DIR))!=NULL)
8383
{
8484
if (strcmp(spc_de->d_name,".")==0||
8585
strcmp(spc_de->d_name,"..")==0)
8686
continue;
8787

88-
snprintf(temp_path,sizeof(temp_path),"pg_tblspc/%s/%s",
89-
spc_de->d_name,TABLESPACE_VERSION_DIRECTORY);
88+
snprintf(temp_path,sizeof(temp_path),"%s/%s/%s",
89+
PG_TBLSPC_DIR,spc_de->d_name,TABLESPACE_VERSION_DIRECTORY);
9090
ResetUnloggedRelationsInTablespaceDir(temp_path,op);
9191
}
9292

‎src/backend/utils/adt/dbsize.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ calculate_database_size(Oid dbOid)
143143
totalsize=db_dir_size(pathname);
144144

145145
/* Scan the non-default tablespaces */
146-
snprintf(dirpath,MAXPGPATH,"pg_tblspc");
146+
snprintf(dirpath,MAXPGPATH,PG_TBLSPC_DIR);
147147
dirdesc=AllocateDir(dirpath);
148148

149149
while ((direntry=ReadDir(dirdesc,dirpath))!=NULL)
@@ -154,8 +154,8 @@ calculate_database_size(Oid dbOid)
154154
strcmp(direntry->d_name,"..")==0)
155155
continue;
156156

157-
snprintf(pathname,sizeof(pathname),"pg_tblspc/%s/%s/%u",
158-
direntry->d_name,TABLESPACE_VERSION_DIRECTORY,dbOid);
157+
snprintf(pathname,sizeof(pathname),"%s/%s/%s/%u",
158+
PG_TBLSPC_DIR,direntry->d_name,TABLESPACE_VERSION_DIRECTORY,dbOid);
159159
totalsize+=db_dir_size(pathname);
160160
}
161161

@@ -227,7 +227,7 @@ calculate_tablespace_size(Oid tblspcOid)
227227
elseif (tblspcOid==GLOBALTABLESPACE_OID)
228228
snprintf(tblspcPath,MAXPGPATH,"global");
229229
else
230-
snprintf(tblspcPath,MAXPGPATH,"pg_tblspc/%u/%s",tblspcOid,
230+
snprintf(tblspcPath,MAXPGPATH,"%s/%u/%s",PG_TBLSPC_DIR,tblspcOid,
231231
TABLESPACE_VERSION_DIRECTORY);
232232

233233
dirdesc=AllocateDir(tblspcPath);

‎src/backend/utils/adt/misc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pg_tablespace_databases(PG_FUNCTION_ARGS)
242242
if (tablespaceOid==DEFAULTTABLESPACE_OID)
243243
location="base";
244244
else
245-
location=psprintf("pg_tblspc/%u/%s",tablespaceOid,
245+
location=psprintf("%s/%u/%s",PG_TBLSPC_DIR,tablespaceOid,
246246
TABLESPACE_VERSION_DIRECTORY);
247247

248248
dirdesc=AllocateDir(location);
@@ -325,7 +325,7 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
325325
* Find the location of the tablespace by reading the symbolic link that
326326
* is in pg_tblspc/<oid>.
327327
*/
328-
snprintf(sourcepath,sizeof(sourcepath),"pg_tblspc/%u",tablespaceOid);
328+
snprintf(sourcepath,sizeof(sourcepath),"%s/%u",PG_TBLSPC_DIR,tablespaceOid);
329329

330330
/*
331331
* Before reading the link, check if the source path is a link or a

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp