mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Clean up some residual confusion between OIDs and RelFileNumbers.
Commit b0a55e4329
missed a few places
where we are referring to the number used as a part of the relation
filename as an "OID". We now want to call that a "RelFileNumber".
Some of these places actually made it sound like the OID in question
is pg_class.oid rather than pg_class.relfilenode, which is especially
good to clean up.
Dilip Kumar with some editing by me.
This commit is contained in:
@@ -195,11 +195,11 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
|
||||
{
|
||||
ForkNumber forkNum;
|
||||
int oidchars;
|
||||
int relnumchars;
|
||||
unlogged_relation_entry ent;
|
||||
|
||||
/* Skip anything that doesn't look like a relation data file. */
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars,
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &relnumchars,
|
||||
&forkNum))
|
||||
continue;
|
||||
|
||||
@@ -235,11 +235,11 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
|
||||
{
|
||||
ForkNumber forkNum;
|
||||
int oidchars;
|
||||
int relnumchars;
|
||||
unlogged_relation_entry ent;
|
||||
|
||||
/* Skip anything that doesn't look like a relation data file. */
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars,
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &relnumchars,
|
||||
&forkNum))
|
||||
continue;
|
||||
|
||||
@@ -285,13 +285,13 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
|
||||
{
|
||||
ForkNumber forkNum;
|
||||
int oidchars;
|
||||
char oidbuf[OIDCHARS + 1];
|
||||
int relnumchars;
|
||||
char relnumbuf[OIDCHARS + 1];
|
||||
char srcpath[MAXPGPATH * 2];
|
||||
char dstpath[MAXPGPATH];
|
||||
|
||||
/* Skip anything that doesn't look like a relation data file. */
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars,
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &relnumchars,
|
||||
&forkNum))
|
||||
continue;
|
||||
|
||||
@@ -304,10 +304,10 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
dbspacedirname, de->d_name);
|
||||
|
||||
/* Construct destination pathname. */
|
||||
memcpy(oidbuf, de->d_name, oidchars);
|
||||
oidbuf[oidchars] = '\0';
|
||||
memcpy(relnumbuf, de->d_name, relnumchars);
|
||||
relnumbuf[relnumchars] = '\0';
|
||||
snprintf(dstpath, sizeof(dstpath), "%s/%s%s",
|
||||
dbspacedirname, oidbuf, de->d_name + oidchars + 1 +
|
||||
dbspacedirname, relnumbuf, de->d_name + relnumchars + 1 +
|
||||
strlen(forkNames[INIT_FORKNUM]));
|
||||
|
||||
/* OK, we're ready to perform the actual copy. */
|
||||
@@ -328,12 +328,12 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
|
||||
{
|
||||
ForkNumber forkNum;
|
||||
int oidchars;
|
||||
char oidbuf[OIDCHARS + 1];
|
||||
int relnumchars;
|
||||
char relnumbuf[OIDCHARS + 1];
|
||||
char mainpath[MAXPGPATH];
|
||||
|
||||
/* Skip anything that doesn't look like a relation data file. */
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars,
|
||||
if (!parse_filename_for_nontemp_relation(de->d_name, &relnumchars,
|
||||
&forkNum))
|
||||
continue;
|
||||
|
||||
@@ -342,10 +342,10 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
continue;
|
||||
|
||||
/* Construct main fork pathname. */
|
||||
memcpy(oidbuf, de->d_name, oidchars);
|
||||
oidbuf[oidchars] = '\0';
|
||||
memcpy(relnumbuf, de->d_name, relnumchars);
|
||||
relnumbuf[relnumchars] = '\0';
|
||||
snprintf(mainpath, sizeof(mainpath), "%s/%s%s",
|
||||
dbspacedirname, oidbuf, de->d_name + oidchars + 1 +
|
||||
dbspacedirname, relnumbuf, de->d_name + relnumchars + 1 +
|
||||
strlen(forkNames[INIT_FORKNUM]));
|
||||
|
||||
fsync_fname(mainpath, false);
|
||||
@@ -372,13 +372,13 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
* for a non-temporary relation and false otherwise.
|
||||
*
|
||||
* NB: If this function returns true, the caller is entitled to assume that
|
||||
* *oidchars has been set to the a value no more than OIDCHARS, and thus
|
||||
* that a buffer of OIDCHARS+1 characters is sufficient to hold the OID
|
||||
* portion of the filename. This is critical to protect against a possible
|
||||
* buffer overrun.
|
||||
* *relnumchars has been set to a value no more than OIDCHARS, and thus
|
||||
* that a buffer of OIDCHARS+1 characters is sufficient to hold the
|
||||
* RelFileNumber portion of the filename. This is critical to protect against
|
||||
* a possible buffer overrun.
|
||||
*/
|
||||
bool
|
||||
parse_filename_for_nontemp_relation(const char *name, int *oidchars,
|
||||
parse_filename_for_nontemp_relation(const char *name, int *relnumchars,
|
||||
ForkNumber *fork)
|
||||
{
|
||||
int pos;
|
||||
@@ -388,7 +388,7 @@ parse_filename_for_nontemp_relation(const char *name, int *oidchars,
|
||||
;
|
||||
if (pos == 0 || pos > OIDCHARS)
|
||||
return false;
|
||||
*oidchars = pos;
|
||||
*relnumchars = pos;
|
||||
|
||||
/* Check for a fork name. */
|
||||
if (name[pos] != '_')
|
||||
|
Reference in New Issue
Block a user