Line data Source code
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
20 0 : btree_desc(StringInfo buf, XLogReaderState *record)
21 : {
22 0 : char *rec = XLogRecGetData(record);
23 0 : uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24 :
25 0 : switch (info)
26 : {
27 : case XLOG_BTREE_INSERT_LEAF:
28 : case XLOG_BTREE_INSERT_UPPER:
29 : case XLOG_BTREE_INSERT_META:
30 : {
31 0 : xl_btree_insert *xlrec = (xl_btree_insert *) rec;
32 :
33 0 : appendStringInfo(buf, "off %u", xlrec->offnum);
34 0 : break;
35 : }
36 : case XLOG_BTREE_SPLIT_L:
37 : case XLOG_BTREE_SPLIT_R:
38 : {
39 0 : xl_btree_split *xlrec = (xl_btree_split *) rec;
40 :
41 0 : appendStringInfo(buf, "level %u, firstright %d",
42 0 : xlrec->level, xlrec->firstright);
43 0 : break;
44 : }
45 : case XLOG_BTREE_VACUUM:
46 : {
47 0 : xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
48 :
49 0 : appendStringInfo(buf, "lastBlockVacuumed %u",
50 : xlrec->lastBlockVacuumed);
51 0 : break;
52 : }
53 : case XLOG_BTREE_DELETE:
54 : {
55 0 : xl_btree_delete *xlrec = (xl_btree_delete *) rec;
56 :
57 0 : appendStringInfo(buf, "%d items", xlrec->nitems);
58 0 : break;
59 : }
60 : case XLOG_BTREE_MARK_PAGE_HALFDEAD:
61 : {
62 0 : xl_btree_mark_page_halfdead *xlrec = (xl_btree_mark_page_halfdead *) rec;
63 :
64 0 : appendStringInfo(buf, "topparent %u; leaf %u; left %u; right %u",
65 : xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
66 0 : break;
67 : }
68 : case XLOG_BTREE_UNLINK_PAGE_META:
69 : case XLOG_BTREE_UNLINK_PAGE:
70 : {
71 0 : xl_btree_unlink_page *xlrec = (xl_btree_unlink_page *) rec;
72 :
73 0 : appendStringInfo(buf, "left %u; right %u; btpo_xact %u; ",
74 : xlrec->leftsib, xlrec->rightsib,
75 : xlrec->btpo_xact);
76 0 : appendStringInfo(buf, "leafleft %u; leafright %u; topparent %u",
77 : xlrec->leafleftsib, xlrec->leafrightsib,
78 : xlrec->topparent);
79 0 : break;
80 : }
81 : case XLOG_BTREE_NEWROOT:
82 : {
83 0 : xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
84 :
85 0 : appendStringInfo(buf, "lev %u", xlrec->level);
86 0 : break;
87 : }
88 : case XLOG_BTREE_REUSE_PAGE:
89 : {
90 0 : xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
91 :
92 0 : appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u",
93 : xlrec->node.spcNode, xlrec->node.dbNode,
94 : xlrec->node.relNode, xlrec->latestRemovedXid);
95 0 : break;
96 : }
97 : }
98 0 : }
99 :
100 : const char *
101 0 : btree_identify(uint8 info)
102 : {
103 0 : const char *id = NULL;
104 :
105 0 : switch (info & ~XLR_INFO_MASK)
106 : {
107 : case XLOG_BTREE_INSERT_LEAF:
108 0 : id = "INSERT_LEAF";
109 0 : break;
110 : case XLOG_BTREE_INSERT_UPPER:
111 0 : id = "INSERT_UPPER";
112 0 : break;
113 : case XLOG_BTREE_INSERT_META:
114 0 : id = "INSERT_META";
115 0 : break;
116 : case XLOG_BTREE_SPLIT_L:
117 0 : id = "SPLIT_L";
118 0 : break;
119 : case XLOG_BTREE_SPLIT_R:
120 0 : id = "SPLIT_R";
121 0 : break;
122 : case XLOG_BTREE_VACUUM:
123 0 : id = "VACUUM";
124 0 : break;
125 : case XLOG_BTREE_DELETE:
126 0 : id = "DELETE";
127 0 : break;
128 : case XLOG_BTREE_MARK_PAGE_HALFDEAD:
129 0 : id = "MARK_PAGE_HALFDEAD";
130 0 : break;
131 : case XLOG_BTREE_UNLINK_PAGE:
132 0 : id = "UNLINK_PAGE";
133 0 : break;
134 : case XLOG_BTREE_UNLINK_PAGE_META:
135 0 : id = "UNLINK_PAGE_META";
136 0 : break;
137 : case XLOG_BTREE_NEWROOT:
138 0 : id = "NEWROOT";
139 0 : break;
140 : case XLOG_BTREE_REUSE_PAGE:
141 0 : id = "REUSE_PAGE";
142 0 : break;
143 : }
144 :
145 0 : return id;
146 : }
|