Tuesday, August 5, 2008

[HACKERS] small improvement in buffread common

*** pgsql_page_api.7c9eff0cf439/src/backend/storage/buffer/bufmgr.c út srp 5 12:31:44 2008
--- pgsql_page_api/src/backend/storage/buffer/bufmgr.c út srp 5 12:25:01 2008
***************
*** 352,379 ****
if (zeroPage)
MemSet((char *) bufBlock, 0, BLCKSZ);
else
- smgrread(smgr, blockNum, (char *) bufBlock);
- /* check for garbage data */
- if (!PageHeaderIsValid((PageHeader) bufBlock))
{
! if (zero_damaged_pages)
{
! ereport(WARNING,
! (errcode(ERRCODE_DATA_CORRUPTED),
! errmsg("invalid page header in block %u of relation %u/%u/%u; zeroing out page",
! blockNum,
! smgr->smgr_rnode.spcNode,
! smgr->smgr_rnode.dbNode,
! smgr->smgr_rnode.relNode)));
! MemSet((char *) bufBlock, 0, BLCKSZ);
}
- else
- ereport(ERROR,
- (errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("invalid page header in block %u of relation %u/%u/%u",
- blockNum, smgr->smgr_rnode.spcNode,
- smgr->smgr_rnode.dbNode,
- smgr->smgr_rnode.relNode)));
}
}

--- 352,382 ----
if (zeroPage)
MemSet((char *) bufBlock, 0, BLCKSZ);
else
{
! smgrread(smgr, blockNum, (char *) bufBlock);
!
! /* check for garbage data */
! if (!PageHeaderIsValid((Page) bufBlock))
{
! if (zero_damaged_pages)
! {
! ereport(WARNING,
! (errcode(ERRCODE_DATA_CORRUPTED),
! errmsg("invalid page header in block %u of relation %u/%u/%u; zeroing out page",
! blockNum,
! smgr->smgr_rnode.spcNode,
! smgr->smgr_rnode.dbNode,
! smgr->smgr_rnode.relNode)));
! MemSet((char *) bufBlock, 0, BLCKSZ);
! }
! else
! ereport(ERROR,
! (errcode(ERRCODE_DATA_CORRUPTED),
! errmsg("invalid page header in block %u of relation %u/%u/%u",
! blockNum, smgr->smgr_rnode.spcNode,
! smgr->smgr_rnode.dbNode,
! smgr->smgr_rnode.relNode)));
}
}
}

I attach patch which removes useless page header check when page is zeroed. It
is primary used by hash index.

Zdenek

--
Zdenek Kotala Sun Microsystems
Prague, Czech Republic http://sun.com/postgresql

No comments: