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

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

Definition at line 55 of file brin_xlog.h.

Referenced by brinbuild().

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

Definition at line 142 of file brin_xlog.h.

Referenced by brinRevmapDesummarizeRange().

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

Definition at line 74 of file brin_xlog.h.

Referenced by brin_doinsert().

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

Definition at line 124 of file brin_xlog.h.

Referenced by revmap_physical_extend().

#define SizeOfBrinSamepageUpdate   (sizeof(OffsetNumber))

Definition at line 107 of file brin_xlog.h.

Referenced by brin_doupdate().

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

Definition at line 95 of file brin_xlog.h.

Referenced by brin_doupdate().

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

#define XLOG_BRIN_DESUMMARIZE   0x50

Definition at line 36 of file brin_xlog.h.

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

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

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

#define XLOG_BRIN_OPMASK   0x70

Definition at line 38 of file brin_xlog.h.

Referenced by brin_desc(), and brin_redo().

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

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

#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

Function Documentation

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:266
#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:218
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:110
#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:214
#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
const char* brin_identify ( uint8  info)

Definition at line 74 of file brindesc.c.

References NULL, 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 NULL
Definition: c.h:229
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BRIN_SAMEPAGE_UPDATE
Definition: brin_xlog.h:34
void brin_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 331 of file brin_xlog.c.

References BRIN_IS_REGULAR_PAGE, mask_page_hint_bits(), mask_page_lsn(), and mask_unused_space().

332 {
333  Page page = (Page) pagedata;
334 
335  mask_page_lsn(page);
336 
337  mask_page_hint_bits(page);
338 
339  if (BRIN_IS_REGULAR_PAGE(page))
340  {
341  /* Regular brin pages contain unused space which needs to be masked. */
342  mask_unused_space(page);
343  }
344 }
void mask_page_hint_bits(Page page)
Definition: bufmask.c:44
#define BRIN_IS_REGULAR_PAGE(page)
Definition: brin_page.h:57
void mask_unused_space(Page page)
Definition: bufmask.c:69
void mask_page_lsn(Page page)
Definition: bufmask.c:30
Pointer Page
Definition: bufpage.h:74
void brin_redo ( XLogReaderState record)

Definition at line 298 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.

299 {
300  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
301 
302  switch (info & XLOG_BRIN_OPMASK)
303  {
305  brin_xlog_createidx(record);
306  break;
307  case XLOG_BRIN_INSERT:
308  brin_xlog_insert(record);
309  break;
310  case XLOG_BRIN_UPDATE:
311  brin_xlog_update(record);
312  break;
315  break;
317  brin_xlog_revmap_extend(record);
318  break;
321  break;
322  default:
323  elog(PANIC, "brin_redo: unknown op code %u", info);
324  }
325 }
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:266
#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:258
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:214
#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