PostgreSQL Source Code  git master
brin_xlog.h File Reference
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/bufpage.h"
#include "storage/itemptr.h"
#include "storage/relfilenode.h"
#include "utils/relcache.h"
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.

Referenced by brinbuild().

◆ SizeOfBrinDesummarize

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

Definition at line 142 of file brin_xlog.h.

Referenced by brinRevmapDesummarizeRange().

◆ SizeOfBrinInsert

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

Definition at line 74 of file brin_xlog.h.

Referenced by brin_doinsert().

◆ SizeOfBrinRevmapExtend

#define SizeOfBrinRevmapExtend
Value:
sizeof(BlockNumber))
uint32 BlockNumber
Definition: block.h:31
#define offsetof(type, field)
Definition: c.h:603

Definition at line 124 of file brin_xlog.h.

Referenced by revmap_physical_extend().

◆ SizeOfBrinSamepageUpdate

#define SizeOfBrinSamepageUpdate   (sizeof(OffsetNumber))

Definition at line 107 of file brin_xlog.h.

Referenced by brin_doupdate().

◆ SizeOfBrinUpdate

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

Definition at line 95 of file brin_xlog.h.

Referenced by brin_doupdate().

◆ XLOG_BRIN_CREATE_INDEX

#define XLOG_BRIN_CREATE_INDEX   0x00

Definition at line 31 of file brin_xlog.h.

Referenced by brin_desc(), brin_identify(), brin_redo(), and brinbuild().

◆ XLOG_BRIN_DESUMMARIZE

#define XLOG_BRIN_DESUMMARIZE   0x50

Definition at line 36 of file brin_xlog.h.

Referenced by brin_desc(), brin_identify(), brin_redo(), and brinRevmapDesummarizeRange().

◆ XLOG_BRIN_INIT_PAGE

#define XLOG_BRIN_INIT_PAGE   0x80

Definition at line 43 of file brin_xlog.h.

Referenced by brin_doinsert(), brin_doupdate(), brin_identify(), and brin_xlog_insert_update().

◆ XLOG_BRIN_INSERT

#define XLOG_BRIN_INSERT   0x10

Definition at line 32 of file brin_xlog.h.

Referenced by brin_desc(), brin_doinsert(), brin_identify(), and brin_redo().

◆ XLOG_BRIN_OPMASK

#define XLOG_BRIN_OPMASK   0x70

Definition at line 38 of file brin_xlog.h.

Referenced by brin_desc(), and brin_redo().

◆ XLOG_BRIN_REVMAP_EXTEND

#define XLOG_BRIN_REVMAP_EXTEND   0x40

Definition at line 35 of file brin_xlog.h.

Referenced by brin_desc(), brin_identify(), brin_redo(), and revmap_physical_extend().

◆ XLOG_BRIN_SAMEPAGE_UPDATE

#define XLOG_BRIN_SAMEPAGE_UPDATE   0x30

Definition at line 34 of file brin_xlog.h.

Referenced by brin_desc(), brin_doupdate(), brin_identify(), and brin_redo().

◆ XLOG_BRIN_UPDATE

#define XLOG_BRIN_UPDATE   0x20

Definition at line 33 of file brin_xlog.h.

Referenced by brin_desc(), brin_doupdate(), brin_identify(), and brin_redo().

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.

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

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 }
BlockNumber heapBlk
Definition: brin_xlog.h:65
OffsetNumber regOffset
Definition: brin_xlog.h:139
BlockNumber pagesPerRange
Definition: brin_xlog.h:135
OffsetNumber offnum
Definition: brin_xlog.h:104
unsigned char uint8
Definition: c.h:304
#define XLOG_BRIN_CREATE_INDEX
Definition: brin_xlog.h:31
#define XLOG_BRIN_UPDATE
Definition: brin_xlog.h:33
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
#define XLOG_BRIN_DESUMMARIZE
Definition: brin_xlog.h:36
BlockNumber pagesPerRange
Definition: brin_xlog.h:68
BlockNumber targetBlk
Definition: brin_xlog.h:121
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_BRIN_REVMAP_EXTEND
Definition: brin_xlog.h:35
#define XLOG_BRIN_INSERT
Definition: brin_xlog.h:32
xl_brin_insert insert
Definition: brin_xlog.h:92
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BRIN_SAMEPAGE_UPDATE
Definition: brin_xlog.h:34
OffsetNumber offnum
Definition: brin_xlog.h:71
BlockNumber heapBlk
Definition: brin_xlog.h:137
#define XLOG_BRIN_OPMASK
Definition: brin_xlog.h:38
BlockNumber pagesPerRange
Definition: brin_xlog.h:52
OffsetNumber oldOffnum
Definition: brin_xlog.h:90

◆ brin_identify()

const char* brin_identify ( uint8  info)

Definition at line 74 of file brindesc.c.

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.

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_CREATE_INDEX
Definition: brin_xlog.h:31
#define XLOG_BRIN_UPDATE
Definition: brin_xlog.h:33
#define XLOG_BRIN_DESUMMARIZE
Definition: brin_xlog.h:36
#define XLOG_BRIN_REVMAP_EXTEND
Definition: brin_xlog.h:35
#define XLOG_BRIN_INIT_PAGE
Definition: brin_xlog.h:43
#define XLOG_BRIN_INSERT
Definition: brin_xlog.h:32
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BRIN_SAMEPAGE_UPDATE
Definition: brin_xlog.h:34

◆ brin_mask()

void brin_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 342 of file brin_xlog.c.

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

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 }
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define BRIN_IS_REGULAR_PAGE(page)
Definition: brin_page.h:57
#define SizeOfPageHeaderData
Definition: bufpage.h:212
void mask_unused_space(Page page)
Definition: bufmask.c:71
#define BRIN_IS_META_PAGE(page)
Definition: brin_page.h:55
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
PageHeaderData * PageHeader
Definition: bufpage.h:162
Pointer Page
Definition: bufpage.h:74
LocationIndex pd_lower
Definition: bufpage.h:154

◆ brin_redo()

void brin_redo ( XLogReaderState record)

Definition at line 309 of file brin_xlog.c.

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.

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_revmap_extend(XLogReaderState *record)
Definition: brin_xlog.c:208
static void brin_xlog_update(XLogReaderState *record)
Definition: brin_xlog.c:135
static void brin_xlog_createidx(XLogReaderState *record)
Definition: brin_xlog.c:24
unsigned char uint8
Definition: c.h:304
#define XLOG_BRIN_CREATE_INDEX
Definition: brin_xlog.h:31
#define PANIC
Definition: elog.h:53
#define XLOG_BRIN_UPDATE
Definition: brin_xlog.h:33
static void brin_xlog_insert(XLogReaderState *record)
Definition: brin_xlog.c:124
#define XLOG_BRIN_DESUMMARIZE
Definition: brin_xlog.h:36
static void brin_xlog_desummarize_page(XLogReaderState *record)
Definition: brin_xlog.c:269
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_BRIN_REVMAP_EXTEND
Definition: brin_xlog.h:35
#define XLOG_BRIN_INSERT
Definition: brin_xlog.h:32
static void brin_xlog_samepage_update(XLogReaderState *record)
Definition: brin_xlog.c:170
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BRIN_SAMEPAGE_UPDATE
Definition: brin_xlog.h:34
#define XLOG_BRIN_OPMASK
Definition: brin_xlog.h:38
#define elog
Definition: elog.h:219