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
 

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_REVMAP_VACUUM   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
 

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
 

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 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_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_REVMAP_VACUUM   0x50

Definition at line 36 of file brin_xlog.h.

#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_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_revmap_extend::targetBlk, xl_brin_createidx::version, XLOG_BRIN_CREATE_INDEX, 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 }
BlockNumber heapBlk
Definition: brin_xlog.h:65
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
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
#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 67 of file brindesc.c.

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

68 {
69  const char *id = NULL;
70 
71  switch (info & ~XLR_INFO_MASK)
72  {
74  id = "CREATE_INDEX";
75  break;
76  case XLOG_BRIN_INSERT:
77  id = "INSERT";
78  break;
80  id = "INSERT+INIT";
81  break;
82  case XLOG_BRIN_UPDATE:
83  id = "UPDATE";
84  break;
86  id = "UPDATE+INIT";
87  break;
89  id = "SAMEPAGE_UPDATE";
90  break;
92  id = "REVMAP_EXTEND";
93  break;
94  }
95 
96  return id;
97 }
#define XLOG_BRIN_CREATE_INDEX
Definition: brin_xlog.h:31
#define XLOG_BRIN_UPDATE
Definition: brin_xlog.h:33
#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 288 of file brin_xlog.c.

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

289 {
290  Page page = (Page) pagedata;
291 
292  mask_page_lsn(page);
293 
294  mask_page_hint_bits(page);
295 
296  if (BRIN_IS_REGULAR_PAGE(page))
297  {
298  /* Regular brin pages contain unused space which needs to be masked. */
299  mask_unused_space(page);
300  }
301 }
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 258 of file brin_xlog.c.

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

259 {
260  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
261 
262  switch (info & XLOG_BRIN_OPMASK)
263  {
265  brin_xlog_createidx(record);
266  break;
267  case XLOG_BRIN_INSERT:
268  brin_xlog_insert(record);
269  break;
270  case XLOG_BRIN_UPDATE:
271  brin_xlog_update(record);
272  break;
275  break;
277  brin_xlog_revmap_extend(record);
278  break;
279  default:
280  elog(PANIC, "brin_redo: unknown op code %u", info);
281  }
282 }
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 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