@@ -1030,7 +1030,7 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
1030
1030
* go to the next page.
1031
1031
*/
1032
1032
if (!headers && fseek (in , read_len , SEEK_CUR ) != 0 )
1033
- elog (ERROR , "Cannot seek block %u of \"%s\" : %s" ,
1033
+ elog (ERROR , "Cannot seek block %u of '%s' : %s" ,
1034
1034
blknum , from_fullpath , strerror (errno ));
1035
1035
continue ;
1036
1036
}
@@ -1039,7 +1039,7 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
1039
1039
cur_pos_in != headers [n_hdr ].pos )
1040
1040
{
1041
1041
if (fseek (in , headers [n_hdr ].pos , SEEK_SET ) != 0 )
1042
- elog (ERROR , "Cannot seek to offset %u of \"%s\" : %s" ,
1042
+ elog (ERROR , "Cannot seek to offset %u of '%s' : %s" ,
1043
1043
headers [n_hdr ].pos , from_fullpath , strerror (errno ));
1044
1044
1045
1045
cur_pos_in = headers [n_hdr ].pos ;
@@ -1802,7 +1802,6 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
1802
1802
BlockNumber blknum = 0 ;
1803
1803
char read_buffer [BLCKSZ ];
1804
1804
char in_buf [STDIO_BUFSIZE ];
1805
- off_t cur_pos = 0 ;
1806
1805
1807
1806
/* open file */
1808
1807
in = fopen (fullpath , "r+" );
@@ -1820,32 +1819,16 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
1820
1819
checksum_map = pgut_malloc (n_blocks * sizeof (PageState ));
1821
1820
memset (checksum_map , 0 , n_blocks * sizeof (PageState ));
1822
1821
1823
- for (;; )
1822
+ for (blknum = 0 ; blknum < n_blocks ; blknum ++ )
1824
1823
{
1824
+ size_t read_len = fread (read_buffer , 1 , BLCKSZ , in );
1825
1825
PageState page_st ;
1826
- size_t read_len = 0 ;
1827
-
1828
- if (blknum >= n_blocks )
1829
- break ;
1830
-
1831
- if (cur_pos != blknum * BLCKSZ &&
1832
- fseek (in , blknum * BLCKSZ , SEEK_SET ))
1833
- {
1834
- elog (ERROR , "Cannot seek to offset %u in file \"%s\": %s" ,
1835
- blknum * BLCKSZ , fullpath , strerror (errno ));
1836
- }
1837
-
1838
- read_len = fread (read_buffer , 1 , BLCKSZ , in );
1839
- cur_pos += read_len ;
1840
1826
1841
1827
/* report error */
1842
1828
if (ferror (in ))
1843
1829
elog (ERROR , "Cannot read block %u of \"%s\": %s" ,
1844
1830
blknum , fullpath , strerror (errno ));
1845
1831
1846
- if (read_len == 0 && feof (in ))
1847
- break ;
1848
-
1849
1832
if (read_len == BLCKSZ )
1850
1833
{
1851
1834
int rc = validate_one_page (read_buffer , segmentno + blknum ,
@@ -1861,11 +1844,12 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
1861
1844
1862
1845
checksum_map [blknum ].lsn = page_st .lsn ;
1863
1846
}
1864
-
1865
- blknum ++ ;
1866
1847
}
1867
1848
else
1868
- elog (WARNING , "Odd size read len %lu for blknum %u in file \"%s\"" , read_len , blknum , fullpath );
1849
+ elog (ERROR , "Failed to read blknum %u from file \"%s\"" , blknum , fullpath );
1850
+
1851
+ if (feof (in ))
1852
+ break ;
1869
1853
1870
1854
if (interrupted )
1871
1855
elog (ERROR , "Interrupted during page reading" );
0 commit comments