PostgreSQL Source Code  git master
nbtxlog.h File Reference
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/off.h"
Include dependency graph for nbtxlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_btree_metadata
 
struct  xl_btree_insert
 
struct  xl_btree_split
 
struct  xl_btree_dedup
 
struct  xl_btree_delete
 
struct  xl_btree_reuse_page
 
struct  xl_btree_update
 
struct  xl_btree_vacuum
 
struct  xl_btree_mark_page_halfdead
 
struct  xl_btree_unlink_page
 
struct  xl_btree_newroot
 

Macros

#define XLOG_BTREE_INSERT_LEAF   0x00 /* add index tuple without split */
 
#define XLOG_BTREE_INSERT_UPPER   0x10 /* same, on a non-leaf page */
 
#define XLOG_BTREE_INSERT_META   0x20 /* same, plus update metapage */
 
#define XLOG_BTREE_SPLIT_L   0x30 /* add index tuple with split */
 
#define XLOG_BTREE_SPLIT_R   0x40 /* as above, new item on right */
 
#define XLOG_BTREE_INSERT_POST   0x50 /* add index tuple with posting split */
 
#define XLOG_BTREE_DEDUP   0x60 /* deduplicate tuples for a page */
 
#define XLOG_BTREE_DELETE   0x70 /* delete leaf index tuples for a page */
 
#define XLOG_BTREE_UNLINK_PAGE   0x80 /* delete a half-dead page */
 
#define XLOG_BTREE_UNLINK_PAGE_META   0x90 /* same, and update metapage */
 
#define XLOG_BTREE_NEWROOT   0xA0 /* new root page */
 
#define XLOG_BTREE_MARK_PAGE_HALFDEAD   0xB0 /* mark a leaf as half-dead */
 
#define XLOG_BTREE_VACUUM
 
#define XLOG_BTREE_REUSE_PAGE
 
#define XLOG_BTREE_META_CLEANUP
 
#define SizeOfBtreeInsert   (offsetof(xl_btree_insert, offnum) + sizeof(OffsetNumber))
 
#define SizeOfBtreeSplit   (offsetof(xl_btree_split, postingoff) + sizeof(uint16))
 
#define SizeOfBtreeDedup   (offsetof(xl_btree_dedup, nintervals) + sizeof(uint16))
 
#define SizeOfBtreeDelete   (offsetof(xl_btree_delete, ndeleted) + sizeof(uint32))
 
#define SizeOfBtreeReusePage   (sizeof(xl_btree_reuse_page))
 
#define SizeOfBtreeUpdate   (offsetof(xl_btree_update, ndeletedtids) + sizeof(uint16))
 
#define SizeOfBtreeVacuum   (offsetof(xl_btree_vacuum, nupdated) + sizeof(uint16))
 
#define SizeOfBtreeMarkPageHalfDead   (offsetof(xl_btree_mark_page_halfdead, topparent) + sizeof(BlockNumber))
 
#define SizeOfBtreeUnlinkPage   (offsetof(xl_btree_unlink_page, btpo_xact) + sizeof(TransactionId))
 
#define SizeOfBtreeNewroot   (offsetof(xl_btree_newroot, level) + sizeof(uint32))
 

Typedefs

typedef struct xl_btree_metadata xl_btree_metadata
 
typedef struct xl_btree_insert xl_btree_insert
 
typedef struct xl_btree_split xl_btree_split
 
typedef struct xl_btree_dedup xl_btree_dedup
 
typedef struct xl_btree_delete xl_btree_delete
 
typedef struct xl_btree_reuse_page xl_btree_reuse_page
 
typedef struct xl_btree_update xl_btree_update
 
typedef struct xl_btree_vacuum xl_btree_vacuum
 
typedef struct xl_btree_mark_page_halfdead xl_btree_mark_page_halfdead
 
typedef struct xl_btree_unlink_page xl_btree_unlink_page
 
typedef struct xl_btree_newroot xl_btree_newroot
 

Functions

void btree_redo (XLogReaderState *record)
 
void btree_desc (StringInfo buf, XLogReaderState *record)
 
const char * btree_identify (uint8 info)
 
void btree_xlog_startup (void)
 
void btree_xlog_cleanup (void)
 
void btree_mask (char *pagedata, BlockNumber blkno)
 

Macro Definition Documentation

◆ SizeOfBtreeDedup

#define SizeOfBtreeDedup   (offsetof(xl_btree_dedup, nintervals) + sizeof(uint16))

Definition at line 177 of file nbtxlog.h.

Referenced by _bt_dedup_one_page().

◆ SizeOfBtreeDelete

#define SizeOfBtreeDelete   (offsetof(xl_btree_delete, ndeleted) + sizeof(uint32))

Definition at line 195 of file nbtxlog.h.

Referenced by _bt_delitems_delete().

◆ SizeOfBtreeInsert

#define SizeOfBtreeInsert   (offsetof(xl_btree_insert, offnum) + sizeof(OffsetNumber))

Definition at line 87 of file nbtxlog.h.

Referenced by _bt_insertonpg().

◆ SizeOfBtreeMarkPageHalfDead

#define SizeOfBtreeMarkPageHalfDead   (offsetof(xl_btree_mark_page_halfdead, topparent) + sizeof(BlockNumber))

Definition at line 273 of file nbtxlog.h.

Referenced by _bt_mark_page_halfdead().

◆ SizeOfBtreeNewroot

#define SizeOfBtreeNewroot   (offsetof(xl_btree_newroot, level) + sizeof(uint32))

Definition at line 322 of file nbtxlog.h.

Referenced by _bt_getroot(), and _bt_newroot().

◆ SizeOfBtreeReusePage

#define SizeOfBtreeReusePage   (sizeof(xl_btree_reuse_page))

Definition at line 211 of file nbtxlog.h.

Referenced by _bt_log_reuse_page().

◆ SizeOfBtreeSplit

#define SizeOfBtreeSplit   (offsetof(xl_btree_split, postingoff) + sizeof(uint16))

Definition at line 161 of file nbtxlog.h.

Referenced by _bt_split().

◆ SizeOfBtreeUnlinkPage

#define SizeOfBtreeUnlinkPage   (offsetof(xl_btree_unlink_page, btpo_xact) + sizeof(TransactionId))

Definition at line 303 of file nbtxlog.h.

Referenced by _bt_unlink_halfdead_page().

◆ SizeOfBtreeUpdate

#define SizeOfBtreeUpdate   (offsetof(xl_btree_update, ndeletedtids) + sizeof(uint16))

Definition at line 225 of file nbtxlog.h.

Referenced by _bt_delitems_vacuum(), and btree_xlog_vacuum().

◆ SizeOfBtreeVacuum

#define SizeOfBtreeVacuum   (offsetof(xl_btree_vacuum, nupdated) + sizeof(uint16))

Definition at line 250 of file nbtxlog.h.

Referenced by _bt_delitems_vacuum().

◆ XLOG_BTREE_DEDUP

#define XLOG_BTREE_DEDUP   0x60 /* deduplicate tuples for a page */

Definition at line 32 of file nbtxlog.h.

Referenced by _bt_dedup_one_page(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_DELETE

#define XLOG_BTREE_DELETE   0x70 /* delete leaf index tuples for a page */

Definition at line 33 of file nbtxlog.h.

Referenced by _bt_delitems_delete(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_INSERT_LEAF

#define XLOG_BTREE_INSERT_LEAF   0x00 /* add index tuple without split */

Definition at line 26 of file nbtxlog.h.

Referenced by _bt_insertonpg(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_INSERT_META

#define XLOG_BTREE_INSERT_META   0x20 /* same, plus update metapage */

Definition at line 28 of file nbtxlog.h.

Referenced by _bt_insertonpg(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_INSERT_POST

#define XLOG_BTREE_INSERT_POST   0x50 /* add index tuple with posting split */

Definition at line 31 of file nbtxlog.h.

Referenced by _bt_insertonpg(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_INSERT_UPPER

#define XLOG_BTREE_INSERT_UPPER   0x10 /* same, on a non-leaf page */

Definition at line 27 of file nbtxlog.h.

Referenced by _bt_insertonpg(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_MARK_PAGE_HALFDEAD

#define XLOG_BTREE_MARK_PAGE_HALFDEAD   0xB0 /* mark a leaf as half-dead */

Definition at line 37 of file nbtxlog.h.

Referenced by _bt_mark_page_halfdead(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_META_CLEANUP

#define XLOG_BTREE_META_CLEANUP
Value:
0xE0 /* update cleanup-related data in the
* metapage */

Definition at line 42 of file nbtxlog.h.

Referenced by _bt_update_meta_cleanup_info(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_NEWROOT

#define XLOG_BTREE_NEWROOT   0xA0 /* new root page */

Definition at line 36 of file nbtxlog.h.

Referenced by _bt_getroot(), _bt_newroot(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_REUSE_PAGE

#define XLOG_BTREE_REUSE_PAGE
Value:
0xD0 /* old page is about to be reused from
* FSM */

Definition at line 40 of file nbtxlog.h.

Referenced by _bt_log_reuse_page(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_SPLIT_L

#define XLOG_BTREE_SPLIT_L   0x30 /* add index tuple with split */

Definition at line 29 of file nbtxlog.h.

Referenced by _bt_split(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_SPLIT_R

#define XLOG_BTREE_SPLIT_R   0x40 /* as above, new item on right */

Definition at line 30 of file nbtxlog.h.

Referenced by _bt_split(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_UNLINK_PAGE

#define XLOG_BTREE_UNLINK_PAGE   0x80 /* delete a half-dead page */

Definition at line 34 of file nbtxlog.h.

Referenced by _bt_unlink_halfdead_page(), btree_desc(), btree_identify(), and btree_redo().

◆ XLOG_BTREE_UNLINK_PAGE_META

#define XLOG_BTREE_UNLINK_PAGE_META   0x90 /* same, and update metapage */

◆ XLOG_BTREE_VACUUM

#define XLOG_BTREE_VACUUM
Value:
0xC0 /* delete entries on a page during
* vacuum */

Definition at line 38 of file nbtxlog.h.

Referenced by _bt_delitems_vacuum(), btree_desc(), btree_identify(), and btree_redo().

Typedef Documentation

◆ xl_btree_dedup

◆ xl_btree_delete

◆ xl_btree_insert

◆ xl_btree_mark_page_halfdead

◆ xl_btree_metadata

◆ xl_btree_newroot

◆ xl_btree_reuse_page

◆ xl_btree_split

◆ xl_btree_unlink_page

◆ xl_btree_update

◆ xl_btree_vacuum

Function Documentation

◆ btree_desc()

void btree_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 20 of file nbtdesc.c.

References appendStringInfo(), xl_btree_unlink_page::btpo_xact, RelFileNode::dbNode, xl_btree_split::firstright, xl_btree_metadata::last_cleanup_num_heap_tuples, xl_btree_delete::latestRemovedXid, xl_btree_reuse_page::latestRemovedXid, xl_btree_mark_page_halfdead::leafblk, xl_btree_unlink_page::leafleftsib, xl_btree_unlink_page::leafrightsib, xl_btree_mark_page_halfdead::leftblk, xl_btree_unlink_page::leftsib, xl_btree_split::level, xl_btree_newroot::level, xl_btree_delete::ndeleted, xl_btree_vacuum::ndeleted, xl_btree_split::newitemoff, xl_btree_dedup::nintervals, xl_btree_reuse_page::node, xl_btree_vacuum::nupdated, xl_btree_insert::offnum, xl_btree_metadata::oldest_btpo_xact, xl_btree_split::postingoff, RelFileNode::relNode, xl_btree_mark_page_halfdead::rightblk, xl_btree_unlink_page::rightsib, RelFileNode::spcNode, xl_btree_mark_page_halfdead::topparent, xl_btree_unlink_page::topparent, XLOG_BTREE_DEDUP, XLOG_BTREE_DELETE, XLOG_BTREE_INSERT_LEAF, XLOG_BTREE_INSERT_META, XLOG_BTREE_INSERT_POST, XLOG_BTREE_INSERT_UPPER, XLOG_BTREE_MARK_PAGE_HALFDEAD, XLOG_BTREE_META_CLEANUP, XLOG_BTREE_NEWROOT, XLOG_BTREE_REUSE_PAGE, XLOG_BTREE_SPLIT_L, XLOG_BTREE_SPLIT_R, XLOG_BTREE_UNLINK_PAGE, XLOG_BTREE_UNLINK_PAGE_META, XLOG_BTREE_VACUUM, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

21 {
22  char *rec = XLogRecGetData(record);
23  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24 
25  switch (info)
26  {
31  {
32  xl_btree_insert *xlrec = (xl_btree_insert *) rec;
33 
34  appendStringInfo(buf, "off %u", xlrec->offnum);
35  break;
36  }
37  case XLOG_BTREE_SPLIT_L:
38  case XLOG_BTREE_SPLIT_R:
39  {
40  xl_btree_split *xlrec = (xl_btree_split *) rec;
41 
42  appendStringInfo(buf, "level %u, firstright %d, newitemoff %d, postingoff %d",
43  xlrec->level, xlrec->firstright,
44  xlrec->newitemoff, xlrec->postingoff);
45  break;
46  }
47  case XLOG_BTREE_DEDUP:
48  {
49  xl_btree_dedup *xlrec = (xl_btree_dedup *) rec;
50 
51  appendStringInfo(buf, "nintervals %u", xlrec->nintervals);
52  break;
53  }
54  case XLOG_BTREE_VACUUM:
55  {
56  xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
57 
58  appendStringInfo(buf, "ndeleted %u; nupdated %u",
59  xlrec->ndeleted, xlrec->nupdated);
60  break;
61  }
62  case XLOG_BTREE_DELETE:
63  {
64  xl_btree_delete *xlrec = (xl_btree_delete *) rec;
65 
66  appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u",
67  xlrec->latestRemovedXid, xlrec->ndeleted);
68  break;
69  }
71  {
73 
74  appendStringInfo(buf, "topparent %u; leaf %u; left %u; right %u",
75  xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
76  break;
77  }
80  {
82 
83  appendStringInfo(buf, "left %u; right %u; btpo_xact %u; ",
84  xlrec->leftsib, xlrec->rightsib,
85  xlrec->btpo_xact);
86  appendStringInfo(buf, "leafleft %u; leafright %u; topparent %u",
87  xlrec->leafleftsib, xlrec->leafrightsib,
88  xlrec->topparent);
89  break;
90  }
91  case XLOG_BTREE_NEWROOT:
92  {
93  xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
94 
95  appendStringInfo(buf, "lev %u", xlrec->level);
96  break;
97  }
99  {
100  xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
101 
102  appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u",
103  xlrec->node.spcNode, xlrec->node.dbNode,
104  xlrec->node.relNode, xlrec->latestRemovedXid);
105  break;
106  }
108  {
109  xl_btree_metadata *xlrec;
110 
111  xlrec = (xl_btree_metadata *) XLogRecGetBlockData(record, 0,
112  NULL);
113  appendStringInfo(buf, "oldest_btpo_xact %u; last_cleanup_num_heap_tuples: %f",
114  xlrec->oldest_btpo_xact,
116  break;
117  }
118  }
119 }
TransactionId latestRemovedXid
Definition: nbtxlog.h:189
uint16 nintervals
Definition: nbtxlog.h:172
unsigned char uint8
Definition: c.h:365
#define XLOG_BTREE_INSERT_META
Definition: nbtxlog.h:28
RelFileNode node
Definition: nbtxlog.h:206
uint32 level
Definition: nbtxlog.h:319
uint16 nupdated
Definition: nbtxlog.h:243
uint32 ndeleted
Definition: nbtxlog.h:190
#define XLOG_BTREE_NEWROOT
Definition: nbtxlog.h:36
#define XLogRecGetData(decoder)
Definition: xlogreader.h:288
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
float8 last_cleanup_num_heap_tuples
Definition: nbtxlog.h:56
#define XLOG_BTREE_INSERT_LEAF
Definition: nbtxlog.h:26
OffsetNumber newitemoff
Definition: nbtxlog.h:157
TransactionId oldest_btpo_xact
Definition: nbtxlog.h:55
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:38
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:34
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:284
#define XLOG_BTREE_DELETE
Definition: nbtxlog.h:33
uint16 ndeleted
Definition: nbtxlog.h:242
#define XLOG_BTREE_DEDUP
Definition: nbtxlog.h:32
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:1505
#define XLOG_BTREE_REUSE_PAGE
Definition: nbtxlog.h:40
uint32 level
Definition: nbtxlog.h:155
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition: nbtxlog.h:37
OffsetNumber offnum
Definition: nbtxlog.h:81
#define XLOG_BTREE_SPLIT_R
Definition: nbtxlog.h:30
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
OffsetNumber firstright
Definition: nbtxlog.h:156
#define XLOG_BTREE_INSERT_POST
Definition: nbtxlog.h:31
#define XLOG_BTREE_INSERT_UPPER
Definition: nbtxlog.h:27
#define XLOG_BTREE_SPLIT_L
Definition: nbtxlog.h:29
#define XLOG_BTREE_UNLINK_PAGE_META
Definition: nbtxlog.h:35
TransactionId latestRemovedXid
Definition: nbtxlog.h:208
uint16 postingoff
Definition: nbtxlog.h:158
#define XLOG_BTREE_META_CLEANUP
Definition: nbtxlog.h:42

◆ btree_identify()

const char* btree_identify ( uint8  info)

Definition at line 122 of file nbtdesc.c.

References XLOG_BTREE_DEDUP, XLOG_BTREE_DELETE, XLOG_BTREE_INSERT_LEAF, XLOG_BTREE_INSERT_META, XLOG_BTREE_INSERT_POST, XLOG_BTREE_INSERT_UPPER, XLOG_BTREE_MARK_PAGE_HALFDEAD, XLOG_BTREE_META_CLEANUP, XLOG_BTREE_NEWROOT, XLOG_BTREE_REUSE_PAGE, XLOG_BTREE_SPLIT_L, XLOG_BTREE_SPLIT_R, XLOG_BTREE_UNLINK_PAGE, XLOG_BTREE_UNLINK_PAGE_META, XLOG_BTREE_VACUUM, and XLR_INFO_MASK.

123 {
124  const char *id = NULL;
125 
126  switch (info & ~XLR_INFO_MASK)
127  {
129  id = "INSERT_LEAF";
130  break;
132  id = "INSERT_UPPER";
133  break;
135  id = "INSERT_META";
136  break;
137  case XLOG_BTREE_SPLIT_L:
138  id = "SPLIT_L";
139  break;
140  case XLOG_BTREE_SPLIT_R:
141  id = "SPLIT_R";
142  break;
144  id = "INSERT_POST";
145  break;
146  case XLOG_BTREE_DEDUP:
147  id = "DEDUP";
148  break;
149  case XLOG_BTREE_VACUUM:
150  id = "VACUUM";
151  break;
152  case XLOG_BTREE_DELETE:
153  id = "DELETE";
154  break;
156  id = "MARK_PAGE_HALFDEAD";
157  break;
159  id = "UNLINK_PAGE";
160  break;
162  id = "UNLINK_PAGE_META";
163  break;
164  case XLOG_BTREE_NEWROOT:
165  id = "NEWROOT";
166  break;
168  id = "REUSE_PAGE";
169  break;
171  id = "META_CLEANUP";
172  break;
173  }
174 
175  return id;
176 }
#define XLOG_BTREE_INSERT_META
Definition: nbtxlog.h:28
#define XLOG_BTREE_NEWROOT
Definition: nbtxlog.h:36
#define XLOG_BTREE_INSERT_LEAF
Definition: nbtxlog.h:26
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:38
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:34
#define XLOG_BTREE_DELETE
Definition: nbtxlog.h:33
#define XLOG_BTREE_DEDUP
Definition: nbtxlog.h:32
#define XLOG_BTREE_REUSE_PAGE
Definition: nbtxlog.h:40
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition: nbtxlog.h:37
#define XLOG_BTREE_SPLIT_R
Definition: nbtxlog.h:30
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BTREE_INSERT_POST
Definition: nbtxlog.h:31
#define XLOG_BTREE_INSERT_UPPER
Definition: nbtxlog.h:27
#define XLOG_BTREE_SPLIT_L
Definition: nbtxlog.h:29
#define XLOG_BTREE_UNLINK_PAGE_META
Definition: nbtxlog.h:35
#define XLOG_BTREE_META_CLEANUP
Definition: nbtxlog.h:42

◆ btree_mask()

void btree_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 1020 of file nbtxlog.c.

References BTP_HAS_GARBAGE, BTP_SPLIT_END, BTPageOpaqueData::btpo_cycleid, BTPageOpaqueData::btpo_flags, mask_lp_flags(), mask_page_content(), mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), P_ISDELETED, P_ISLEAF, and PageGetSpecialPointer.

1021 {
1022  Page page = (Page) pagedata;
1023  BTPageOpaque maskopaq;
1024 
1026 
1027  mask_page_hint_bits(page);
1028  mask_unused_space(page);
1029 
1030  maskopaq = (BTPageOpaque) PageGetSpecialPointer(page);
1031 
1032  if (P_ISDELETED(maskopaq))
1033  {
1034  /*
1035  * Mask page content on a DELETED page since it will be re-initialized
1036  * during replay. See btree_xlog_unlink_page() for details.
1037  */
1038  mask_page_content(page);
1039  }
1040  else if (P_ISLEAF(maskopaq))
1041  {
1042  /*
1043  * In btree leaf pages, it is possible to modify the LP_FLAGS without
1044  * emitting any WAL record. Hence, mask the line pointer flags. See
1045  * _bt_killitems(), _bt_check_unique() for details.
1046  */
1047  mask_lp_flags(page);
1048  }
1049 
1050  /*
1051  * BTP_HAS_GARBAGE is just an un-logged hint bit. So, mask it. See
1052  * _bt_killitems(), _bt_check_unique() for details.
1053  */
1054  maskopaq->btpo_flags &= ~BTP_HAS_GARBAGE;
1055 
1056  /*
1057  * During replay of a btree page split, we don't set the BTP_SPLIT_END
1058  * flag of the right sibling and initialize the cycle_id to 0 for the same
1059  * page. See btree_xlog_split() for details.
1060  */
1061  maskopaq->btpo_flags &= ~BTP_SPLIT_END;
1062  maskopaq->btpo_cycleid = 0;
1063 }
#define BTP_SPLIT_END
Definition: nbtree.h:77
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
BTPageOpaqueData * BTPageOpaque
Definition: nbtree.h:69
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_content(Page page)
Definition: bufmask.c:119
BTCycleId btpo_cycleid
Definition: nbtree.h:66
#define P_ISDELETED(opaque)
Definition: nbtree.h:216
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
#define PageGetSpecialPointer(page)
Definition: bufpage.h:326
uint16 btpo_flags
Definition: nbtree.h:65
void mask_lp_flags(Page page)
Definition: bufmask.c:95
#define BTP_HAS_GARBAGE
Definition: nbtree.h:78
Pointer Page
Definition: bufpage.h:78
#define P_ISLEAF(opaque)
Definition: nbtree.h:214

◆ btree_redo()

void btree_redo ( XLogReaderState record)

Definition at line 943 of file nbtxlog.c.

References _bt_restore_meta(), btree_xlog_dedup(), btree_xlog_delete(), btree_xlog_insert(), btree_xlog_mark_page_halfdead(), btree_xlog_newroot(), btree_xlog_reuse_page(), btree_xlog_split(), btree_xlog_unlink_page(), btree_xlog_vacuum(), elog, MemoryContextReset(), MemoryContextSwitchTo(), PANIC, XLOG_BTREE_DEDUP, XLOG_BTREE_DELETE, XLOG_BTREE_INSERT_LEAF, XLOG_BTREE_INSERT_META, XLOG_BTREE_INSERT_POST, XLOG_BTREE_INSERT_UPPER, XLOG_BTREE_MARK_PAGE_HALFDEAD, XLOG_BTREE_META_CLEANUP, XLOG_BTREE_NEWROOT, XLOG_BTREE_REUSE_PAGE, XLOG_BTREE_SPLIT_L, XLOG_BTREE_SPLIT_R, XLOG_BTREE_UNLINK_PAGE, XLOG_BTREE_UNLINK_PAGE_META, XLOG_BTREE_VACUUM, XLogRecGetInfo, and XLR_INFO_MASK.

944 {
945  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
946  MemoryContext oldCtx;
947 
948  oldCtx = MemoryContextSwitchTo(opCtx);
949  switch (info)
950  {
952  btree_xlog_insert(true, false, false, record);
953  break;
955  btree_xlog_insert(false, false, false, record);
956  break;
958  btree_xlog_insert(false, true, false, record);
959  break;
960  case XLOG_BTREE_SPLIT_L:
961  btree_xlog_split(true, record);
962  break;
963  case XLOG_BTREE_SPLIT_R:
964  btree_xlog_split(false, record);
965  break;
967  btree_xlog_insert(true, false, true, record);
968  break;
969  case XLOG_BTREE_DEDUP:
970  btree_xlog_dedup(record);
971  break;
972  case XLOG_BTREE_VACUUM:
973  btree_xlog_vacuum(record);
974  break;
975  case XLOG_BTREE_DELETE:
976  btree_xlog_delete(record);
977  break;
979  btree_xlog_mark_page_halfdead(info, record);
980  break;
983  btree_xlog_unlink_page(info, record);
984  break;
985  case XLOG_BTREE_NEWROOT:
986  btree_xlog_newroot(record);
987  break;
989  btree_xlog_reuse_page(record);
990  break;
992  _bt_restore_meta(record, 0);
993  break;
994  default:
995  elog(PANIC, "btree_redo: unknown op code %u", info);
996  }
997  MemoryContextSwitchTo(oldCtx);
999 }
static void btree_xlog_vacuum(XLogReaderState *record)
Definition: nbtxlog.c:557
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
unsigned char uint8
Definition: c.h:365
#define XLOG_BTREE_INSERT_META
Definition: nbtxlog.h:28
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:136
static void btree_xlog_delete(XLogReaderState *record)
Definition: nbtxlog.c:644
#define PANIC
Definition: elog.h:53
#define XLOG_BTREE_NEWROOT
Definition: nbtxlog.h:36
static void _bt_restore_meta(XLogReaderState *record, uint8 block_id)
Definition: nbtxlog.c:85
static void btree_xlog_newroot(XLogReaderState *record)
Definition: nbtxlog.c:881
static void btree_xlog_reuse_page(XLogReaderState *record)
Definition: nbtxlog.c:921
#define XLOG_BTREE_INSERT_LEAF
Definition: nbtxlog.h:26
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:38
static void btree_xlog_split(bool onleft, XLogReaderState *record)
Definition: nbtxlog.c:254
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:34
static void btree_xlog_dedup(XLogReaderState *record)
Definition: nbtxlog.c:465
static void btree_xlog_insert(bool isleaf, bool ismeta, bool posting, XLogReaderState *record)
Definition: nbtxlog.c:163
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:284
#define XLOG_BTREE_DELETE
Definition: nbtxlog.h:33
#define XLOG_BTREE_DEDUP
Definition: nbtxlog.h:32
#define XLOG_BTREE_REUSE_PAGE
Definition: nbtxlog.h:40
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition: nbtxlog.h:37
#define XLOG_BTREE_SPLIT_R
Definition: nbtxlog.h:30
static MemoryContext opCtx
Definition: nbtxlog.c:27
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_BTREE_INSERT_POST
Definition: nbtxlog.h:31
static void btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
Definition: nbtxlog.c:769
#define XLOG_BTREE_INSERT_UPPER
Definition: nbtxlog.h:27
static void btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record)
Definition: nbtxlog.c:689
#define elog(elevel,...)
Definition: elog.h:228
#define XLOG_BTREE_SPLIT_L
Definition: nbtxlog.h:29
#define XLOG_BTREE_UNLINK_PAGE_META
Definition: nbtxlog.h:35
#define XLOG_BTREE_META_CLEANUP
Definition: nbtxlog.h:42

◆ btree_xlog_cleanup()

void btree_xlog_cleanup ( void  )

Definition at line 1010 of file nbtxlog.c.

References MemoryContextDelete().

1011 {
1013  opCtx = NULL;
1014 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
static MemoryContext opCtx
Definition: nbtxlog.c:27

◆ btree_xlog_startup()

void btree_xlog_startup ( void  )

Definition at line 1002 of file nbtxlog.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, and CurrentMemoryContext.

1003 {
1005  "Btree recovery temporary context",
1007 }
#define AllocSetContextCreate
Definition: memutils.h:170
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
static MemoryContext opCtx
Definition: nbtxlog.c:27