PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 (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

void mask_lp_flags ( Page  page)

Definition at line 93 of file bufmask.c.

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

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

94 {
95  OffsetNumber offnum,
96  maxoff;
97 
98  maxoff = PageGetMaxOffsetNumber(page);
99  for (offnum = FirstOffsetNumber;
100  offnum <= maxoff;
101  offnum = OffsetNumberNext(offnum))
102  {
103  ItemId itemId = PageGetItemId(page, offnum);
104 
105  if (ItemIdIsUsed(itemId))
106  itemId->lp_flags = LP_UNUSED;
107  }
108 }
#define ItemIdIsUsed(itemId)
Definition: itemid.h:91
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:354
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:232
#define LP_UNUSED
Definition: itemid.h:37
#define OffsetNumberNext(offsetNumber)
Definition: off.h:53
unsigned lp_flags
Definition: itemid.h:26
void mask_page_content ( Page  page)

Definition at line 117 of file bufmask.c.

References MASK_MARKER, and SizeOfPageHeaderData.

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

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

Definition at line 44 of file bufmask.c.

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().

45 {
46  PageHeader phdr = (PageHeader) page;
47 
48  /* Ignore prune_xid (it's like a hint-bit) */
49  phdr->pd_prune_xid = MASK_MARKER;
50 
51  /* Ignore PD_PAGE_FULL and PD_HAS_FREE_LINES flags, they are just hints. */
52  PageClearFull(page);
54 
55  /*
56  * During replay, if the page LSN has advanced past our XLOG record's LSN,
57  * we don't mark the page all-visible. See heap_xlog_visible() for
58  * details.
59  */
60  PageClearAllVisible(page);
61 }
#define PageClearHasFreeLinePointers(page)
Definition: bufpage.h:372
#define MASK_MARKER
Definition: bufmask.h:24
#define PageClearFull(page)
Definition: bufpage.h:379
PageHeaderData * PageHeader
Definition: bufpage.h:162
#define PageClearAllVisible(page)
Definition: bufpage.h:386
TransactionId pd_prune_xid
Definition: bufpage.h:158
void mask_page_lsn ( Page  page)

Definition at line 30 of file bufmask.c.

References MASK_MARKER, PageXLogRecPtrSet, 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().

31 {
32  PageHeader phdr = (PageHeader) page;
33 
34  PageXLogRecPtrSet(phdr->pd_lsn, (uint64) MASK_MARKER);
35 }
#define PageXLogRecPtrSet(ptr, lsn)
Definition: bufpage.h:98
#define MASK_MARKER
Definition: bufmask.h:24
PageHeaderData * PageHeader
Definition: bufpage.h:162
PageXLogRecPtr pd_lsn
Definition: bufpage.h:150
void mask_unused_space ( Page  page)

Definition at line 69 of file bufmask.c.

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().

70 {
71  int pd_lower = ((PageHeader) page)->pd_lower;
72  int pd_upper = ((PageHeader) page)->pd_upper;
73  int pd_special = ((PageHeader) page)->pd_special;
74 
75  /* Sanity check */
76  if (pd_lower > pd_upper || pd_special < pd_upper ||
77  pd_lower < SizeOfPageHeaderData || pd_special > BLCKSZ)
78  {
79  elog(ERROR, "invalid page pd_lower %u pd_upper %u pd_special %u\n",
80  pd_lower, pd_upper, pd_special);
81  }
82 
83  memset(page + pd_lower, MASK_MARKER, pd_upper - pd_lower);
84 }
#define ERROR
Definition: elog.h:43
#define MASK_MARKER
Definition: bufmask.h:24
PageHeaderData * PageHeader
Definition: bufpage.h:162
#define elog
Definition: elog.h:219