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  {
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, firstrightoff %d, newitemoff %d, postingoff %d",
43  xlrec->level, xlrec->firstrightoff,
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 }
120 
121 const char *
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 }
TransactionId latestRemovedXid
Definition: nbtxlog.h:189
uint16 nintervals
Definition: nbtxlog.h:172
unsigned char uint8
Definition: c.h:372
#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:310
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
const char * btree_identify(uint8 info)
Definition: nbtdesc.c:122
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
static char * buf
Definition: pg_test_fsync.c:67
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:38
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:34
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:305
#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:1521
#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
void btree_desc(StringInfo buf, XLogReaderState *record)
Definition: nbtdesc.c:20
#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
OffsetNumber firstrightoff
Definition: nbtxlog.h:156
#define XLOG_BTREE_META_CLEANUP
Definition: nbtxlog.h:42