Debian Codegraph @

storage/innobase/include/mtr0types.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 1995, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 /** @file include/mtr0types.h
29 Mini-transaction buffer global types
30
31 Created 11/26/1995 Heikki Tuuri
32 *******************************************************/
33
34 #ifndef mtr0types_h
35 #define mtr0types_h
36
37 #include "sync0rw.h"
38
39 struct mtr_t;
40
41 /** Logging modes for a mini-transaction */
42 enum mtr_log_t {
43 /** Default mode: log all operations modifying disk-based data */
44 MTR_LOG_ALL = 0,
45
46 /** Log no operations and dirty pages are not added to the flush list */
47 MTR_LOG_NONE = 1,
48
49 /** Don't generate REDO log but add dirty pages to flush list */
50 MTR_LOG_NO_REDO = 2,
51
52 /** Inserts are logged in a shorter form */
53 MTR_LOG_SHORT_INSERTS = 3,
54
55 /** Last element */
56 MTR_LOG_MODE_MAX = 4
57 };
58
59 /** @name Log item types
60 The log items are declared 'byte' so that the compiler can warn if val
61 and type parameters are switched in a call to mlog_write_ulint. NOTE!
62 For 1 - 8 bytes, the flag value must give the length also! @{ */
63 enum mlog_id_t {
64 /** if the mtr contains only one log record for one page,
65 i.e., write_initial_log_record has been called only once,
66 this flag is ORed to the type of that first log record */
67 MLOG_SINGLE_REC_FLAG = 128,
68
69 /** one byte is written */
70 MLOG_1BYTE = 1,
71
72 /** 2 bytes ... */
73 MLOG_2BYTES = 2,
74
75 /** 4 bytes ... */
76 MLOG_4BYTES = 4,
77
78 /** 8 bytes ... */
79 MLOG_8BYTES = 8,
80
81 /** Record insert */
82 MLOG_REC_INSERT_8027 = 9,
83
84 /** Mark clustered index record deleted */
85 MLOG_REC_CLUST_DELETE_MARK_8027 = 10,
86
87 /** Mark secondary index record deleted */
88 MLOG_REC_SEC_DELETE_MARK = 11,
89
90 /** update of a record, preserves record field sizes */
91 MLOG_REC_UPDATE_IN_PLACE_8027 = 13,
92
93 /*!< Delete a record from a page */
94 MLOG_REC_DELETE_8027 = 14,
95
96 /** Delete record list end on index page */
97 MLOG_LIST_END_DELETE_8027 = 15,
98
99 /** Delete record list start on index page */
100 MLOG_LIST_START_DELETE_8027 = 16,
101
102 /** Copy record list end to a new created index page */
103 MLOG_LIST_END_COPY_CREATED_8027 = 17,
104
105 /** Reorganize an index page in ROW_FORMAT=REDUNDANT */
106 MLOG_PAGE_REORGANIZE_8027 = 18,
107
108 /** Create an index page */
109 MLOG_PAGE_CREATE = 19,
110
111 /** Insert entry in an undo log */
112 MLOG_UNDO_INSERT = 20,
113
114 /** erase an undo log page end */
115 MLOG_UNDO_ERASE_END = 21,
116
117 /** initialize a page in an undo log */
118 MLOG_UNDO_INIT = 22,
119
120 /** reuse an insert undo log header */
121 MLOG_UNDO_HDR_REUSE = 24,
122
123 /** create an undo log header */
124 MLOG_UNDO_HDR_CREATE = 25,
125
126 /** mark an index record as the predefined minimum record */
127 MLOG_REC_MIN_MARK = 26,
128
129 /** initialize an ibuf bitmap page */
130 MLOG_IBUF_BITMAP_INIT = 27,
131
132 #ifdef UNIV_LOG_LSN_DEBUG
133 /** Current LSN */
134 MLOG_LSN = 28,
135 #endif /* UNIV_LOG_LSN_DEBUG */
136
137 /** this means that a file page is taken into use and the prior
138 contents of the page should be ignored: in recovery we must not
139 trust the lsn values stored to the file page.
140 Note: it's deprecated because it causes crash recovery problem
141 in bulk create index, and actually we don't need to reset page
142 lsn in recv_recover_page_func() now. */
143 MLOG_INIT_FILE_PAGE = 29,
144
145 /** write a string to a page */
146 MLOG_WRITE_STRING = 30,
147
148 /** If a single mtr writes several log records, this log
149 record ends the sequence of these records */
150 MLOG_MULTI_REC_END = 31,
151
152 /** dummy log record used to pad a log block full */
153 MLOG_DUMMY_RECORD = 32,
154
155 /** log record about creating an .ibd file, with format */
156 MLOG_FILE_CREATE = 33,
157
158 /** rename a tablespace file that starts with (space_id,page_no) */
159 MLOG_FILE_RENAME = 34,
160
161 /** delete a tablespace file that starts with (space_id,page_no) */
162 MLOG_FILE_DELETE = 35,
163
164 /** mark a compact index record as the predefined minimum record */
165 MLOG_COMP_REC_MIN_MARK = 36,
166
167 /** create a compact index page */
168 MLOG_COMP_PAGE_CREATE = 37,
169
170 /** compact record insert */
171 MLOG_COMP_REC_INSERT_8027 = 38,
172
173 /** mark compact clustered index record deleted */
174 MLOG_COMP_REC_CLUST_DELETE_MARK_8027 = 39,
175
176 /** mark compact secondary index record deleted; this log
177 record type is redundant, as MLOG_REC_SEC_DELETE_MARK is
178 independent of the record format. */
179 MLOG_COMP_REC_SEC_DELETE_MARK = 40,
180
181 /** update of a compact record, preserves record field sizes */
182 MLOG_COMP_REC_UPDATE_IN_PLACE_8027 = 41,
183
184 /** delete a compact record from a page */
185 MLOG_COMP_REC_DELETE_8027 = 42,
186
187 /** delete compact record list end on index page */
188 MLOG_COMP_LIST_END_DELETE_8027 = 43,
189
190 /*** delete compact record list start on index page */
191 MLOG_COMP_LIST_START_DELETE_8027 = 44,
192
193 /** copy compact record list end to a new created index page */
194 MLOG_COMP_LIST_END_COPY_CREATED_8027 = 45,
195
196 /** reorganize an index page */
197 MLOG_COMP_PAGE_REORGANIZE_8027 = 46,
198
199 /** write the node pointer of a record on a compressed
200 non-leaf B-tree page */
201 MLOG_ZIP_WRITE_NODE_PTR = 48,
202
203 /** write the BLOB pointer of an externally stored column
204 on a compressed page */
205 MLOG_ZIP_WRITE_BLOB_PTR = 49,
206
207 /** write to compressed page header */
208 MLOG_ZIP_WRITE_HEADER = 50,
209
210 /** compress an index page */
211 MLOG_ZIP_PAGE_COMPRESS = 51,
212
213 /** compress an index page without logging it's image */
214 MLOG_ZIP_PAGE_COMPRESS_NO_DATA_8027 = 52,
215
216 /** reorganize a compressed page */
217 MLOG_ZIP_PAGE_REORGANIZE_8027 = 53,
218
219 /** Create a R-Tree index page */
220 MLOG_PAGE_CREATE_RTREE = 57,
221
222 /** create a R-tree compact page */
223 MLOG_COMP_PAGE_CREATE_RTREE = 58,
224
225 /** this means that a file page is taken into use.
226 We use it to replace MLOG_INIT_FILE_PAGE. */
227 MLOG_INIT_FILE_PAGE2 = 59,
228
229 /** Table is being truncated. (Marked only for file-per-table) */
230 /* MLOG_TRUNCATE = 60, Disabled for WL6378 */
231
232 /** notify that an index tree is being loaded without writing
233 redo log about individual pages */
234 MLOG_INDEX_LOAD = 61,
235
236 /** log for some persistent dynamic metadata change */
237 MLOG_TABLE_DYNAMIC_META = 62,
238
239 /** create a SDI index page */
240 MLOG_PAGE_CREATE_SDI = 63,
241
242 /** create a SDI compact page */
243 MLOG_COMP_PAGE_CREATE_SDI = 64,
244
245 /** Extend the space */
246 MLOG_FILE_EXTEND = 65,
247
248 /** Used in tests of redo log. It must never be used outside unit tests. */
249 MLOG_TEST = 66,
250
251 MLOG_REC_INSERT = 67,
252 MLOG_REC_CLUST_DELETE_MARK = 68,
253 MLOG_REC_DELETE = 69,
254 MLOG_REC_UPDATE_IN_PLACE = 70,
255 MLOG_LIST_END_COPY_CREATED = 71,
256 MLOG_PAGE_REORGANIZE = 72,
257 MLOG_ZIP_PAGE_REORGANIZE = 73,
258 MLOG_ZIP_PAGE_COMPRESS_NO_DATA = 74,
259 MLOG_LIST_END_DELETE = 75,
260 MLOG_LIST_START_DELETE = 76,
261
262 /** biggest value (used in assertions) */
263 MLOG_BIGGEST_TYPE = MLOG_LIST_START_DELETE
264 };
265
266 /** @} */
267
268 /** Types for the mlock objects to store in the mtr memo; NOTE that the
269 first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
270 enum mtr_memo_type_t {
271 MTR_MEMO_PAGE_S_FIX = RW_S_LATCH,
272
273 MTR_MEMO_PAGE_X_FIX = RW_X_LATCH,
274
275 MTR_MEMO_PAGE_SX_FIX = RW_SX_LATCH,
276
277 MTR_MEMO_BUF_FIX = RW_NO_LATCH,
278
279 #ifdef UNIV_DEBUG
280 MTR_MEMO_MODIFY = 32,
281 #endif /* UNIV_DEBUG */
282
283 MTR_MEMO_S_LOCK = 64,
284
285 MTR_MEMO_X_LOCK = 128,
286
287 MTR_MEMO_SX_LOCK = 256
288 };
289
290 inline const char *mtr_memo_type(const ulint type) {
291 switch (type) {
292 case MTR_MEMO_PAGE_S_FIX:
293 return "MTR_MEMO_PAGE_S_FIX";
294 case MTR_MEMO_PAGE_X_FIX:
295 return "MTR_MEMO_PAGE_X_FIX";
296 case MTR_MEMO_PAGE_SX_FIX:
297 return "MTR_MEMO_PAGE_SX_FIX";
298 case MTR_MEMO_BUF_FIX:
299 return "MTR_MEMO_BUF_FIX";
300 #ifdef UNIV_DEBUG
301 case MTR_MEMO_MODIFY:
302 return "MTR_MEMO_MODIFY";
303 #endif /* UNIV_DEBUG */
304 case MTR_MEMO_S_LOCK:
305 return "MTR_MEMO_S_LOCK";
306 case MTR_MEMO_X_LOCK:
307 return "MTR_MEMO_X_LOCK";
308 case MTR_MEMO_SX_LOCK:
309 return "MTR_MEMO_SX_LOCK";
310 default:
311 ut_d(ut_error);
312 }
313 ut_o(return "MTR_MEMO_UNKNOWN");
314 }
315
316 #ifdef UNIV_DEBUG
317 constexpr uint32_t MTR_MAGIC_N = 54551;
318 #endif /* UNIV_DEBUG */
319
320 enum mtr_state_t {
321 MTR_STATE_INIT = 0,
322 MTR_STATE_ACTIVE = 12231,
323 MTR_STATE_COMMITTING = 56456,
324 MTR_STATE_COMMITTED = 34676
325 };
326
327 #endif /* mtr0types_h */