PostgreSQL Source Code  git master
nbtdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * nbtdesc.c
4  * rmgr descriptor routines for access/nbtree/nbtxlog.c
5  *
6  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/access/rmgrdesc/nbtdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
17 #include "access/nbtxlog.h"
18 
19 void
21 {
22  char *rec = XLogRecGetData(record);
23  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24 
25  switch (info)
26  {
30  {
31  xl_btree_insert *xlrec = (xl_btree_insert *) rec;
32 
33  appendStringInfo(buf, "off %u", xlrec->offnum);
34  break;
35  }
36  case XLOG_BTREE_SPLIT_L:
37  case XLOG_BTREE_SPLIT_R:
38  {
39  xl_btree_split *xlrec = (xl_btree_split *) rec;
40 
41  appendStringInfo(buf, "level %u, firstright %d, newitemoff %d",
42  xlrec->level, xlrec->firstright, xlrec->newitemoff);
43  break;
44  }
45  case XLOG_BTREE_VACUUM:
46  {
47  xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
48 
49  appendStringInfo(buf, "ndeleted %u", xlrec->ndeleted);
50  break;
51  }
52  case XLOG_BTREE_DELETE:
53  {
54  xl_btree_delete *xlrec = (xl_btree_delete *) rec;
55 
56  appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u",
57  xlrec->latestRemovedXid, xlrec->ndeleted);
58  break;
59  }
61  {
63 
64  appendStringInfo(buf, "topparent %u; leaf %u; left %u; right %u",
65  xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
66  break;
67  }
70  {
72 
73  appendStringInfo(buf, "left %u; right %u; btpo_xact %u; ",
74  xlrec->leftsib, xlrec->rightsib,
75  xlrec->btpo_xact);
76  appendStringInfo(buf, "leafleft %u; leafright %u; topparent %u",
77  xlrec->leafleftsib, xlrec->leafrightsib,
78  xlrec->topparent);
79  break;
80  }
81  case XLOG_BTREE_NEWROOT:
82  {
83  xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
84 
85  appendStringInfo(buf, "lev %u", xlrec->level);
86  break;
87  }
89  {
91 
92  appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u",
93  xlrec->node.spcNode, xlrec->node.dbNode,
94  xlrec->node.relNode, xlrec->latestRemovedXid);
95  break;
96  }
98  {
99  xl_btree_metadata *xlrec;
100 
101  xlrec = (xl_btree_metadata *) XLogRecGetBlockData(record, 0,
102  NULL);
103  appendStringInfo(buf, "oldest_btpo_xact %u; last_cleanup_num_heap_tuples: %f",
104  xlrec->oldest_btpo_xact,
106  break;
107  }
108  }
109 }
110 
111 const char *
113 {
114  const char *id = NULL;
115 
116  switch (info & ~XLR_INFO_MASK)
117  {
119  id = "INSERT_LEAF";
120  break;
122  id = "INSERT_UPPER";
123  break;
125  id = "INSERT_META";
126  break;
127  case XLOG_BTREE_SPLIT_L:
128  id = "SPLIT_L";
129  break;
130  case XLOG_BTREE_SPLIT_R:
131  id = "SPLIT_R";
132  break;
133  case XLOG_BTREE_VACUUM:
134  id = "VACUUM";
135  break;
136  case XLOG_BTREE_DELETE:
137  id = "DELETE";
138  break;
140  id = "MARK_PAGE_HALFDEAD";
141  break;
143  id = "UNLINK_PAGE";
144  break;
146  id = "UNLINK_PAGE_META";
147  break;
148  case XLOG_BTREE_NEWROOT:
149  id = "NEWROOT";
150  break;
152  id = "REUSE_PAGE";
153  break;
155  id = "META_CLEANUP";
156  break;
157  }
158 
159  return id;
160 }
TransactionId latestRemovedXid
Definition: nbtxlog.h:128
unsigned char uint8
Definition: c.h:365
#define XLOG_BTREE_INSERT_META
Definition: nbtxlog.h:28
RelFileNode node
Definition: nbtxlog.h:145
uint32 level
Definition: nbtxlog.h:236
uint32 ndeleted
Definition: nbtxlog.h:129
#define XLOG_BTREE_NEWROOT
Definition: nbtxlog.h:35
#define XLogRecGetData(decoder)
Definition: xlogreader.h:288
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
const char * btree_identify(uint8 info)
Definition: nbtdesc.c:112
float8 last_cleanup_num_heap_tuples
Definition: nbtxlog.h:55
#define XLOG_BTREE_INSERT_LEAF
Definition: nbtxlog.h:26
OffsetNumber newitemoff
Definition: nbtxlog.h:114
TransactionId oldest_btpo_xact
Definition: nbtxlog.h:54
static char * buf
Definition: pg_test_fsync.c:67
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:37
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:33
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:284
#define XLOG_BTREE_DELETE
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:39
uint32 level
Definition: nbtxlog.h:112
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition: nbtxlog.h:36
OffsetNumber offnum
Definition: nbtxlog.h:70
#define XLOG_BTREE_SPLIT_R
Definition: nbtxlog.h:30
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
void btree_desc(StringInfo buf, XLogReaderState *record)
Definition: nbtdesc.c:20
OffsetNumber firstright
Definition: nbtxlog.h:113
#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:34
TransactionId latestRemovedXid
Definition: nbtxlog.h:147
uint32 ndeleted
Definition: nbtxlog.h:162
#define XLOG_BTREE_META_CLEANUP
Definition: nbtxlog.h:41