@ -24,6 +24,7 @@
# include "access/xlog_internal.h"
# include "access/xlog_internal.h"
# include "catalog/catversion.h"
# include "catalog/catversion.h"
# include "catalog/pg_control.h"
# include "catalog/pg_control.h"
# include "common/controldata_utils.h"
# include "common/file_perm.h"
# include "common/file_perm.h"
# include "common/file_utils.h"
# include "common/file_utils.h"
# include "common/restricted_token.h"
# include "common/restricted_token.h"
@ -37,7 +38,6 @@ static void createBackupLabel(XLogRecPtr startpoint, TimeLineID starttli,
static void digestControlFile ( ControlFileData * ControlFile , char * source ,
static void digestControlFile ( ControlFileData * ControlFile , char * source ,
size_t size ) ;
size_t size ) ;
static void updateControlFile ( ControlFileData * ControlFile ) ;
static void syncTargetDirectory ( void ) ;
static void syncTargetDirectory ( void ) ;
static void sanityChecks ( void ) ;
static void sanityChecks ( void ) ;
static void findCommonAncestorTimeline ( XLogRecPtr * recptr , int * tliIndex ) ;
static void findCommonAncestorTimeline ( XLogRecPtr * recptr , int * tliIndex ) ;
@ -377,7 +377,7 @@ main(int argc, char **argv)
ControlFile_new . minRecoveryPoint = endrec ;
ControlFile_new . minRecoveryPoint = endrec ;
ControlFile_new . minRecoveryPointTLI = endtli ;
ControlFile_new . minRecoveryPointTLI = endtli ;
ControlFile_new . state = DB_IN_ARCHIVE_RECOVERY ;
ControlFile_new . state = DB_IN_ARCHIVE_RECOVERY ;
updateControlFile ( & ControlFile_new ) ;
update_controlfile ( datadir_target , progname , & ControlFile_new ) ;
pg_log ( PG_PROGRESS , " syncing target data directory \n " ) ;
pg_log ( PG_PROGRESS , " syncing target data directory \n " ) ;
syncTargetDirectory ( ) ;
syncTargetDirectory ( ) ;
@ -666,45 +666,6 @@ digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
checkControlFile ( ControlFile ) ;
checkControlFile ( ControlFile ) ;
}
}
/*
* Update the target ' s control file .
*/
static void
updateControlFile ( ControlFileData * ControlFile )
{
char buffer [ PG_CONTROL_FILE_SIZE ] ;
/*
* For good luck , apply the same static assertions as in backend ' s
* WriteControlFile ( ) .
*/
StaticAssertStmt ( sizeof ( ControlFileData ) < = PG_CONTROL_MAX_SAFE_SIZE ,
" pg_control is too large for atomic disk writes " ) ;
StaticAssertStmt ( sizeof ( ControlFileData ) < = PG_CONTROL_FILE_SIZE ,
" sizeof(ControlFileData) exceeds PG_CONTROL_FILE_SIZE " ) ;
/* Recalculate CRC of control file */
INIT_CRC32C ( ControlFile - > crc ) ;
COMP_CRC32C ( ControlFile - > crc ,
( char * ) ControlFile ,
offsetof ( ControlFileData , crc ) ) ;
FIN_CRC32C ( ControlFile - > crc ) ;
/*
* Write out PG_CONTROL_FILE_SIZE bytes into pg_control by zero - padding
* the excess over sizeof ( ControlFileData ) , to avoid premature EOF related
* errors when reading it .
*/
memset ( buffer , 0 , PG_CONTROL_FILE_SIZE ) ;
memcpy ( buffer , ControlFile , sizeof ( ControlFileData ) ) ;
open_target_file ( " global/pg_control " , false ) ;
write_target_range ( buffer , 0 , PG_CONTROL_FILE_SIZE ) ;
close_target_file ( ) ;
}
/*
/*
* Sync target data directory to ensure that modifications are safely on disk .
* Sync target data directory to ensure that modifications are safely on disk .
*
*