@ -195,11 +195,11 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
while ( ( de = ReadDir ( dbspace_dir , dbspacedirname ) ) ! = NULL )
{
ForkNumber forkNum ;
int oid chars;
int relnum chars;
unlogged_relation_entry ent ;
/* Skip anything that doesn't look like a relation data file. */
if ( ! parse_filename_for_nontemp_relation ( de - > d_name , & oid chars,
if ( ! parse_filename_for_nontemp_relation ( de - > d_name , & relnum chars,
& forkNum ) )
continue ;
@ -235,11 +235,11 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
while ( ( de = ReadDir ( dbspace_dir , dbspacedirname ) ) ! = NULL )
{
ForkNumber forkNum ;
int oid chars;
int relnum chars;
unlogged_relation_entry ent ;
/* Skip anything that doesn't look like a relation data file. */
if ( ! parse_filename_for_nontemp_relation ( de - > d_name , & oid chars,
if ( ! parse_filename_for_nontemp_relation ( de - > d_name , & relnum chars,
& forkNum ) )
continue ;
@ -285,13 +285,13 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
while ( ( de = ReadDir ( dbspace_dir , dbspacedirname ) ) ! = NULL )
{
ForkNumber forkNum ;
int oid chars;
char oid buf[ OIDCHARS + 1 ] ;
int relnum chars;
char relnum buf[ 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 , & oid chars,
if ( ! parse_filename_for_nontemp_relation ( de - > d_name , & relnum chars,
& forkNum ) )
continue ;
@ -304,10 +304,10 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
dbspacedirname , de - > d_name ) ;
/* Construct destination pathname. */
memcpy ( oid buf, de - > d_name , oid chars) ;
oidbuf [ oid chars] = ' \0 ' ;
memcpy ( relnum buf, de - > d_name , relnum chars) ;
relnumbuf [ relnum chars] = ' \0 ' ;
snprintf ( dstpath , sizeof ( dstpath ) , " %s/%s%s " ,
dbspacedirname , oid buf, de - > d_name + oid chars + 1 +
dbspacedirname , relnum buf, de - > d_name + relnum chars + 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 oid chars;
char oid buf[ OIDCHARS + 1 ] ;
int relnum chars;
char relnum buf[ 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 , & oid chars,
if ( ! parse_filename_for_nontemp_relation ( de - > d_name , & relnum chars,
& forkNum ) )
continue ;
@ -342,10 +342,10 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
continue ;
/* Construct main fork pathname. */
memcpy ( oid buf, de - > d_name , oid chars) ;
oidbuf [ oid chars] = ' \0 ' ;
memcpy ( relnum buf, de - > d_name , relnum chars) ;
relnumbuf [ relnum chars] = ' \0 ' ;
snprintf ( mainpath , sizeof ( mainpath ) , " %s/%s%s " ,
dbspacedirname , oid buf, de - > d_name + oid chars + 1 +
dbspacedirname , relnum buf, de - > d_name + relnum chars + 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
* * oid chars 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 .
* * relnum chars 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 * oid chars,
parse_filename_for_nontemp_relation ( const char * name , int * relnum chars,
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 ;
* oid chars = pos ;
* relnum chars = pos ;
/* Check for a fork name. */
if ( name [ pos ] ! = ' _ ' )