1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * hashdesc.c |
4 | * rmgr descriptor routines for access/hash/hash.c |
5 | * |
6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
7 | * Portions Copyright (c) 1994, Regents of the University of California |
8 | * |
9 | * |
10 | * IDENTIFICATION |
11 | * src/backend/access/rmgrdesc/hashdesc.c |
12 | * |
13 | *------------------------------------------------------------------------- |
14 | */ |
15 | #include "postgres.h" |
16 | |
17 | #include "access/hash_xlog.h" |
18 | |
19 | void |
20 | hash_desc(StringInfo buf, XLogReaderState *record) |
21 | { |
22 | char *rec = XLogRecGetData(record); |
23 | uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK; |
24 | |
25 | switch (info) |
26 | { |
27 | case XLOG_HASH_INIT_META_PAGE: |
28 | { |
29 | xl_hash_init_meta_page *xlrec = (xl_hash_init_meta_page *) rec; |
30 | |
31 | appendStringInfo(buf, "num_tuples %g, fillfactor %d" , |
32 | xlrec->num_tuples, xlrec->ffactor); |
33 | break; |
34 | } |
35 | case XLOG_HASH_INIT_BITMAP_PAGE: |
36 | { |
37 | xl_hash_init_bitmap_page *xlrec = (xl_hash_init_bitmap_page *) rec; |
38 | |
39 | appendStringInfo(buf, "bmsize %d" , xlrec->bmsize); |
40 | break; |
41 | } |
42 | case XLOG_HASH_INSERT: |
43 | { |
44 | xl_hash_insert *xlrec = (xl_hash_insert *) rec; |
45 | |
46 | appendStringInfo(buf, "off %u" , xlrec->offnum); |
47 | break; |
48 | } |
49 | case XLOG_HASH_ADD_OVFL_PAGE: |
50 | { |
51 | xl_hash_add_ovfl_page *xlrec = (xl_hash_add_ovfl_page *) rec; |
52 | |
53 | appendStringInfo(buf, "bmsize %d, bmpage_found %c" , |
54 | xlrec->bmsize, (xlrec->bmpage_found) ? 'T' : 'F'); |
55 | break; |
56 | } |
57 | case XLOG_HASH_SPLIT_ALLOCATE_PAGE: |
58 | { |
59 | xl_hash_split_allocate_page *xlrec = (xl_hash_split_allocate_page *) rec; |
60 | |
61 | appendStringInfo(buf, "new_bucket %u, meta_page_masks_updated %c, issplitpoint_changed %c" , |
62 | xlrec->new_bucket, |
63 | (xlrec->flags & XLH_SPLIT_META_UPDATE_MASKS) ? 'T' : 'F', |
64 | (xlrec->flags & XLH_SPLIT_META_UPDATE_SPLITPOINT) ? 'T' : 'F'); |
65 | break; |
66 | } |
67 | case XLOG_HASH_SPLIT_COMPLETE: |
68 | { |
69 | xl_hash_split_complete *xlrec = (xl_hash_split_complete *) rec; |
70 | |
71 | appendStringInfo(buf, "old_bucket_flag %u, new_bucket_flag %u" , |
72 | xlrec->old_bucket_flag, xlrec->new_bucket_flag); |
73 | break; |
74 | } |
75 | case XLOG_HASH_MOVE_PAGE_CONTENTS: |
76 | { |
77 | xl_hash_move_page_contents *xlrec = (xl_hash_move_page_contents *) rec; |
78 | |
79 | appendStringInfo(buf, "ntups %d, is_primary %c" , |
80 | xlrec->ntups, |
81 | xlrec->is_prim_bucket_same_wrt ? 'T' : 'F'); |
82 | break; |
83 | } |
84 | case XLOG_HASH_SQUEEZE_PAGE: |
85 | { |
86 | xl_hash_squeeze_page *xlrec = (xl_hash_squeeze_page *) rec; |
87 | |
88 | appendStringInfo(buf, "prevblkno %u, nextblkno %u, ntups %d, is_primary %c" , |
89 | xlrec->prevblkno, |
90 | xlrec->nextblkno, |
91 | xlrec->ntups, |
92 | xlrec->is_prim_bucket_same_wrt ? 'T' : 'F'); |
93 | break; |
94 | } |
95 | case XLOG_HASH_DELETE: |
96 | { |
97 | xl_hash_delete *xlrec = (xl_hash_delete *) rec; |
98 | |
99 | appendStringInfo(buf, "clear_dead_marking %c, is_primary %c" , |
100 | xlrec->clear_dead_marking ? 'T' : 'F', |
101 | xlrec->is_primary_bucket_page ? 'T' : 'F'); |
102 | break; |
103 | } |
104 | case XLOG_HASH_UPDATE_META_PAGE: |
105 | { |
106 | xl_hash_update_meta_page *xlrec = (xl_hash_update_meta_page *) rec; |
107 | |
108 | appendStringInfo(buf, "ntuples %g" , |
109 | xlrec->ntuples); |
110 | break; |
111 | } |
112 | case XLOG_HASH_VACUUM_ONE_PAGE: |
113 | { |
114 | xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec; |
115 | |
116 | appendStringInfo(buf, "ntuples %d, latest removed xid %u" , |
117 | xlrec->ntuples, |
118 | xlrec->latestRemovedXid); |
119 | break; |
120 | } |
121 | } |
122 | } |
123 | |
124 | const char * |
125 | hash_identify(uint8 info) |
126 | { |
127 | const char *id = NULL; |
128 | |
129 | switch (info & ~XLR_INFO_MASK) |
130 | { |
131 | case XLOG_HASH_INIT_META_PAGE: |
132 | id = "INIT_META_PAGE" ; |
133 | break; |
134 | case XLOG_HASH_INIT_BITMAP_PAGE: |
135 | id = "INIT_BITMAP_PAGE" ; |
136 | break; |
137 | case XLOG_HASH_INSERT: |
138 | id = "INSERT" ; |
139 | break; |
140 | case XLOG_HASH_ADD_OVFL_PAGE: |
141 | id = "ADD_OVFL_PAGE" ; |
142 | break; |
143 | case XLOG_HASH_SPLIT_ALLOCATE_PAGE: |
144 | id = "SPLIT_ALLOCATE_PAGE" ; |
145 | break; |
146 | case XLOG_HASH_SPLIT_PAGE: |
147 | id = "SPLIT_PAGE" ; |
148 | break; |
149 | case XLOG_HASH_SPLIT_COMPLETE: |
150 | id = "SPLIT_COMPLETE" ; |
151 | break; |
152 | case XLOG_HASH_MOVE_PAGE_CONTENTS: |
153 | id = "MOVE_PAGE_CONTENTS" ; |
154 | break; |
155 | case XLOG_HASH_SQUEEZE_PAGE: |
156 | id = "SQUEEZE_PAGE" ; |
157 | break; |
158 | case XLOG_HASH_DELETE: |
159 | id = "DELETE" ; |
160 | break; |
161 | case XLOG_HASH_SPLIT_CLEANUP: |
162 | id = "SPLIT_CLEANUP" ; |
163 | break; |
164 | case XLOG_HASH_UPDATE_META_PAGE: |
165 | id = "UPDATE_META_PAGE" ; |
166 | break; |
167 | case XLOG_HASH_VACUUM_ONE_PAGE: |
168 | id = "VACUUM_ONE_PAGE" ; |
169 | } |
170 | |
171 | return id; |
172 | } |
173 | |