Teach both base backups and pg_verify_checksums that if a page is new,
it does not have a checksum yet, so it shouldn't be verified.
Noted by Tomas Vondra, review by David Steele.
* written only halfway and the checksum would not be valid.
* However, replaying WAL would reinstate the correct page in
* this case.
+ * We also skip completely new pages, since they don't have
+ * a checksum yet.
*/
- if (PageGetLSN(page) < startptr)
+ if (!PageIsNew(page) && PageGetLSN(page) < startptr)
{
checksum = pg_checksum_page((char *) page, blkno + segmentno * RELSEG_SIZE);
phdr = (PageHeader) page;
}
blocks++;
+ /* New pages have no checksum yet */
+ if (PageIsNew(buf))
+ continue;
+
csum = pg_checksum_page(buf, blockno + segmentno * RELSEG_SIZE);
if (csum != header->pd_checksum)
{