PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nbtxlog.h File Reference
#include "access/transam.h"
#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_reuse_page
 
struct  xl_btree_vacuum
 
struct  xl_btree_delete
 
struct  xl_btree_update
 
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 SizeOfBtreeReusePage   (offsetof(xl_btree_reuse_page, isCatalogRel) + sizeof(bool))
 
#define SizeOfBtreeVacuum   (offsetof(xl_btree_vacuum, nupdated) + sizeof(uint16))
 
#define SizeOfBtreeDelete   (offsetof(xl_btree_delete, isCatalogRel) + sizeof(bool))
 
#define SizeOfBtreeUpdate   (offsetof(xl_btree_update, ndeletedtids) + sizeof(uint16))
 
#define SizeOfBtreeMarkPageHalfDead   (offsetof(xl_btree_mark_page_halfdead, topparent) + sizeof(BlockNumber))
 
#define SizeOfBtreeUnlinkPage   (offsetof(xl_btree_unlink_page, leaftopparent) + sizeof(BlockNumber))
 
#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_reuse_page xl_btree_reuse_page
 
typedef struct xl_btree_vacuum xl_btree_vacuum
 
typedef struct xl_btree_delete xl_btree_delete
 
typedef struct xl_btree_update xl_btree_update
 
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_xlog_startup (void)
 
void btree_xlog_cleanup (void)
 
void btree_mask (char *pagedata, BlockNumber blkno)
 
void btree_desc (StringInfo buf, XLogReaderState *record)
 
const charbtree_identify (uint8 info)
 

Macro Definition Documentation

◆ SizeOfBtreeDedup

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

Definition at line 174 of file nbtxlog.h.

◆ SizeOfBtreeDelete

#define SizeOfBtreeDelete   (offsetof(xl_btree_delete, isCatalogRel) + sizeof(bool))

Definition at line 253 of file nbtxlog.h.

◆ SizeOfBtreeInsert

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

Definition at line 84 of file nbtxlog.h.

◆ SizeOfBtreeMarkPageHalfDead

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

Definition at line 291 of file nbtxlog.h.

◆ SizeOfBtreeNewroot

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

Definition at line 347 of file nbtxlog.h.

◆ SizeOfBtreeReusePage

#define SizeOfBtreeReusePage   (offsetof(xl_btree_reuse_page, isCatalogRel) + sizeof(bool))

Definition at line 192 of file nbtxlog.h.

◆ SizeOfBtreeSplit

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

Definition at line 158 of file nbtxlog.h.

◆ SizeOfBtreeUnlinkPage

#define SizeOfBtreeUnlinkPage   (offsetof(xl_btree_unlink_page, leaftopparent) + sizeof(BlockNumber))

Definition at line 328 of file nbtxlog.h.

◆ SizeOfBtreeUpdate

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

Definition at line 268 of file nbtxlog.h.

◆ SizeOfBtreeVacuum

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

Definition at line 234 of file nbtxlog.h.

◆ XLOG_BTREE_DEDUP

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

Definition at line 33 of file nbtxlog.h.

◆ XLOG_BTREE_DELETE

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

Definition at line 34 of file nbtxlog.h.

◆ XLOG_BTREE_INSERT_LEAF

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

Definition at line 27 of file nbtxlog.h.

◆ XLOG_BTREE_INSERT_META

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

Definition at line 29 of file nbtxlog.h.

◆ XLOG_BTREE_INSERT_POST

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

Definition at line 32 of file nbtxlog.h.

◆ XLOG_BTREE_INSERT_UPPER

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

Definition at line 28 of file nbtxlog.h.

◆ XLOG_BTREE_MARK_PAGE_HALFDEAD

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

Definition at line 38 of file nbtxlog.h.

◆ XLOG_BTREE_META_CLEANUP

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

Definition at line 41 of file nbtxlog.h.

50{
51 uint32 version;
53 uint32 level;
54 BlockNumber fastroot;
55 uint32 fastlevel;
56 uint32 last_cleanup_num_delpages;
57 bool allequalimage;
59
60/*
61 * This is what we need to know about simple (without split) insert.
62 *
63 * This data record is used for INSERT_LEAF, INSERT_UPPER, INSERT_META, and
64 * INSERT_POST. Note that INSERT_META and INSERT_UPPER implies it's not a
65 * leaf page, while INSERT_POST and INSERT_LEAF imply that it must be a leaf
66 * page.
67 *
68 * Backup Blk 0: original page
69 * Backup Blk 1: child's left sibling, if INSERT_UPPER or INSERT_META
70 * Backup Blk 2: xl_btree_metadata, if INSERT_META
71 *
72 * Note: The new tuple is actually the "original" new item in the posting
73 * list split insert case (i.e. the INSERT_POST case). A split offset for
74 * the posting list is logged before the original new item. Recovery needs
75 * both, since it must do an in-place update of the existing posting list
76 * that was split as an extra step. Also, recovery generates a "final"
77 * newitem. See _bt_swap_posting() for details on posting list splits.
78 */
79typedef struct xl_btree_insert
80{
82
83 /* POSTING SPLIT OFFSET FOLLOWS (INSERT_POST case) */
84 /* NEW TUPLE ALWAYS FOLLOWS AT THE END */
86
87#define SizeOfBtreeInsert (offsetof(xl_btree_insert, offnum) + sizeof(OffsetNumber))
88
89/*
90 * On insert with split, we save all the items going into the right sibling
91 * so that we can restore it completely from the log record. This way takes
92 * less xlog space than the normal approach, because if we did it standardly,
93 * XLogInsert would almost always think the right page is new and store its
94 * whole page image. The left page, however, is handled in the normal
95 * incremental-update fashion.
96 *
97 * Note: XLOG_BTREE_SPLIT_L and XLOG_BTREE_SPLIT_R share this data record.
98 * There are two variants to indicate whether the inserted tuple went into the
99 * left or right split page (and thus, whether the new item is stored or not).
100 * We always log the left page high key because suffix truncation can generate
101 * a new leaf high key using user-defined code. This is also necessary on
102 * internal pages, since the firstright item that the left page's high key was
103 * based on will have been truncated to zero attributes in the right page (the
104 * separator key is unavailable from the right page).
105 *
106 * Backup Blk 0: original page / new left page
107 *
108 * The left page's data portion contains the new item, if it's the _L variant.
109 * _R variant split records generally do not have a newitem (_R variant leaf
110 * page split records that must deal with a posting list split will include an
111 * explicit newitem, though it is never used on the right page -- it is
112 * actually an orignewitem needed to update existing posting list). The new
113 * high key of the left/original page appears last of all (and must always be
114 * present).
115 *
116 * Page split records that need the REDO routine to deal with a posting list
117 * split directly will have an explicit newitem, which is actually an
118 * orignewitem (the newitem as it was before the posting list split, not
119 * after). A posting list split always has a newitem that comes immediately
120 * after the posting list being split (which would have overlapped with
121 * orignewitem prior to split). Usually REDO must deal with posting list
122 * splits with an _L variant page split record, and usually both the new
123 * posting list and the final newitem go on the left page (the existing
124 * posting list will be inserted instead of the old, and the final newitem
125 * will be inserted next to that). However, _R variant split records will
126 * include an orignewitem when the split point for the page happens to have a
127 * lastleft tuple that is also the posting list being split (leaving newitem
128 * as the page split's firstright tuple). The existence of this corner case
129 * does not change the basic fact about newitem/orignewitem for the REDO
130 * routine: it is always state used for the left page alone. (This is why the
131 * record's postingoff field isn't a reliable indicator of whether or not a
132 * posting list split occurred during the page split; a non-zero value merely
133 * indicates that the REDO routine must reconstruct a new posting list tuple
134 * that is needed for the left page.)
135 *
136 * This posting list split handling is equivalent to the xl_btree_insert REDO
137 * routine's INSERT_POST handling. While the details are more complicated
138 * here, the concept and goals are exactly the same. See _bt_swap_posting()
139 * for details on posting list splits.
140 *
141 * Backup Blk 1: new right page
142 *
143 * The right page's data portion contains the right page's tuples in the form
144 * used by _bt_restore_page. This includes the new item, if it's the _R
145 * variant. The right page's tuples also include the right page's high key
146 * with either variant (moved from the left/original page during the split),
147 * unless the split happened to be of the rightmost page on its level, where
148 * there is no high key for new right page.
149 *
150 * Backup Blk 2: next block (orig page's rightlink), if any
151 * Backup Blk 3: child's left sibling, if non-leaf split
152 */
153typedef struct xl_btree_split
154{
155 uint32 level; /* tree level of page being split */
156 OffsetNumber firstrightoff; /* first origpage item on rightpage */
157 OffsetNumber newitemoff; /* new item's offset */
158 uint16 postingoff; /* offset inside orig posting tuple */
160
161#define SizeOfBtreeSplit (offsetof(xl_btree_split, postingoff) + sizeof(uint16))
162
163/*
164 * When page is deduplicated, consecutive groups of tuples with equal keys are
165 * merged together into posting list tuples.
166 *
167 * The WAL record represents a deduplication pass for a leaf page. An array
168 * of BTDedupInterval structs follows.
169 */
170typedef struct xl_btree_dedup
171{
173
174 /* DEDUPLICATION INTERVALS FOLLOW */
176
177#define SizeOfBtreeDedup (offsetof(xl_btree_dedup, nintervals) + sizeof(uint16))
178
179/*
180 * This is what we need to know about page reuse within btree. This record
181 * only exists to generate a conflict point for Hot Standby.
182 *
183 * Note that we must include a RelFileLocator in the record because we don't
184 * actually register the buffer with the record.
185 */
186typedef struct xl_btree_reuse_page
187{
191 bool isCatalogRel; /* to handle recovery conflict during logical
192 * decoding on standby */
194
195#define SizeOfBtreeReusePage (offsetof(xl_btree_reuse_page, isCatalogRel) + sizeof(bool))
196
197/*
198 * xl_btree_vacuum and xl_btree_delete records describe deletion of index
199 * tuples on a leaf page. The former variant is used by VACUUM, while the
200 * latter variant is used by the ad-hoc deletions that sometimes take place
201 * when btinsert() is called.
202 *
203 * The records are very similar. The only difference is that xl_btree_delete
204 * have snapshotConflictHorizon/isCatalogRel fields for recovery conflicts.
205 * (VACUUM operations can just rely on earlier conflicts generated during
206 * pruning of the table whose TIDs the to-be-deleted index tuples point to.
207 * There are also small differences between each REDO routine that we don't go
208 * into here.)
209 *
210 * xl_btree_vacuum and xl_btree_delete both represent deletion of any number
211 * of index tuples on a single leaf page using page offset numbers. Both also
212 * support "updates" of index tuples, which is how deletes of a subset of TIDs
213 * contained in an existing posting list tuple are implemented.
214 *
215 * Updated posting list tuples are represented using xl_btree_update metadata.
216 * The REDO routines each use the xl_btree_update entries (plus each
217 * corresponding original index tuple from the target leaf page) to generate
218 * the final updated tuple.
219 *
220 * Updates are only used when there will be some remaining TIDs left by the
221 * REDO routine. Otherwise the posting list tuple just gets deleted outright.
222 */
223typedef struct xl_btree_vacuum
224{
227
228 /*----
229 * In payload of blk 0 :
230 * - DELETED TARGET OFFSET NUMBERS
231 * - UPDATED TARGET OFFSET NUMBERS
232 * - UPDATED TUPLES METADATA (xl_btree_update) ITEMS
233 *----
234 */
236
237#define SizeOfBtreeVacuum (offsetof(xl_btree_vacuum, nupdated) + sizeof(uint16))
238
239typedef struct xl_btree_delete
240{
244 bool isCatalogRel; /* to handle recovery conflict during logical
245 * decoding on standby */
246
247 /*----
248 * In payload of blk 0 :
249 * - DELETED TARGET OFFSET NUMBERS
250 * - UPDATED TARGET OFFSET NUMBERS
251 * - UPDATED TUPLES METADATA (xl_btree_update) ITEMS
252 *----
253 */
255
256#define SizeOfBtreeDelete (offsetof(xl_btree_delete, isCatalogRel) + sizeof(bool))
257
258/*
259 * The offsets that appear in xl_btree_update metadata are offsets into the
260 * original posting list from tuple, not page offset numbers. These are
261 * 0-based. The page offset number for the original posting list tuple comes
262 * from the main xl_btree_vacuum/xl_btree_delete record.
263 */
264typedef struct xl_btree_update
265{
267
268 /* POSTING LIST uint16 OFFSETS TO A DELETED TID FOLLOW */
270
271#define SizeOfBtreeUpdate (offsetof(xl_btree_update, ndeletedtids) + sizeof(uint16))
272
273/*
274 * This is what we need to know about marking an empty subtree for deletion.
275 * The target identifies the tuple removed from the parent page (note that we
276 * remove this tuple's downlink and the *following* tuple's key). Note that
277 * the leaf page is empty, so we don't need to store its content --- it is
278 * just reinitialized during recovery using the rest of the fields.
279 *
280 * Backup Blk 0: leaf block
281 * Backup Blk 1: top parent
282 */
283typedef struct xl_btree_mark_page_halfdead
284{
285 OffsetNumber poffset; /* deleted tuple id in parent page */
286
287 /* information needed to recreate the leaf page: */
288 BlockNumber leafblk; /* leaf block ultimately being deleted */
289 BlockNumber leftblk; /* leaf block's left sibling, if any */
290 BlockNumber rightblk; /* leaf block's right sibling */
291 BlockNumber topparent; /* topmost internal page in the subtree */
293
294#define SizeOfBtreeMarkPageHalfDead (offsetof(xl_btree_mark_page_halfdead, topparent) + sizeof(BlockNumber))
295
296/*
297 * This is what we need to know about deletion of a btree page. Note that we
298 * only leave behind a small amount of bookkeeping information in deleted
299 * pages (deleted pages must be kept around as tombstones for a while). It is
300 * convenient for the REDO routine to regenerate its target page from scratch.
301 * This is why WAL record describes certain details that are actually directly
302 * available from the target page.
303 *
304 * Backup Blk 0: target block being deleted
305 * Backup Blk 1: target block's left sibling, if any
306 * Backup Blk 2: target block's right sibling
307 * Backup Blk 3: leaf block (if different from target)
308 * Backup Blk 4: metapage (if rightsib becomes new fast root)
309 */
310typedef struct xl_btree_unlink_page
311{
312 BlockNumber leftsib; /* target block's left sibling, if any */
313 BlockNumber rightsib; /* target block's right sibling */
314 uint32 level; /* target block's level */
315 FullTransactionId safexid; /* target block's BTPageSetDeleted() XID */
316
317 /*
318 * Information needed to recreate a half-dead leaf page with correct
319 * topparent link. The fields are only used when deletion operation's
320 * target page is an internal page. REDO routine creates half-dead page
321 * from scratch to keep things simple (this is the same convenient
322 * approach used for the target page itself).
323 */
326 BlockNumber leaftopparent; /* next child down in the subtree */
327
328 /* xl_btree_metadata FOLLOWS IF XLOG_BTREE_UNLINK_PAGE_META */
330
331#define SizeOfBtreeUnlinkPage (offsetof(xl_btree_unlink_page, leaftopparent) + sizeof(BlockNumber))
332
333/*
334 * New root log record. There are zero tuples if this is to establish an
335 * empty root, or two if it is the result of splitting an old root.
336 *
337 * Note that although this implies rewriting the metadata page, we don't need
338 * an xl_btree_metadata record --- the rootblk and level are sufficient.
339 *
340 * Backup Blk 0: new root page (2 tuples as payload, if splitting old root)
341 * Backup Blk 1: left child (if splitting an old root)
342 * Backup Blk 2: metapage
343 */
344typedef struct xl_btree_newroot
345{
346 BlockNumber rootblk; /* location of new root (redundant with blk 0) */
347 uint32 level; /* its tree level */
349
350#define SizeOfBtreeNewroot (offsetof(xl_btree_newroot, level) + sizeof(uint32))
351
352
353/*
354 * prototypes for functions in nbtxlog.c
355 */
356extern void btree_redo(XLogReaderState *record);
357extern void btree_xlog_startup(void);
358extern void btree_xlog_cleanup(void);
359extern void btree_mask(char *pagedata, BlockNumber blkno);
360
361/*
362 * prototypes for functions in nbtdesc.c
363 */
364extern void btree_desc(StringInfo buf, XLogReaderState *record);
365extern const char *btree_identify(uint8 info);
366
367#endif /* NBTXLOG_H */
uint32 BlockNumber
Definition block.h:31
uint8_t uint8
Definition c.h:544
uint16_t uint16
Definition c.h:545
uint32_t uint32
Definition c.h:546
uint32 TransactionId
Definition c.h:666
void btree_redo(XLogReaderState *record)
Definition nbtxlog.c:1004
void btree_xlog_cleanup(void)
Definition nbtxlog.c:1071
const char * btree_identify(uint8 info)
Definition nbtdesc.c:139
void btree_mask(char *pagedata, BlockNumber blkno)
Definition nbtxlog.c:1081
void btree_desc(StringInfo buf, XLogReaderState *record)
Definition nbtdesc.c:24
void btree_xlog_startup(void)
Definition nbtxlog.c:1063
uint16 OffsetNumber
Definition off.h:24
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fb(int x)
tree ctl root
Definition radixtree.h:1857
uint16 nintervals
Definition nbtxlog.h:169
TransactionId snapshotConflictHorizon
Definition nbtxlog.h:238
bool isCatalogRel
Definition nbtxlog.h:241
uint16 ndeleted
Definition nbtxlog.h:239
uint16 nupdated
Definition nbtxlog.h:240
OffsetNumber offnum
Definition nbtxlog.h:78
BlockNumber rootblk
Definition nbtxlog.h:343
FullTransactionId snapshotConflictHorizon
Definition nbtxlog.h:187
RelFileLocator locator
Definition nbtxlog.h:185
BlockNumber block
Definition nbtxlog.h:186
uint16 postingoff
Definition nbtxlog.h:155
OffsetNumber firstrightoff
Definition nbtxlog.h:153
uint32 level
Definition nbtxlog.h:152
OffsetNumber newitemoff
Definition nbtxlog.h:154
uint16 ndeletedtids
Definition nbtxlog.h:263
uint16 ndeleted
Definition nbtxlog.h:222
uint16 nupdated
Definition nbtxlog.h:223

◆ XLOG_BTREE_NEWROOT

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

Definition at line 37 of file nbtxlog.h.

◆ 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.

◆ XLOG_BTREE_SPLIT_L

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

Definition at line 30 of file nbtxlog.h.

◆ XLOG_BTREE_SPLIT_R

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

Definition at line 31 of file nbtxlog.h.

◆ XLOG_BTREE_UNLINK_PAGE

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

Definition at line 35 of file nbtxlog.h.

◆ XLOG_BTREE_UNLINK_PAGE_META

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

Definition at line 36 of file nbtxlog.h.

◆ XLOG_BTREE_VACUUM

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

Definition at line 39 of file nbtxlog.h.

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 
)
extern

Definition at line 24 of file nbtdesc.c.

25{
26 char *rec = XLogRecGetData(record);
27 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
28
29 switch (info)
30 {
35 {
37
38 appendStringInfo(buf, "off: %u", xlrec->offnum);
39 break;
40 }
43 {
45
46 appendStringInfo(buf, "level: %u, firstrightoff: %d, newitemoff: %d, postingoff: %d",
47 xlrec->level, xlrec->firstrightoff,
48 xlrec->newitemoff, xlrec->postingoff);
49 break;
50 }
52 {
54
55 appendStringInfo(buf, "nintervals: %u", xlrec->nintervals);
56 break;
57 }
59 {
61
62 appendStringInfo(buf, "ndeleted: %u, nupdated: %u",
63 xlrec->ndeleted, xlrec->nupdated);
64
65 if (XLogRecHasBlockData(record, 0))
67 xlrec->ndeleted, xlrec->nupdated);
68 break;
69 }
71 {
73
74 appendStringInfo(buf, "snapshotConflictHorizon: %u, ndeleted: %u, nupdated: %u, isCatalogRel: %c",
75 xlrec->snapshotConflictHorizon,
76 xlrec->ndeleted, xlrec->nupdated,
77 xlrec->isCatalogRel ? 'T' : 'F');
78
79 if (XLogRecHasBlockData(record, 0))
81 xlrec->ndeleted, xlrec->nupdated);
82 break;
83 }
85 {
87
88 appendStringInfo(buf, "topparent: %u, leaf: %u, left: %u, right: %u",
89 xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
90 break;
91 }
94 {
96
97 appendStringInfo(buf, "left: %u, right: %u, level: %u, safexid: %u:%u, ",
98 xlrec->leftsib, xlrec->rightsib, xlrec->level,
101 appendStringInfo(buf, "leafleft: %u, leafright: %u, leaftopparent: %u",
102 xlrec->leafleftsib, xlrec->leafrightsib,
103 xlrec->leaftopparent);
104 break;
105 }
107 {
109
110 appendStringInfo(buf, "level: %u", xlrec->level);
111 break;
112 }
114 {
116
117 appendStringInfo(buf, "rel: %u/%u/%u, snapshotConflictHorizon: %u:%u, isCatalogRel: %c",
118 xlrec->locator.spcOid, xlrec->locator.dbOid,
119 xlrec->locator.relNumber,
120 EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
121 XidFromFullTransactionId(xlrec->snapshotConflictHorizon),
122 xlrec->isCatalogRel ? 'T' : 'F');
123 break;
124 }
126 {
128
130 NULL);
131 appendStringInfo(buf, "last_cleanup_num_delpages: %u",
132 xlrec->last_cleanup_num_delpages);
133 break;
134 }
135 }
136}
static void delvacuum_desc(StringInfo buf, char *block_data, uint16 ndeleted, uint16 nupdated)
Definition nbtdesc.c:196
#define XLOG_BTREE_META_CLEANUP
Definition nbtxlog.h:41
#define XLOG_BTREE_INSERT_POST
Definition nbtxlog.h:32
#define XLOG_BTREE_VACUUM
Definition nbtxlog.h:39
#define XLOG_BTREE_SPLIT_R
Definition nbtxlog.h:31
#define XLOG_BTREE_INSERT_LEAF
Definition nbtxlog.h:27
#define XLOG_BTREE_INSERT_UPPER
Definition nbtxlog.h:28
#define XLOG_BTREE_DEDUP
Definition nbtxlog.h:33
#define XLOG_BTREE_UNLINK_PAGE
Definition nbtxlog.h:35
#define XLOG_BTREE_UNLINK_PAGE_META
Definition nbtxlog.h:36
#define XLOG_BTREE_INSERT_META
Definition nbtxlog.h:29
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition nbtxlog.h:38
#define XLOG_BTREE_REUSE_PAGE
Definition nbtxlog.h:40
#define XLOG_BTREE_SPLIT_L
Definition nbtxlog.h:30
#define XLOG_BTREE_NEWROOT
Definition nbtxlog.h:37
#define XLOG_BTREE_DELETE
Definition nbtxlog.h:34
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition stringinfo.c:145
#define EpochFromFullTransactionId(x)
Definition transam.h:47
#define XidFromFullTransactionId(x)
Definition transam.h:48
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
#define XLogRecHasBlockData(decoder, block_id)
Definition xlogreader.h:426
#define XLogRecGetInfo(decoder)
Definition xlogreader.h:409
#define XLogRecGetData(decoder)
Definition xlogreader.h:414

References appendStringInfo(), buf, delvacuum_desc(), EpochFromFullTransactionId, fb(), XidFromFullTransactionId, 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 XLogRecHasBlockData.

◆ btree_identify()

const char * btree_identify ( uint8  info)
extern

Definition at line 139 of file nbtdesc.c.

140{
141 const char *id = NULL;
142
143 switch (info & ~XLR_INFO_MASK)
144 {
146 id = "INSERT_LEAF";
147 break;
149 id = "INSERT_UPPER";
150 break;
152 id = "INSERT_META";
153 break;
155 id = "SPLIT_L";
156 break;
158 id = "SPLIT_R";
159 break;
161 id = "INSERT_POST";
162 break;
163 case XLOG_BTREE_DEDUP:
164 id = "DEDUP";
165 break;
167 id = "VACUUM";
168 break;
170 id = "DELETE";
171 break;
173 id = "MARK_PAGE_HALFDEAD";
174 break;
176 id = "UNLINK_PAGE";
177 break;
179 id = "UNLINK_PAGE_META";
180 break;
182 id = "NEWROOT";
183 break;
185 id = "REUSE_PAGE";
186 break;
188 id = "META_CLEANUP";
189 break;
190 }
191
192 return id;
193}
#define XLR_INFO_MASK
Definition xlogrecord.h:62

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

◆ btree_mask()

void btree_mask ( char pagedata,
BlockNumber  blkno 
)
extern

Definition at line 1081 of file nbtxlog.c.

1082{
1083 Page page = (Page) pagedata;
1085
1087
1088 mask_page_hint_bits(page);
1089 mask_unused_space(page);
1090
1091 maskopaq = BTPageGetOpaque(page);
1092
1093 if (P_ISLEAF(maskopaq))
1094 {
1095 /*
1096 * In btree leaf pages, it is possible to modify the LP_FLAGS without
1097 * emitting any WAL record. Hence, mask the line pointer flags. See
1098 * _bt_killitems(), _bt_check_unique() for details.
1099 */
1100 mask_lp_flags(page);
1101 }
1102
1103 /*
1104 * BTP_HAS_GARBAGE is just an un-logged hint bit. So, mask it. See
1105 * _bt_delete_or_dedup_one_page(), _bt_killitems(), and _bt_check_unique()
1106 * for details.
1107 */
1108 maskopaq->btpo_flags &= ~BTP_HAS_GARBAGE;
1109
1110 /*
1111 * During replay of a btree page split, we don't set the BTP_SPLIT_END
1112 * flag of the right sibling and initialize the cycle_id to 0 for the same
1113 * page. See btree_xlog_split() for details.
1114 */
1115 maskopaq->btpo_flags &= ~BTP_SPLIT_END;
1116 maskopaq->btpo_cycleid = 0;
1117}
void mask_lp_flags(Page page)
Definition bufmask.c:95
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
PageData * Page
Definition bufpage.h:81
#define P_ISLEAF(opaque)
Definition nbtree.h:221
#define BTPageGetOpaque(page)
Definition nbtree.h:74

References BTPageGetOpaque, fb(), mask_lp_flags(), mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), and P_ISLEAF.

◆ btree_redo()

void btree_redo ( XLogReaderState record)
extern

Definition at line 1004 of file nbtxlog.c.

1005{
1006 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
1008
1010 switch (info)
1011 {
1013 btree_xlog_insert(true, false, false, record);
1014 break;
1016 btree_xlog_insert(false, false, false, record);
1017 break;
1019 btree_xlog_insert(false, true, false, record);
1020 break;
1021 case XLOG_BTREE_SPLIT_L:
1022 btree_xlog_split(true, record);
1023 break;
1024 case XLOG_BTREE_SPLIT_R:
1025 btree_xlog_split(false, record);
1026 break;
1028 btree_xlog_insert(true, false, true, record);
1029 break;
1030 case XLOG_BTREE_DEDUP:
1031 btree_xlog_dedup(record);
1032 break;
1033 case XLOG_BTREE_VACUUM:
1034 btree_xlog_vacuum(record);
1035 break;
1036 case XLOG_BTREE_DELETE:
1037 btree_xlog_delete(record);
1038 break;
1040 btree_xlog_mark_page_halfdead(info, record);
1041 break;
1044 btree_xlog_unlink_page(info, record);
1045 break;
1046 case XLOG_BTREE_NEWROOT:
1047 btree_xlog_newroot(record);
1048 break;
1050 btree_xlog_reuse_page(record);
1051 break;
1053 _bt_restore_meta(record, 0);
1054 break;
1055 default:
1056 elog(PANIC, "btree_redo: unknown op code %u", info);
1057 }
1060}
#define PANIC
Definition elog.h:42
#define elog(elevel,...)
Definition elog.h:226
void MemoryContextReset(MemoryContext context)
Definition mcxt.c:403
static void btree_xlog_delete(XLogReaderState *record)
Definition nbtxlog.c:640
static void _bt_restore_meta(XLogReaderState *record, uint8 block_id)
Definition nbtxlog.c:80
static void btree_xlog_newroot(XLogReaderState *record)
Definition nbtxlog.c:927
static void btree_xlog_dedup(XLogReaderState *record)
Definition nbtxlog.c:454
static void btree_xlog_insert(bool isleaf, bool ismeta, bool posting, XLogReaderState *record)
Definition nbtxlog.c:158
static void btree_xlog_split(bool newitemonleft, XLogReaderState *record)
Definition nbtxlog.c:247
static void btree_xlog_reuse_page(XLogReaderState *record)
Definition nbtxlog.c:993
static void btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record)
Definition nbtxlog.c:705
static MemoryContext opCtx
Definition nbtxlog.c:25
static void btree_xlog_vacuum(XLogReaderState *record)
Definition nbtxlog.c:586
static void btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
Definition nbtxlog.c:789
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124

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, fb(), MemoryContextReset(), MemoryContextSwitchTo(), opCtx, 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, and XLogRecGetInfo.

◆ btree_xlog_cleanup()

void btree_xlog_cleanup ( void  )
extern

Definition at line 1071 of file nbtxlog.c.

1072{
1074 opCtx = NULL;
1075}
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472

References fb(), MemoryContextDelete(), and opCtx.

◆ btree_xlog_startup()

void btree_xlog_startup ( void  )
extern

Definition at line 1063 of file nbtxlog.c.

1064{
1066 "Btree recovery temporary context",
1068}
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, and opCtx.