PostgreSQL Source Code git master
Loading...
Searching...
No Matches
checksum.h File Reference
#include "storage/block.h"
Include dependency graph for checksum.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum ChecksumStateType ChecksumStateType
 

Enumerations

enum  ChecksumStateType { PG_DATA_CHECKSUM_OFF = 0 , PG_DATA_CHECKSUM_VERSION = 1 , PG_DATA_CHECKSUM_INPROGRESS_OFF = 2 , PG_DATA_CHECKSUM_INPROGRESS_ON = 3 }
 

Functions

uint16 pg_checksum_page (char *page, BlockNumber blkno)
 

Typedef Documentation

◆ ChecksumStateType

Enumeration Type Documentation

◆ ChecksumStateType

Enumerator
PG_DATA_CHECKSUM_OFF 
PG_DATA_CHECKSUM_VERSION 
PG_DATA_CHECKSUM_INPROGRESS_OFF 
PG_DATA_CHECKSUM_INPROGRESS_ON 

Definition at line 26 of file checksum.h.

27{
ChecksumStateType
Definition checksum.h:27
@ PG_DATA_CHECKSUM_VERSION
Definition checksum.h:29
@ PG_DATA_CHECKSUM_INPROGRESS_OFF
Definition checksum.h:30
@ PG_DATA_CHECKSUM_INPROGRESS_ON
Definition checksum.h:31
@ PG_DATA_CHECKSUM_OFF
Definition checksum.h:28

Function Documentation

◆ pg_checksum_page()

uint16 pg_checksum_page ( char page,
BlockNumber  blkno 
)
extern

Definition at line 172 of file checksum_impl.h.

173{
176 uint32 checksum;
177
178 /* We only calculate the checksum for properly-initialized pages */
179 Assert(!PageIsNew((Page) page));
180
181 /*
182 * Save pd_checksum and temporarily set it to zero, so that the checksum
183 * calculation isn't affected by the old checksum stored on the page.
184 * Restore it after, because actually updating the checksum is NOT part of
185 * the API of this function.
186 */
187 save_checksum = cpage->phdr.pd_checksum;
188 cpage->phdr.pd_checksum = 0;
189 checksum = pg_checksum_block(cpage);
190 cpage->phdr.pd_checksum = save_checksum;
191
192 /* Mix in the block number to detect transposed pages */
193 checksum ^= blkno;
194
195 /*
196 * Reduce to a uint16 (to fit in the pd_checksum field) with an offset of
197 * one. That avoids checksums of zero, which seems like a good idea.
198 */
199 return (uint16) ((checksum % 65535) + 1);
200}
static bool PageIsNew(const PageData *page)
Definition bufpage.h:258
PageData * Page
Definition bufpage.h:81
#define Assert(condition)
Definition c.h:943
uint16_t uint16
Definition c.h:623
uint32_t uint32
Definition c.h:624
static uint32(* pg_checksum_block)(const PGChecksummablePage *page)
Definition checksum.c:64
static int fb(int x)

References Assert, fb(), PageIsNew(), and pg_checksum_block.

Referenced by modify_rel_block(), page_checksum_internal(), PageIsVerified(), PageSetChecksum(), rewriteVisibilityMap(), scan_file(), and verify_page_checksum().