PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
bufmask.c File Reference
#include "postgres.h"
#include "access/bufmask.h"
Include dependency graph for bufmask.c:

Go to the source code of this file.

Functions

void mask_page_lsn_and_checksum (Page page)
 
void mask_page_hint_bits (Page page)
 
void mask_unused_space (Page page)
 
void mask_lp_flags (Page page)
 
void mask_page_content (Page page)
 

Function Documentation

◆ mask_lp_flags()

void mask_lp_flags ( Page  page)

Definition at line 95 of file bufmask.c.

96 {
97  OffsetNumber offnum,
98  maxoff;
99 
100  maxoff = PageGetMaxOffsetNumber(page);
101  for (offnum = FirstOffsetNumber;
102  offnum <= maxoff;
103  offnum = OffsetNumberNext(offnum))
104  {
105  ItemId itemId = PageGetItemId(page, offnum);
106 
107  if (ItemIdIsUsed(itemId))
108  itemId->lp_flags = LP_UNUSED;
109  }
110 }
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition: bufpage.h:243
static OffsetNumber PageGetMaxOffsetNumber(Page page)
Definition: bufpage.h:372
#define LP_UNUSED
Definition: itemid.h:38
#define ItemIdIsUsed(itemId)
Definition: itemid.h:92
#define OffsetNumberNext(offsetNumber)
Definition: off.h:52
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
unsigned lp_flags
Definition: itemid.h:28

References FirstOffsetNumber, ItemIdIsUsed, ItemIdData::lp_flags, LP_UNUSED, OffsetNumberNext, PageGetItemId(), and PageGetMaxOffsetNumber().

Referenced by btree_mask(), gist_mask(), and hash_mask().

◆ mask_page_content()

void mask_page_content ( Page  page)

Definition at line 119 of file bufmask.c.

120 {
121  /* Mask Page Content */
122  memset(page + SizeOfPageHeaderData, MASK_MARKER,
123  BLCKSZ - SizeOfPageHeaderData);
124 
125  /* Mask pd_lower and pd_upper */
126  memset(&((PageHeader) page)->pd_lower, MASK_MARKER,
127  sizeof(uint16));
128  memset(&((PageHeader) page)->pd_upper, MASK_MARKER,
129  sizeof(uint16));
130 }
#define MASK_MARKER
Definition: bufmask.h:24
#define SizeOfPageHeaderData
Definition: bufpage.h:216
unsigned short uint16
Definition: c.h:517

References MASK_MARKER, and SizeOfPageHeaderData.

Referenced by gin_mask(), and hash_mask().

◆ mask_page_hint_bits()

void mask_page_hint_bits ( Page  page)

Definition at line 46 of file bufmask.c.

47 {
48  PageHeader phdr = (PageHeader) page;
49 
50  /* Ignore prune_xid (it's like a hint-bit) */
51  phdr->pd_prune_xid = MASK_MARKER;
52 
53  /* Ignore PD_PAGE_FULL and PD_HAS_FREE_LINES flags, they are just hints. */
54  PageClearFull(page);
56 
57  /*
58  * During replay, if the page LSN has advanced past our XLOG record's LSN,
59  * we don't mark the page all-visible. See heap_xlog_visible() for
60  * details.
61  */
62  PageClearAllVisible(page);
63 }
PageHeaderData * PageHeader
Definition: bufpage.h:173
static void PageClearAllVisible(Page page)
Definition: bufpage.h:439
static void PageClearFull(Page page)
Definition: bufpage.h:423
static void PageClearHasFreeLinePointers(Page page)
Definition: bufpage.h:407
TransactionId pd_prune_xid
Definition: bufpage.h:169

References MASK_MARKER, PageClearAllVisible(), PageClearFull(), PageClearHasFreeLinePointers(), and PageHeaderData::pd_prune_xid.

Referenced by brin_mask(), btree_mask(), gin_mask(), gist_mask(), hash_mask(), heap_mask(), and spg_mask().

◆ mask_page_lsn_and_checksum()

void mask_page_lsn_and_checksum ( Page  page)

Definition at line 31 of file bufmask.c.

32 {
33  PageHeader phdr = (PageHeader) page;
34 
35  PageXLogRecPtrSet(phdr->pd_lsn, (uint64) MASK_MARKER);
36  phdr->pd_checksum = MASK_MARKER;
37 }
#define PageXLogRecPtrSet(ptr, lsn)
Definition: bufpage.h:109
PageXLogRecPtr pd_lsn
Definition: bufpage.h:161
uint16 pd_checksum
Definition: bufpage.h:163

References MASK_MARKER, PageXLogRecPtrSet, PageHeaderData::pd_checksum, and PageHeaderData::pd_lsn.

Referenced by brin_mask(), btree_mask(), generic_mask(), gin_mask(), gist_mask(), hash_mask(), heap_mask(), seq_mask(), and spg_mask().

◆ mask_unused_space()

void mask_unused_space ( Page  page)

Definition at line 71 of file bufmask.c.

72 {
73  int pd_lower = ((PageHeader) page)->pd_lower;
74  int pd_upper = ((PageHeader) page)->pd_upper;
75  int pd_special = ((PageHeader) page)->pd_special;
76 
77  /* Sanity check */
78  if (pd_lower > pd_upper || pd_special < pd_upper ||
79  pd_lower < SizeOfPageHeaderData || pd_special > BLCKSZ)
80  {
81  elog(ERROR, "invalid page pd_lower %u pd_upper %u pd_special %u",
82  pd_lower, pd_upper, pd_special);
83  }
84 
85  memset(page + pd_lower, MASK_MARKER, pd_upper - pd_lower);
86 }
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225

References elog, ERROR, and MASK_MARKER.

Referenced by brin_mask(), btree_mask(), generic_mask(), gin_mask(), gist_mask(), hash_mask(), heap_mask(), seq_mask(), and spg_mask().