PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
brin_xlog.h File Reference
Include dependency graph for brin_xlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_brin_createidx
 
struct  xl_brin_insert
 
struct  xl_brin_update
 
struct  xl_brin_samepage_update
 
struct  xl_brin_revmap_extend
 
struct  xl_brin_desummarize
 

Macros

#define XLOG_BRIN_CREATE_INDEX   0x00
 
#define XLOG_BRIN_INSERT   0x10
 
#define XLOG_BRIN_UPDATE   0x20
 
#define XLOG_BRIN_SAMEPAGE_UPDATE   0x30
 
#define XLOG_BRIN_REVMAP_EXTEND   0x40
 
#define XLOG_BRIN_DESUMMARIZE   0x50
 
#define XLOG_BRIN_OPMASK   0x70
 
#define XLOG_BRIN_INIT_PAGE   0x80
 
#define SizeOfBrinCreateIdx   (offsetof(xl_brin_createidx, version) + sizeof(uint16))
 
#define SizeOfBrinInsert   (offsetof(xl_brin_insert, offnum) + sizeof(OffsetNumber))
 
#define SizeOfBrinUpdate   (offsetof(xl_brin_update, insert) + SizeOfBrinInsert)
 
#define SizeOfBrinSamepageUpdate   (sizeof(OffsetNumber))
 
#define SizeOfBrinRevmapExtend
 
#define SizeOfBrinDesummarize
 

Typedefs

typedef struct xl_brin_createidx xl_brin_createidx
 
typedef struct xl_brin_insert xl_brin_insert
 
typedef struct xl_brin_update xl_brin_update
 
typedef struct xl_brin_samepage_update xl_brin_samepage_update
 
typedef struct xl_brin_revmap_extend xl_brin_revmap_extend
 
typedef struct xl_brin_desummarize xl_brin_desummarize
 

Functions

void brin_redo (XLogReaderState *record)
 
void brin_desc (StringInfo buf, XLogReaderState *record)
 
const char * brin_identify (uint8 info)
 
void brin_mask (char *pagedata, BlockNumber blkno)
 

Macro Definition Documentation

◆ SizeOfBrinCreateIdx

#define SizeOfBrinCreateIdx   (offsetof(xl_brin_createidx, version) + sizeof(uint16))

Definition at line 55 of file brin_xlog.h.

◆ SizeOfBrinDesummarize

#define SizeOfBrinDesummarize
Value:
(offsetof(xl_brin_desummarize, regOffset) + \
sizeof(OffsetNumber))
uint16 OffsetNumber
Definition: off.h:24

Definition at line 142 of file brin_xlog.h.

◆ SizeOfBrinInsert

#define SizeOfBrinInsert   (offsetof(xl_brin_insert, offnum) + sizeof(OffsetNumber))

Definition at line 74 of file brin_xlog.h.

◆ SizeOfBrinRevmapExtend

#define SizeOfBrinRevmapExtend
Value:
(offsetof(xl_brin_revmap_extend, targetBlk) + \
sizeof(BlockNumber))
uint32 BlockNumber
Definition: block.h:31

Definition at line 124 of file brin_xlog.h.

◆ SizeOfBrinSamepageUpdate

#define SizeOfBrinSamepageUpdate   (sizeof(OffsetNumber))

Definition at line 107 of file brin_xlog.h.

◆ SizeOfBrinUpdate

#define SizeOfBrinUpdate   (offsetof(xl_brin_update, insert) + SizeOfBrinInsert)

Definition at line 95 of file brin_xlog.h.

◆ XLOG_BRIN_CREATE_INDEX

#define XLOG_BRIN_CREATE_INDEX   0x00

Definition at line 31 of file brin_xlog.h.

◆ XLOG_BRIN_DESUMMARIZE

#define XLOG_BRIN_DESUMMARIZE   0x50

Definition at line 36 of file brin_xlog.h.

◆ XLOG_BRIN_INIT_PAGE

#define XLOG_BRIN_INIT_PAGE   0x80

Definition at line 43 of file brin_xlog.h.

◆ XLOG_BRIN_INSERT

#define XLOG_BRIN_INSERT   0x10

Definition at line 32 of file brin_xlog.h.

◆ XLOG_BRIN_OPMASK

#define XLOG_BRIN_OPMASK   0x70

Definition at line 38 of file brin_xlog.h.

◆ XLOG_BRIN_REVMAP_EXTEND

#define XLOG_BRIN_REVMAP_EXTEND   0x40

Definition at line 35 of file brin_xlog.h.

◆ XLOG_BRIN_SAMEPAGE_UPDATE

#define XLOG_BRIN_SAMEPAGE_UPDATE   0x30

Definition at line 34 of file brin_xlog.h.

◆ XLOG_BRIN_UPDATE

#define XLOG_BRIN_UPDATE   0x20

Definition at line 33 of file brin_xlog.h.

Typedef Documentation

◆ xl_brin_createidx

◆ xl_brin_desummarize

◆ xl_brin_insert

◆ xl_brin_revmap_extend

◆ xl_brin_samepage_update

◆ xl_brin_update

Function Documentation

◆ brin_desc()

void brin_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 20 of file brindesc.c.

21 {
22  char *rec = XLogRecGetData(record);
23  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24 
25  info &= XLOG_BRIN_OPMASK;
26  if (info == XLOG_BRIN_CREATE_INDEX)
27  {
28  xl_brin_createidx *xlrec = (xl_brin_createidx *) rec;
29 
30  appendStringInfo(buf, "v%d pagesPerRange %u",
31  xlrec->version, xlrec->pagesPerRange);
32  }
33  else if (info == XLOG_BRIN_INSERT)
34  {
35  xl_brin_insert *xlrec = (xl_brin_insert *) rec;
36 
37  appendStringInfo(buf, "heapBlk %u pagesPerRange %u offnum %u",
38  xlrec->heapBlk,
39  xlrec->pagesPerRange,
40  xlrec->offnum);
41  }
42  else if (info == XLOG_BRIN_UPDATE)
43  {
44  xl_brin_update *xlrec = (xl_brin_update *) rec;
45 
46  appendStringInfo(buf, "heapBlk %u pagesPerRange %u old offnum %u, new offnum %u",
47  xlrec->insert.heapBlk,
48  xlrec->insert.pagesPerRange,
49  xlrec->oldOffnum,
50  xlrec->insert.offnum);
51  }
52  else if (info == XLOG_BRIN_SAMEPAGE_UPDATE)
53  {
55 
56  appendStringInfo(buf, "offnum %u", xlrec->offnum);
57  }
58  else if (info == XLOG_BRIN_REVMAP_EXTEND)
59  {
61 
62  appendStringInfo(buf, "targetBlk %u", xlrec->targetBlk);
63  }
64  else if (info == XLOG_BRIN_DESUMMARIZE)
65  {
67 
68  appendStringInfo(buf, "pagesPerRange %u, heapBlk %u, page offset %u",
69  xlrec->pagesPerRange, xlrec->heapBlk, xlrec->regOffset);
70  }
71 }
#define XLOG_BRIN_REVMAP_EXTEND
Definition: brin_xlog.h:35
#define XLOG_BRIN_SAMEPAGE_UPDATE
Definition: brin_xlog.h:34
#define XLOG_BRIN_DESUMMARIZE
Definition: brin_xlog.h:36
#define XLOG_BRIN_CREATE_INDEX
Definition: brin_xlog.h:31
#define XLOG_BRIN_OPMASK
Definition: brin_xlog.h:38
#define XLOG_BRIN_UPDATE
Definition: brin_xlog.h:33
#define XLOG_BRIN_INSERT
Definition: brin_xlog.h:32
unsigned char uint8
Definition: c.h:490
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:94
BlockNumber pagesPerRange
Definition: brin_xlog.h:52
BlockNumber pagesPerRange
Definition: brin_xlog.h:135
BlockNumber heapBlk
Definition: brin_xlog.h:137
OffsetNumber regOffset
Definition: brin_xlog.h:139
OffsetNumber offnum
Definition: brin_xlog.h:71
BlockNumber pagesPerRange
Definition: brin_xlog.h:68
BlockNumber heapBlk
Definition: brin_xlog.h:65
BlockNumber targetBlk
Definition: brin_xlog.h:121
OffsetNumber offnum
Definition: brin_xlog.h:104
OffsetNumber oldOffnum
Definition: brin_xlog.h:90
xl_brin_insert insert
Definition: brin_xlog.h:92
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References appendStringInfo(), buf, xl_brin_insert::heapBlk, xl_brin_desummarize::heapBlk, xl_brin_update::insert, xl_brin_insert::offnum, xl_brin_samepage_update::offnum, xl_brin_update::oldOffnum, xl_brin_createidx::pagesPerRange, xl_brin_insert::pagesPerRange, xl_brin_desummarize::pagesPerRange, xl_brin_desummarize::regOffset, xl_brin_revmap_extend::targetBlk, xl_brin_createidx::version, XLOG_BRIN_CREATE_INDEX, XLOG_BRIN_DESUMMARIZE, XLOG_BRIN_INSERT, XLOG_BRIN_OPMASK, XLOG_BRIN_REVMAP_EXTEND, XLOG_BRIN_SAMEPAGE_UPDATE, XLOG_BRIN_UPDATE, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

◆ brin_identify()

const char* brin_identify ( uint8  info)

Definition at line 74 of file brindesc.c.

75 {
76  const char *id = NULL;
77 
78  switch (info & ~XLR_INFO_MASK)
79  {
81  id = "CREATE_INDEX";
82  break;
83  case XLOG_BRIN_INSERT:
84  id = "INSERT";
85  break;
87  id = "INSERT+INIT";
88  break;
89  case XLOG_BRIN_UPDATE:
90  id = "UPDATE";
91  break;
93  id = "UPDATE+INIT";
94  break;
96  id = "SAMEPAGE_UPDATE";
97  break;
99  id = "REVMAP_EXTEND";
100  break;
102  id = "DESUMMARIZE";
103  break;
104  }
105 
106  return id;
107 }
#define XLOG_BRIN_INIT_PAGE
Definition: brin_xlog.h:43

References XLOG_BRIN_CREATE_INDEX, XLOG_BRIN_DESUMMARIZE, XLOG_BRIN_INIT_PAGE, XLOG_BRIN_INSERT, XLOG_BRIN_REVMAP_EXTEND, XLOG_BRIN_SAMEPAGE_UPDATE, XLOG_BRIN_UPDATE, and XLR_INFO_MASK.

◆ brin_mask()

void brin_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 342 of file brin_xlog.c.

343 {
344  Page page = (Page) pagedata;
345  PageHeader pagehdr = (PageHeader) page;
346 
348 
349  mask_page_hint_bits(page);
350 
351  /*
352  * Regular brin pages contain unused space which needs to be masked.
353  * Similarly for meta pages, but mask it only if pd_lower appears to have
354  * been set correctly.
355  */
356  if (BRIN_IS_REGULAR_PAGE(page) ||
357  (BRIN_IS_META_PAGE(page) && pagehdr->pd_lower > SizeOfPageHeaderData))
358  {
359  mask_unused_space(page);
360  }
361 
362  /*
363  * BRIN_EVACUATE_PAGE is not WAL-logged, since it's of no use in recovery.
364  * Mask it. See brin_start_evacuating_page() for details.
365  */
367 }
#define BRIN_IS_META_PAGE(page)
Definition: brin_page.h:55
#define BrinPageFlags(page)
Definition: brin_page.h:46
#define BRIN_EVACUATE_PAGE
Definition: brin_page.h:60
#define BRIN_IS_REGULAR_PAGE(page)
Definition: brin_page.h:57
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
PageHeaderData * PageHeader
Definition: bufpage.h:173
Pointer Page
Definition: bufpage.h:81
#define SizeOfPageHeaderData
Definition: bufpage.h:216
LocationIndex pd_lower
Definition: bufpage.h:165

References BRIN_EVACUATE_PAGE, BRIN_IS_META_PAGE, BRIN_IS_REGULAR_PAGE, BrinPageFlags, mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), PageHeaderData::pd_lower, and SizeOfPageHeaderData.

◆ brin_redo()

void brin_redo ( XLogReaderState record)

Definition at line 309 of file brin_xlog.c.

310 {
311  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
312 
313  switch (info & XLOG_BRIN_OPMASK)
314  {
316  brin_xlog_createidx(record);
317  break;
318  case XLOG_BRIN_INSERT:
319  brin_xlog_insert(record);
320  break;
321  case XLOG_BRIN_UPDATE:
322  brin_xlog_update(record);
323  break;
326  break;
328  brin_xlog_revmap_extend(record);
329  break;
332  break;
333  default:
334  elog(PANIC, "brin_redo: unknown op code %u", info);
335  }
336 }
static void brin_xlog_desummarize_page(XLogReaderState *record)
Definition: brin_xlog.c:269
static void brin_xlog_update(XLogReaderState *record)
Definition: brin_xlog.c:135
static void brin_xlog_revmap_extend(XLogReaderState *record)
Definition: brin_xlog.c:208
static void brin_xlog_createidx(XLogReaderState *record)
Definition: brin_xlog.c:24
static void brin_xlog_insert(XLogReaderState *record)
Definition: brin_xlog.c:124
static void brin_xlog_samepage_update(XLogReaderState *record)
Definition: brin_xlog.c:170
#define PANIC
Definition: elog.h:42
#define elog(elevel,...)
Definition: elog.h:225

References brin_xlog_createidx(), brin_xlog_desummarize_page(), brin_xlog_insert(), brin_xlog_revmap_extend(), brin_xlog_samepage_update(), brin_xlog_update(), elog, PANIC, XLOG_BRIN_CREATE_INDEX, XLOG_BRIN_DESUMMARIZE, XLOG_BRIN_INSERT, XLOG_BRIN_OPMASK, XLOG_BRIN_REVMAP_EXTEND, XLOG_BRIN_SAMEPAGE_UPDATE, XLOG_BRIN_UPDATE, XLogRecGetInfo, and XLR_INFO_MASK.