PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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:
40  {
41  xl_btree_split *xlrec = (xl_btree_split *) rec;
42 
43  appendStringInfo(buf, "level %u, firstright %d",
44  xlrec->level, xlrec->firstright);
45  break;
46  }
47  case XLOG_BTREE_VACUUM:
48  {
49  xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
50 
51  appendStringInfo(buf, "lastBlockVacuumed %u",
52  xlrec->lastBlockVacuumed);
53  break;
54  }
55  case XLOG_BTREE_DELETE:
56  {
57  xl_btree_delete *xlrec = (xl_btree_delete *) rec;
58 
59  appendStringInfo(buf, "%d items", xlrec->nitems);
60  break;
61  }
63  {
65 
66  appendStringInfo(buf, "topparent %u; leaf %u; left %u; right %u",
67  xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
68  break;
69  }
72  {
74 
75  appendStringInfo(buf, "left %u; right %u; btpo_xact %u; ",
76  xlrec->leftsib, xlrec->rightsib,
77  xlrec->btpo_xact);
78  appendStringInfo(buf, "leafleft %u; leafright %u; topparent %u",
79  xlrec->leafleftsib, xlrec->leafrightsib,
80  xlrec->topparent);
81  break;
82  }
83  case XLOG_BTREE_NEWROOT:
84  {
85  xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
86 
87  appendStringInfo(buf, "lev %u", xlrec->level);
88  break;
89  }
91  {
93 
94  appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u",
95  xlrec->node.spcNode, xlrec->node.dbNode,
96  xlrec->node.relNode, xlrec->latestRemovedXid);
97  break;
98  }
99  }
100 }
101 
102 const char *
104 {
105  const char *id = NULL;
106 
107  switch (info & ~XLR_INFO_MASK)
108  {
110  id = "INSERT_LEAF";
111  break;
113  id = "INSERT_UPPER";
114  break;
116  id = "INSERT_META";
117  break;
118  case XLOG_BTREE_SPLIT_L:
119  id = "SPLIT_L";
120  break;
121  case XLOG_BTREE_SPLIT_R:
122  id = "SPLIT_R";
123  break;
125  id = "SPLIT_L_ROOT";
126  break;
128  id = "SPLIT_R_ROOT";
129  break;
130  case XLOG_BTREE_VACUUM:
131  id = "VACUUM";
132  break;
133  case XLOG_BTREE_DELETE:
134  id = "DELETE";
135  break;
137  id = "MARK_PAGE_HALFDEAD";
138  break;
140  id = "UNLINK_PAGE";
141  break;
143  id = "UNLINK_PAGE_META";
144  break;
145  case XLOG_BTREE_NEWROOT:
146  id = "NEWROOT";
147  break;
149  id = "REUSE_PAGE";
150  break;
151  }
152 
153  return id;
154 }
BlockNumber lastBlockVacuumed
Definition: nbtxlog.h:167
#define XLOG_BTREE_SPLIT_L_ROOT
Definition: nbtxlog.h:31
unsigned char uint8
Definition: c.h:266
#define XLOG_BTREE_INSERT_META
Definition: nbtxlog.h:28
RelFileNode node
Definition: nbtxlog.h:135
uint32 level
Definition: nbtxlog.h:241
#define XLOG_BTREE_NEWROOT
Definition: nbtxlog.h:36
#define XLogRecGetData(decoder)
Definition: xlogreader.h:220
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
const char * btree_identify(uint8 info)
Definition: nbtdesc.c:103
#define XLOG_BTREE_INSERT_LEAF
Definition: nbtxlog.h:26
static char * buf
Definition: pg_test_fsync.c:66
#define XLOG_BTREE_VACUUM
Definition: nbtxlog.h:38
#define XLOG_BTREE_UNLINK_PAGE
Definition: nbtxlog.h:34
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
#define XLOG_BTREE_DELETE
Definition: nbtxlog.h:33
#define XLOG_BTREE_REUSE_PAGE
Definition: nbtxlog.h:40
uint32 level
Definition: nbtxlog.h:105
#define XLOG_BTREE_MARK_PAGE_HALFDEAD
Definition: nbtxlog.h:37
OffsetNumber offnum
Definition: nbtxlog.h:66
#define XLOG_BTREE_SPLIT_R
Definition: nbtxlog.h:30
#define NULL
Definition: c.h:229
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
void btree_desc(StringInfo buf, XLogReaderState *record)
Definition: nbtdesc.c:20
OffsetNumber firstright
Definition: nbtxlog.h:106
#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:137
#define XLOG_BTREE_SPLIT_R_ROOT
Definition: nbtxlog.h:32