/Users/deen/code/yugabyte-db/src/postgres/src/bin/pg_waldump/nbtdesc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /*------------------------------------------------------------------------- |
2 | | * |
3 | | * nbtdesc.c |
4 | | * rmgr descriptor routines for access/nbtree/nbtxlog.c |
5 | | * |
6 | | * Portions Copyright (c) 1996-2018, 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 | | btree_desc(StringInfo buf, XLogReaderState *record) |
21 | 0 | { |
22 | 0 | char *rec = XLogRecGetData(record); |
23 | 0 | uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK; |
24 | |
|
25 | 0 | switch (info) |
26 | 0 | { |
27 | 0 | case XLOG_BTREE_INSERT_LEAF: |
28 | 0 | case XLOG_BTREE_INSERT_UPPER: |
29 | 0 | case XLOG_BTREE_INSERT_META: |
30 | 0 | { |
31 | 0 | xl_btree_insert *xlrec = (xl_btree_insert *) rec; |
32 | |
|
33 | 0 | appendStringInfo(buf, "off %u", xlrec->offnum); |
34 | 0 | break; |
35 | 0 | } |
36 | 0 | case XLOG_BTREE_SPLIT_L: |
37 | 0 | case XLOG_BTREE_SPLIT_R: |
38 | 0 | case XLOG_BTREE_SPLIT_L_HIGHKEY: |
39 | 0 | case XLOG_BTREE_SPLIT_R_HIGHKEY: |
40 | 0 | { |
41 | 0 | xl_btree_split *xlrec = (xl_btree_split *) rec; |
42 | |
|
43 | 0 | appendStringInfo(buf, "level %u, firstright %d", |
44 | 0 | xlrec->level, xlrec->firstright); |
45 | 0 | break; |
46 | 0 | } |
47 | 0 | case XLOG_BTREE_VACUUM: |
48 | 0 | { |
49 | 0 | xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec; |
50 | |
|
51 | 0 | appendStringInfo(buf, "lastBlockVacuumed %u", |
52 | 0 | xlrec->lastBlockVacuumed); |
53 | 0 | break; |
54 | 0 | } |
55 | 0 | case XLOG_BTREE_DELETE: |
56 | 0 | { |
57 | 0 | xl_btree_delete *xlrec = (xl_btree_delete *) rec; |
58 | |
|
59 | 0 | appendStringInfo(buf, "%d items", xlrec->nitems); |
60 | 0 | break; |
61 | 0 | } |
62 | 0 | case XLOG_BTREE_MARK_PAGE_HALFDEAD: |
63 | 0 | { |
64 | 0 | xl_btree_mark_page_halfdead *xlrec = (xl_btree_mark_page_halfdead *) rec; |
65 | |
|
66 | 0 | appendStringInfo(buf, "topparent %u; leaf %u; left %u; right %u", |
67 | 0 | xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk); |
68 | 0 | break; |
69 | 0 | } |
70 | 0 | case XLOG_BTREE_UNLINK_PAGE_META: |
71 | 0 | case XLOG_BTREE_UNLINK_PAGE: |
72 | 0 | { |
73 | 0 | xl_btree_unlink_page *xlrec = (xl_btree_unlink_page *) rec; |
74 | |
|
75 | 0 | appendStringInfo(buf, "left %u; right %u; btpo_xact %u; ", |
76 | 0 | xlrec->leftsib, xlrec->rightsib, |
77 | 0 | xlrec->btpo_xact); |
78 | 0 | appendStringInfo(buf, "leafleft %u; leafright %u; topparent %u", |
79 | 0 | xlrec->leafleftsib, xlrec->leafrightsib, |
80 | 0 | xlrec->topparent); |
81 | 0 | break; |
82 | 0 | } |
83 | 0 | case XLOG_BTREE_NEWROOT: |
84 | 0 | { |
85 | 0 | xl_btree_newroot *xlrec = (xl_btree_newroot *) rec; |
86 | |
|
87 | 0 | appendStringInfo(buf, "lev %u", xlrec->level); |
88 | 0 | break; |
89 | 0 | } |
90 | 0 | case XLOG_BTREE_REUSE_PAGE: |
91 | 0 | { |
92 | 0 | xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec; |
93 | |
|
94 | 0 | appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u", |
95 | 0 | xlrec->node.spcNode, xlrec->node.dbNode, |
96 | 0 | xlrec->node.relNode, xlrec->latestRemovedXid); |
97 | 0 | break; |
98 | 0 | } |
99 | 0 | case XLOG_BTREE_META_CLEANUP: |
100 | 0 | { |
101 | 0 | xl_btree_metadata *xlrec = (xl_btree_metadata *) rec; |
102 | |
|
103 | 0 | appendStringInfo(buf, "oldest_btpo_xact %u; last_cleanup_num_heap_tuples: %f", |
104 | 0 | xlrec->oldest_btpo_xact, |
105 | 0 | xlrec->last_cleanup_num_heap_tuples); |
106 | 0 | break; |
107 | 0 | } |
108 | 0 | } |
109 | 0 | } |
110 | | |
111 | | const char * |
112 | | btree_identify(uint8 info) |
113 | 0 | { |
114 | 0 | const char *id = NULL; |
115 | |
|
116 | 0 | switch (info & ~XLR_INFO_MASK) |
117 | 0 | { |
118 | 0 | case XLOG_BTREE_INSERT_LEAF: |
119 | 0 | id = "INSERT_LEAF"; |
120 | 0 | break; |
121 | 0 | case XLOG_BTREE_INSERT_UPPER: |
122 | 0 | id = "INSERT_UPPER"; |
123 | 0 | break; |
124 | 0 | case XLOG_BTREE_INSERT_META: |
125 | 0 | id = "INSERT_META"; |
126 | 0 | break; |
127 | 0 | case XLOG_BTREE_SPLIT_L: |
128 | 0 | id = "SPLIT_L"; |
129 | 0 | break; |
130 | 0 | case XLOG_BTREE_SPLIT_R: |
131 | 0 | id = "SPLIT_R"; |
132 | 0 | break; |
133 | 0 | case XLOG_BTREE_SPLIT_L_HIGHKEY: |
134 | 0 | id = "SPLIT_L_HIGHKEY"; |
135 | 0 | break; |
136 | 0 | case XLOG_BTREE_SPLIT_R_HIGHKEY: |
137 | 0 | id = "SPLIT_R_HIGHKEY"; |
138 | 0 | break; |
139 | 0 | case XLOG_BTREE_VACUUM: |
140 | 0 | id = "VACUUM"; |
141 | 0 | break; |
142 | 0 | case XLOG_BTREE_DELETE: |
143 | 0 | id = "DELETE"; |
144 | 0 | break; |
145 | 0 | case XLOG_BTREE_MARK_PAGE_HALFDEAD: |
146 | 0 | id = "MARK_PAGE_HALFDEAD"; |
147 | 0 | break; |
148 | 0 | case XLOG_BTREE_UNLINK_PAGE: |
149 | 0 | id = "UNLINK_PAGE"; |
150 | 0 | break; |
151 | 0 | case XLOG_BTREE_UNLINK_PAGE_META: |
152 | 0 | id = "UNLINK_PAGE_META"; |
153 | 0 | break; |
154 | 0 | case XLOG_BTREE_NEWROOT: |
155 | 0 | id = "NEWROOT"; |
156 | 0 | break; |
157 | 0 | case XLOG_BTREE_REUSE_PAGE: |
158 | 0 | id = "REUSE_PAGE"; |
159 | 0 | break; |
160 | 0 | case XLOG_BTREE_META_CLEANUP: |
161 | 0 | id = "META_CLEANUP"; |
162 | 0 | break; |
163 | 0 | } |
164 | | |
165 | 0 | return id; |
166 | 0 | } |