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

Commit851f4cc

Browse files
committed
Clean up some residual confusion between OIDs and RelFileNumbers.
Commitb0a55e4 missed a few placeswhere we are referring to the number used as a part of the relationfilename as an "OID". We now want to call that a "RelFileNumber".Some of these places actually made it sound like the OID in questionis pg_class.oid rather than pg_class.relfilenode, which is especiallygood to clean up.Dilip Kumar with some editing by me.
1 parent9e4f914 commit851f4cc

File tree

4 files changed

+35
-32
lines changed

4 files changed

+35
-32
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
254254
BlockNumbernblocks;
255255
BlockNumberblkno;
256256
Bufferbuf;
257-
Oidrelfilenumber;
257+
RelFileNumberrelfilenumber;
258258
Pagepage;
259259
List*rlocatorlist=NIL;
260260
LockRelIdrelid;
@@ -401,7 +401,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
401401
{
402402
CreateDBRelInfo*relinfo;
403403
Form_pg_classclassForm;
404-
Oidrelfilenumber=InvalidRelFileNumber;
404+
RelFileNumberrelfilenumber=InvalidRelFileNumber;
405405

406406
classForm= (Form_pg_class)GETSTRUCT(tuple);
407407

‎src/backend/replication/basebackup.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,8 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
11721172
intexcludeIdx;
11731173
boolexcludeFound;
11741174
ForkNumberrelForkNum;/* Type of fork if file is a relation */
1175-
intrelOidChars;/* Chars in filename that are the rel oid */
1175+
intrelnumchars;/* Chars in filename that are the
1176+
* relnumber */
11761177

11771178
/* Skip special stuff */
11781179
if (strcmp(de->d_name,".")==0||strcmp(de->d_name,"..")==0)
@@ -1222,23 +1223,24 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
12221223

12231224
/* Exclude all forks for unlogged tables except the init fork */
12241225
if (isDbDir&&
1225-
parse_filename_for_nontemp_relation(de->d_name,&relOidChars,
1226+
parse_filename_for_nontemp_relation(de->d_name,&relnumchars,
12261227
&relForkNum))
12271228
{
12281229
/* Never exclude init forks */
12291230
if (relForkNum!=INIT_FORKNUM)
12301231
{
12311232
charinitForkFile[MAXPGPATH];
1232-
charrelOid[OIDCHARS+1];
1233+
charrelNumber[OIDCHARS+1];
12331234

12341235
/*
12351236
* If any other type of fork, check if there is an init fork
1236-
* with the same OID. If so, the file can be excluded.
1237+
* with the same RelFileNumber. If so, the file can be
1238+
* excluded.
12371239
*/
1238-
memcpy(relOid,de->d_name,relOidChars);
1239-
relOid[relOidChars]='\0';
1240+
memcpy(relNumber,de->d_name,relnumchars);
1241+
relNumber[relnumchars]='\0';
12401242
snprintf(initForkFile,sizeof(initForkFile),"%s/%s_init",
1241-
path,relOid);
1243+
path,relNumber);
12421244

12431245
if (lstat(initForkFile,&statbuf)==0)
12441246
{

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
195195
while ((de=ReadDir(dbspace_dir,dbspacedirname))!=NULL)
196196
{
197197
ForkNumberforkNum;
198-
intoidchars;
198+
intrelnumchars;
199199
unlogged_relation_entryent;
200200

201201
/* Skip anything that doesn't look like a relation data file. */
202-
if (!parse_filename_for_nontemp_relation(de->d_name,&oidchars,
202+
if (!parse_filename_for_nontemp_relation(de->d_name,&relnumchars,
203203
&forkNum))
204204
continue;
205205

@@ -235,11 +235,11 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
235235
while ((de=ReadDir(dbspace_dir,dbspacedirname))!=NULL)
236236
{
237237
ForkNumberforkNum;
238-
intoidchars;
238+
intrelnumchars;
239239
unlogged_relation_entryent;
240240

241241
/* Skip anything that doesn't look like a relation data file. */
242-
if (!parse_filename_for_nontemp_relation(de->d_name,&oidchars,
242+
if (!parse_filename_for_nontemp_relation(de->d_name,&relnumchars,
243243
&forkNum))
244244
continue;
245245

@@ -285,13 +285,13 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
285285
while ((de=ReadDir(dbspace_dir,dbspacedirname))!=NULL)
286286
{
287287
ForkNumberforkNum;
288-
intoidchars;
289-
charoidbuf[OIDCHARS+1];
288+
intrelnumchars;
289+
charrelnumbuf[OIDCHARS+1];
290290
charsrcpath[MAXPGPATH*2];
291291
chardstpath[MAXPGPATH];
292292

293293
/* Skip anything that doesn't look like a relation data file. */
294-
if (!parse_filename_for_nontemp_relation(de->d_name,&oidchars,
294+
if (!parse_filename_for_nontemp_relation(de->d_name,&relnumchars,
295295
&forkNum))
296296
continue;
297297

@@ -304,10 +304,10 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
304304
dbspacedirname,de->d_name);
305305

306306
/* Construct destination pathname. */
307-
memcpy(oidbuf,de->d_name,oidchars);
308-
oidbuf[oidchars]='\0';
307+
memcpy(relnumbuf,de->d_name,relnumchars);
308+
relnumbuf[relnumchars]='\0';
309309
snprintf(dstpath,sizeof(dstpath),"%s/%s%s",
310-
dbspacedirname,oidbuf,de->d_name+oidchars+1+
310+
dbspacedirname,relnumbuf,de->d_name+relnumchars+1+
311311
strlen(forkNames[INIT_FORKNUM]));
312312

313313
/* OK, we're ready to perform the actual copy. */
@@ -328,12 +328,12 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
328328
while ((de=ReadDir(dbspace_dir,dbspacedirname))!=NULL)
329329
{
330330
ForkNumberforkNum;
331-
intoidchars;
332-
charoidbuf[OIDCHARS+1];
331+
intrelnumchars;
332+
charrelnumbuf[OIDCHARS+1];
333333
charmainpath[MAXPGPATH];
334334

335335
/* Skip anything that doesn't look like a relation data file. */
336-
if (!parse_filename_for_nontemp_relation(de->d_name,&oidchars,
336+
if (!parse_filename_for_nontemp_relation(de->d_name,&relnumchars,
337337
&forkNum))
338338
continue;
339339

@@ -342,10 +342,10 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
342342
continue;
343343

344344
/* Construct main fork pathname. */
345-
memcpy(oidbuf,de->d_name,oidchars);
346-
oidbuf[oidchars]='\0';
345+
memcpy(relnumbuf,de->d_name,relnumchars);
346+
relnumbuf[relnumchars]='\0';
347347
snprintf(mainpath,sizeof(mainpath),"%s/%s%s",
348-
dbspacedirname,oidbuf,de->d_name+oidchars+1+
348+
dbspacedirname,relnumbuf,de->d_name+relnumchars+1+
349349
strlen(forkNames[INIT_FORKNUM]));
350350

351351
fsync_fname(mainpath, false);
@@ -372,13 +372,13 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
372372
* for a non-temporary relation and false otherwise.
373373
*
374374
* NB: If this function returns true, the caller is entitled to assume that
375-
* *oidchars has been set to the a value no more than OIDCHARS, and thus
376-
* that a buffer of OIDCHARS+1 characters is sufficient to hold the OID
377-
* portion of the filename. This is critical to protect against a possible
378-
* buffer overrun.
375+
* *relnumchars has been set to a value no more than OIDCHARS, and thus
376+
* that a buffer of OIDCHARS+1 characters is sufficient to hold the
377+
*RelFileNumberportion of the filename. This is critical to protect against
378+
*a possiblebuffer overrun.
379379
*/
380380
bool
381-
parse_filename_for_nontemp_relation(constchar*name,int*oidchars,
381+
parse_filename_for_nontemp_relation(constchar*name,int*relnumchars,
382382
ForkNumber*fork)
383383
{
384384
intpos;
@@ -388,7 +388,7 @@ parse_filename_for_nontemp_relation(const char *name, int *oidchars,
388388
;
389389
if (pos==0||pos>OIDCHARS)
390390
return false;
391-
*oidchars=pos;
391+
*relnumchars=pos;
392392

393393
/* Check for a fork name. */
394394
if (name[pos]!='_')

‎src/include/storage/reinit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
externvoidResetUnloggedRelations(intop);
2222
externboolparse_filename_for_nontemp_relation(constchar*name,
23-
int*oidchars,ForkNumber*fork);
23+
int*relnumchars,
24+
ForkNumber*fork);
2425

2526
#defineUNLOGGED_RELATION_CLEANUP0x0001
2627
#defineUNLOGGED_RELATION_INIT0x0002

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp