@@ -705,7 +705,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
705
705
in = fopen (file -> path ,PG_BINARY_R );
706
706
if (in == NULL )
707
707
{
708
- elog (ERROR ,"cannot open backup file \"%s\": %s" ,file -> path ,
708
+ elog (ERROR ,"Cannot open backup file \"%s\": %s" ,file -> path ,
709
709
strerror (errno ));
710
710
}
711
711
}
@@ -722,7 +722,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
722
722
{
723
723
int errno_tmp = errno ;
724
724
fclose (in );
725
- elog (ERROR ,"cannot open restore target file \"%s\": %s" ,
725
+ elog (ERROR ,"Cannot open restore target file \"%s\": %s" ,
726
726
to_path ,strerror (errno_tmp ));
727
727
}
728
728
@@ -762,16 +762,22 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
762
762
break ;/* EOF found */
763
763
else if (read_len != 0 && feof (in ))
764
764
elog (ERROR ,
765
- "odd size page found at block %u of \"%s\"" ,
765
+ "Odd size page found at block %u of \"%s\"" ,
766
766
blknum ,file -> path );
767
767
else
768
- elog (ERROR ,"cannot read header of block %u of \"%s\": %s" ,
768
+ elog (ERROR ,"Cannot read header of block %u of \"%s\": %s" ,
769
769
blknum ,file -> path ,strerror (errno_tmp ));
770
770
}
771
771
772
+ if (header .block == 0 && header .compressed_size == 0 )
773
+ {
774
+ elog (VERBOSE ,"Skip empty block of \"%s\"" ,file -> path );
775
+ continue ;
776
+ }
777
+
772
778
if (header .block < blknum )
773
- elog (ERROR ,"backup is broken atfile->path %s block %u " ,
774
- file -> path , blknum );
779
+ elog (ERROR ,"Backup is broken atblock %u of \"%s\" " ,
780
+ blknum , file -> path );
775
781
776
782
blknum = header .block ;
777
783
@@ -792,7 +798,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
792
798
read_len = fread (compressed_page .data ,1 ,
793
799
MAXALIGN (header .compressed_size ),in );
794
800
if (read_len != MAXALIGN (header .compressed_size ))
795
- elog (ERROR ,"cannot read block %u of \"%s\" read %zu of %d" ,
801
+ elog (ERROR ,"Cannot read block %u of \"%s\" read %zu of %d" ,
796
802
blknum ,file -> path ,read_len ,header .compressed_size );
797
803
798
804
/*
@@ -816,7 +822,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
816
822
blknum ,file -> path ,errormsg );
817
823
818
824
if (uncompressed_size != BLCKSZ )
819
- elog (ERROR ,"page of file \"%s\" uncompressed to %d bytes. != BLCKSZ" ,
825
+ elog (ERROR ,"Page of file \"%s\" uncompressed to %d bytes. != BLCKSZ" ,
820
826
file -> path ,uncompressed_size );
821
827
}
822
828
@@ -827,15 +833,15 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
827
833
* Seek and write the restored page.
828
834
*/
829
835
if (fseek (out ,write_pos ,SEEK_SET )< 0 )
830
- elog (ERROR ,"cannot seek block %u of \"%s\": %s" ,
836
+ elog (ERROR ,"Cannot seek block %u of \"%s\": %s" ,
831
837
blknum ,to_path ,strerror (errno ));
832
838
833
839
if (write_header )
834
840
{
835
841
/* We uncompressed the page, so its size is BLCKSZ */
836
842
header .compressed_size = BLCKSZ ;
837
843
if (fwrite (& header ,1 ,sizeof (header ),out )!= sizeof (header ))
838
- elog (ERROR ,"cannot write header of block %u of \"%s\": %s" ,
844
+ elog (ERROR ,"Cannot write header of block %u of \"%s\": %s" ,
839
845
blknum ,file -> path ,strerror (errno ));
840
846
}
841
847
@@ -846,14 +852,14 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
846
852
if (uncompressed_size == BLCKSZ )
847
853
{
848
854
if (fwrite (page .data ,1 ,BLCKSZ ,out )!= BLCKSZ )
849
- elog (ERROR ,"cannot write block %u of \"%s\": %s" ,
855
+ elog (ERROR ,"Cannot write block %u of \"%s\": %s" ,
850
856
blknum ,file -> path ,strerror (errno ));
851
857
}
852
858
else
853
859
{
854
860
/* */
855
861
if (fwrite (compressed_page .data ,1 ,BLCKSZ ,out )!= BLCKSZ )
856
- elog (ERROR ,"cannot write block %u of \"%s\": %s" ,
862
+ elog (ERROR ,"Cannot write block %u of \"%s\": %s" ,
857
863
blknum ,file -> path ,strerror (errno ));
858
864
}
859
865
}
@@ -891,7 +897,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
891
897
* Truncate file to this length.
892
898
*/
893
899
if (ftruncate (fileno (out ),write_pos )!= 0 )
894
- elog (ERROR ,"cannot truncate \"%s\": %s" ,
900
+ elog (ERROR ,"Cannot truncate \"%s\": %s" ,
895
901
file -> path ,strerror (errno ));
896
902
elog (VERBOSE ,"Delta truncate file %s to block %u" ,
897
903
file -> path ,truncate_from );
@@ -905,14 +911,14 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
905
911
if (in )
906
912
fclose (in );
907
913
fclose (out );
908
- elog (ERROR ,"cannot change mode of \"%s\": %s" ,to_path ,
914
+ elog (ERROR ,"Cannot change mode of \"%s\": %s" ,to_path ,
909
915
strerror (errno_tmp ));
910
916
}
911
917
912
918
if (fflush (out )!= 0 ||
913
919
fsync (fileno (out ))!= 0 ||
914
920
fclose (out ))
915
- elog (ERROR ,"cannot write \"%s\": %s" ,to_path ,strerror (errno ));
921
+ elog (ERROR ,"Cannot write \"%s\": %s" ,to_path ,strerror (errno ));
916
922
if (in )
917
923
fclose (in );
918
924
}
@@ -1571,7 +1577,7 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
1571
1577
pg_crc32 crc ;
1572
1578
bool use_crc32c = backup_version <=20021 || backup_version >=20025 ;
1573
1579
1574
- elog (VERBOSE ,"validate relation blocks for file %s" ,file -> path );
1580
+ elog (VERBOSE ,"Validate relation blocks for file %s" ,file -> path );
1575
1581
1576
1582
in = fopen (file -> path ,PG_BINARY_R );
1577
1583
if (in == NULL )
@@ -1582,7 +1588,7 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
1582
1588
return false;
1583
1589
}
1584
1590
1585
- elog (ERROR ,"cannot open file \"%s\": %s" ,
1591
+ elog (ERROR ,"Cannot open file \"%s\": %s" ,
1586
1592
file -> path ,strerror (errno ));
1587
1593
}
1588
1594
@@ -1606,29 +1612,35 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
1606
1612
break ;/* EOF found */
1607
1613
else if (read_len != 0 && feof (in ))
1608
1614
elog (WARNING ,
1609
- "odd size page found at block %u of \"%s\"" ,
1615
+ "Odd size page found at block %u of \"%s\"" ,
1610
1616
blknum ,file -> path );
1611
1617
else
1612
- elog (WARNING ,"cannot read header of block %u of \"%s\": %s" ,
1618
+ elog (WARNING ,"Cannot read header of block %u of \"%s\": %s" ,
1613
1619
blknum ,file -> path ,strerror (errno_tmp ));
1614
1620
return false;
1615
1621
}
1616
1622
1617
1623
COMP_FILE_CRC32 (use_crc32c ,crc ,& header ,read_len );
1618
1624
1625
+ if (header .block == 0 && header .compressed_size == 0 )
1626
+ {
1627
+ elog (VERBOSE ,"Skip empty block of \"%s\"" ,file -> path );
1628
+ continue ;
1629
+ }
1630
+
1619
1631
if (header .block < blknum )
1620
1632
{
1621
- elog (WARNING ,"backup is broken atfile->path %s block %u " ,
1622
- file -> path , blknum );
1633
+ elog (WARNING ,"Backup is broken atblock %u of \"%s\" " ,
1634
+ blknum , file -> path );
1623
1635
return false;
1624
1636
}
1625
1637
1626
1638
blknum = header .block ;
1627
1639
1628
1640
if (header .compressed_size == PageIsTruncated )
1629
1641
{
1630
- elog (LOG ,"File %s, block %u is truncated" ,
1631
- file -> path , blknum );
1642
+ elog (LOG ,"Block %u of \"%s\" is truncated" ,
1643
+ blknum , file -> path );
1632
1644
continue ;
1633
1645
}
1634
1646
@@ -1638,7 +1650,7 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
1638
1650
MAXALIGN (header .compressed_size ),in );
1639
1651
if (read_len != MAXALIGN (header .compressed_size ))
1640
1652
{
1641
- elog (WARNING ,"cannot read block %u of \"%s\" read %zu of %d" ,
1653
+ elog (WARNING ,"Cannot read block %u of \"%s\" read %zu of %d" ,
1642
1654
blknum ,file -> path ,read_len ,header .compressed_size );
1643
1655
return false;
1644
1656
}
@@ -1668,7 +1680,7 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
1668
1680
is_valid = false;
1669
1681
continue ;
1670
1682
}
1671
- elog (WARNING ,"page of file \"%s\" uncompressed to %d bytes. != BLCKSZ" ,
1683
+ elog (WARNING ,"Page of file \"%s\" uncompressed to %d bytes. != BLCKSZ" ,
1672
1684
file -> path ,uncompressed_size );
1673
1685
return false;
1674
1686
}
@@ -1690,7 +1702,7 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
1690
1702
1691
1703
if (crc != file -> crc )
1692
1704
{
1693
- elog (WARNING ,"Invalid CRC of backup file \"%s\" : %X. Expected %X" ,
1705
+ elog (WARNING ,"Invalid CRC of backup file \"%s\": %X. Expected %X" ,
1694
1706
file -> path ,file -> crc ,crc );
1695
1707
is_valid = false;
1696
1708
}