mirror of
https://github.com/postgres/postgres.git
synced 2025-08-18 12:22:09 +03:00
pgindent run for release 9.3
This is the first run of the Perl-based pgindent script. Also update pgindent instructions.
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
#include "access/xlog.h"
|
||||
#include "storage/checksum.h"
|
||||
|
||||
bool ignore_checksum_failure = false;
|
||||
bool ignore_checksum_failure = false;
|
||||
|
||||
static char pageCopyData[BLCKSZ]; /* for checksum calculation */
|
||||
static char pageCopyData[BLCKSZ]; /* for checksum calculation */
|
||||
static Page pageCopy = pageCopyData;
|
||||
|
||||
static uint16 PageCalcChecksum16(Page page, BlockNumber blkno);
|
||||
@@ -101,16 +101,16 @@ PageIsVerified(Page page, BlockNumber blkno)
|
||||
}
|
||||
|
||||
/*
|
||||
* The following checks don't prove the header is correct,
|
||||
* only that it looks sane enough to allow into the buffer pool.
|
||||
* Later usage of the block can still reveal problems,
|
||||
* which is why we offer the checksum option.
|
||||
* The following checks don't prove the header is correct, only that
|
||||
* it looks sane enough to allow into the buffer pool. Later usage of
|
||||
* the block can still reveal problems, which is why we offer the
|
||||
* checksum option.
|
||||
*/
|
||||
if ((p->pd_flags & ~PD_VALID_FLAG_BITS) == 0 &&
|
||||
p->pd_lower <= p->pd_upper &&
|
||||
p->pd_upper <= p->pd_special &&
|
||||
p->pd_special <= BLCKSZ &&
|
||||
p->pd_special == MAXALIGN(p->pd_special))
|
||||
p->pd_lower <= p->pd_upper &&
|
||||
p->pd_upper <= p->pd_special &&
|
||||
p->pd_special <= BLCKSZ &&
|
||||
p->pd_special == MAXALIGN(p->pd_special))
|
||||
header_sane = true;
|
||||
|
||||
if (header_sane && !checksum_failure)
|
||||
@@ -905,10 +905,10 @@ PageSetChecksumCopy(Page page, BlockNumber blkno)
|
||||
|
||||
/*
|
||||
* We make a copy iff we need to calculate a checksum because other
|
||||
* backends may set hint bits on this page while we write, which
|
||||
* would mean the checksum differs from the page contents. It doesn't
|
||||
* matter if we include or exclude hints during the copy, as long
|
||||
* as we write a valid page and associated checksum.
|
||||
* backends may set hint bits on this page while we write, which would
|
||||
* mean the checksum differs from the page contents. It doesn't matter if
|
||||
* we include or exclude hints during the copy, as long as we write a
|
||||
* valid page and associated checksum.
|
||||
*/
|
||||
memcpy((char *) pageCopy, (char *) page, BLCKSZ);
|
||||
PageSetChecksumInplace(pageCopy, blkno);
|
||||
@@ -931,6 +931,7 @@ PageSetChecksumInplace(Page page, BlockNumber blkno)
|
||||
if (DataChecksumsEnabled())
|
||||
{
|
||||
PageHeader p = (PageHeader) page;
|
||||
|
||||
p->pd_checksum = PageCalcChecksum16(page, blkno);
|
||||
}
|
||||
|
||||
@@ -949,7 +950,7 @@ PageSetChecksumInplace(Page page, BlockNumber blkno)
|
||||
static uint16
|
||||
PageCalcChecksum16(Page page, BlockNumber blkno)
|
||||
{
|
||||
PageHeader phdr = (PageHeader) page;
|
||||
PageHeader phdr = (PageHeader) page;
|
||||
uint16 save_checksum;
|
||||
uint32 checksum;
|
||||
|
||||
@@ -958,9 +959,8 @@ PageCalcChecksum16(Page page, BlockNumber blkno)
|
||||
|
||||
/*
|
||||
* Save pd_checksum and set it to zero, so that the checksum calculation
|
||||
* isn't affected by the checksum stored on the page. We do this to
|
||||
* allow optimization of the checksum calculation on the whole block
|
||||
* in one go.
|
||||
* isn't affected by the checksum stored on the page. We do this to allow
|
||||
* optimization of the checksum calculation on the whole block in one go.
|
||||
*/
|
||||
save_checksum = phdr->pd_checksum;
|
||||
phdr->pd_checksum = 0;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
* for Fowler/Noll/Vo) The primitive of a plain FNV-1a hash folds in data 1
|
||||
* byte at a time according to the formula:
|
||||
*
|
||||
* hash = (hash ^ value) * FNV_PRIME
|
||||
* hash = (hash ^ value) * FNV_PRIME
|
||||
*
|
||||
* FNV-1a algorithm is described at http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
*
|
||||
@@ -36,7 +36,7 @@
|
||||
* avalanche into lower positions. For performance reasons we choose to combine
|
||||
* 4 bytes at a time. The actual hash formula used as the basis is:
|
||||
*
|
||||
* hash = (hash ^ value) * FNV_PRIME ^ ((hash ^ value) >> 17)
|
||||
* hash = (hash ^ value) * FNV_PRIME ^ ((hash ^ value) >> 17)
|
||||
*
|
||||
* The main bottleneck in this calculation is the multiplication latency. To
|
||||
* hide the latency and to make use of SIMD parallelism multiple hash values
|
||||
@@ -131,19 +131,20 @@ static const uint32 checksumBaseOffsets[N_SUMS] = {
|
||||
uint32
|
||||
checksum_block(char *data, uint32 size)
|
||||
{
|
||||
uint32 sums[N_SUMS];
|
||||
uint32 (*dataArr)[N_SUMS] = (uint32 (*)[N_SUMS]) data;
|
||||
uint32 result = 0;
|
||||
int i, j;
|
||||
uint32 sums[N_SUMS];
|
||||
uint32 (*dataArr)[N_SUMS] = (uint32 (*)[N_SUMS]) data;
|
||||
uint32 result = 0;
|
||||
int i,
|
||||
j;
|
||||
|
||||
/* ensure that the size is compatible with the algorithm */
|
||||
Assert((size % (sizeof(uint32)*N_SUMS)) == 0);
|
||||
Assert((size % (sizeof(uint32) * N_SUMS)) == 0);
|
||||
|
||||
/* initialize partial checksums to their corresponding offsets */
|
||||
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets));
|
||||
|
||||
/* main checksum calculation */
|
||||
for (i = 0; i < size/sizeof(uint32)/N_SUMS; i++)
|
||||
for (i = 0; i < size / sizeof(uint32) / N_SUMS; i++)
|
||||
for (j = 0; j < N_SUMS; j++)
|
||||
CHECKSUM_COMP(sums[j], dataArr[i][j]);
|
||||
|
||||
|
Reference in New Issue
Block a user