diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-06-13 22:35:56 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-06-13 22:35:56 -0400 |
commit | f04216341dd1cc235e975f93ac806d9d3729a344 (patch) | |
tree | 803d65ef30cc32456bc2798d76ec04e5513fbd12 /src/backend/storage/buffer/bufmgr.c | |
parent | fa2fc066f34f1b631b5f92f11e7cda9f60a25330 (diff) | |
download | postgresql-f04216341dd1cc235e975f93ac806d9d3729a344.tar.gz postgresql-f04216341dd1cc235e975f93ac806d9d3729a344.zip |
Refactor checksumming code to make it easier to use externally.
pg_filedump and other external utility programs are likely to want to be
able to check Postgres page checksums. To avoid messy duplication of code,
move the checksumming functionality into an exported header file, much as
we did awhile back for the CRC code.
In passing, get rid of an unportable assumption that a static char[] array
will be word-aligned, and do some other minor code beautification.
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 43eb7d59f46..c6b033cf417 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -1982,9 +1982,13 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln) * have been able to write it while we were busy with log flushing because * we have the io_in_progress lock. */ - bufBlock = BufHdrGetBlock(buf); + /* + * Update page checksum if desired. Since we have only shared lock on the + * buffer, other processes might be updating hint bits in it, so we must + * copy the page to private storage if we do checksumming. + */ bufToWrite = PageSetChecksumCopy((Page) bufBlock, buf->tag.blockNum); if (track_io_timing) |