@@ -507,7 +507,8 @@ backup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpat
507507 * NOTE This is a normal situation, if the file size has changed
508508 * since the moment we computed it.
509509 */
510- file -> n_blocks = file -> size /BLCKSZ ;
510+ file -> n_blocks = (typeof (file -> n_blocks ))(file -> size /BLCKSZ );
511+ Assert ((int64_t )file -> n_blocks * BLCKSZ == file -> size );
511512
512513/*
513514 * Skip unchanged file only if it exists in previous backup.
@@ -611,12 +612,15 @@ backup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpat
611612elog (ERROR ,"Cannot read file \"%s\"" ,from_fullpath );
612613}
613614
614- file -> read_size = rc * BLCKSZ ;
615+ file -> read_size = ( int64_t ) rc * BLCKSZ ;
615616
616617/* refresh n_blocks for FULL and DELTA */
617618if (backup_mode == BACKUP_MODE_FULL ||
618619backup_mode == BACKUP_MODE_DIFF_DELTA )
619- file -> n_blocks = file -> read_size /BLCKSZ ;
620+ {
621+ file -> n_blocks = (typeof (file -> n_blocks ))(file -> read_size /BLCKSZ );
622+ Assert ((int64_t )file -> n_blocks * BLCKSZ == file -> read_size );
623+ }
620624
621625/* Determine that file didn`t changed in case of incremental backup */
622626if (backup_mode != BACKUP_MODE_FULL &&
@@ -650,7 +654,7 @@ backup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpat
650654void
651655catchup_data_file (pgFile * file ,const char * from_fullpath ,const char * to_fullpath ,
652656XLogRecPtr sync_lsn ,BackupMode backup_mode ,
653- uint32 checksum_version ,size_t prev_size )
657+ uint32 checksum_version ,int64_t prev_size )
654658{
655659int rc ;
656660bool use_pagemap ;
@@ -760,7 +764,7 @@ catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpa
760764elog (ERROR ,"Cannot read file \"%s\"" ,from_fullpath );
761765}
762766
763- file -> read_size = rc * BLCKSZ ;
767+ file -> read_size = ( int64_t ) rc * BLCKSZ ;
764768
765769/* Determine that file didn`t changed in case of incremental catchup */
766770if (backup_mode != BACKUP_MODE_FULL &&
@@ -1595,7 +1599,8 @@ check_data_file(ConnectionArgs *arguments, pgFile *file,
15951599 * NOTE This is a normal situation, if the file size has changed
15961600 * since the moment we computed it.
15971601 */
1598- nblocks = file -> size /BLCKSZ ;
1602+ nblocks = (typeof (nblocks ))(file -> size /BLCKSZ );
1603+ Assert ((int64_t )nblocks * BLCKSZ == file -> size );
15991604
16001605for (blknum = 0 ;blknum < nblocks ;blknum ++ )
16011606{
@@ -2275,7 +2280,7 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
22752280elog (ERROR ,"Cannot seek to end of file position in destination file \"%s\": %s" ,
22762281to_fullpath ,strerror (errno ));
22772282{
2278- long pos = ftell (out );
2283+ int64_t pos = ftell (out );
22792284
22802285if (pos < 0 )
22812286elog (ERROR ,"Cannot get position in destination file \"%s\": %s" ,