1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. |
4 | Copyright (c) 2017, 2018, MariaDB Corporation. |
5 | |
6 | This program is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free Software |
8 | Foundation; version 2 of the License. |
9 | |
10 | This program is distributed in the hope that it will be useful, but WITHOUT |
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License along with |
15 | this program; if not, write to the Free Software Foundation, Inc., |
16 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
17 | |
18 | *****************************************************************************/ |
19 | |
20 | /**************************************************//** |
21 | @file include/mtr0types.h |
22 | Mini-transaction buffer global types |
23 | |
24 | Created 11/26/1995 Heikki Tuuri |
25 | *******************************************************/ |
26 | |
27 | #ifndef mtr0types_h |
28 | #define mtr0types_h |
29 | |
30 | #ifndef UNIV_INNOCHECKSUM |
31 | #include "sync0rw.h" |
32 | #endif /* UNIV_INNOCHECKSUM */ |
33 | |
34 | struct mtr_t; |
35 | |
36 | /** Logging modes for a mini-transaction */ |
37 | enum mtr_log_t { |
38 | /** Default mode: log all operations modifying disk-based data */ |
39 | MTR_LOG_ALL = 21, |
40 | |
41 | /** Log no operations and dirty pages are not added to the flush list */ |
42 | MTR_LOG_NONE = 22, |
43 | |
44 | /** Don't generate REDO log but add dirty pages to flush list */ |
45 | MTR_LOG_NO_REDO = 23, |
46 | |
47 | /** Inserts are logged in a shorter form */ |
48 | MTR_LOG_SHORT_INSERTS = 24 |
49 | }; |
50 | |
51 | /** @name Log item types |
52 | The log items are declared 'byte' so that the compiler can warn if val |
53 | and type parameters are switched in a call to mlog_write_ulint. NOTE! |
54 | For 1 - 8 bytes, the flag value must give the length also! @{ */ |
55 | enum mlog_id_t { |
56 | /** if the mtr contains only one log record for one page, |
57 | i.e., write_initial_log_record has been called only once, |
58 | this flag is ORed to the type of that first log record */ |
59 | MLOG_SINGLE_REC_FLAG = 128, |
60 | |
61 | /** one byte is written */ |
62 | MLOG_1BYTE = 1, |
63 | |
64 | /** 2 bytes ... */ |
65 | MLOG_2BYTES = 2, |
66 | |
67 | /** 4 bytes ... */ |
68 | MLOG_4BYTES = 4, |
69 | |
70 | /** 8 bytes ... */ |
71 | MLOG_8BYTES = 8, |
72 | |
73 | /** Record insert */ |
74 | MLOG_REC_INSERT = 9, |
75 | |
76 | /** Mark clustered index record deleted */ |
77 | MLOG_REC_CLUST_DELETE_MARK = 10, |
78 | |
79 | /** Mark secondary index record deleted */ |
80 | MLOG_REC_SEC_DELETE_MARK = 11, |
81 | |
82 | /** update of a record, preserves record field sizes */ |
83 | MLOG_REC_UPDATE_IN_PLACE = 13, |
84 | |
85 | /*!< Delete a record from a page */ |
86 | MLOG_REC_DELETE = 14, |
87 | |
88 | /** Delete record list end on index page */ |
89 | MLOG_LIST_END_DELETE = 15, |
90 | |
91 | /** Delete record list start on index page */ |
92 | MLOG_LIST_START_DELETE = 16, |
93 | |
94 | /** Copy record list end to a new created index page */ |
95 | MLOG_LIST_END_COPY_CREATED = 17, |
96 | |
97 | /** Reorganize an index page in ROW_FORMAT=REDUNDANT */ |
98 | MLOG_PAGE_REORGANIZE = 18, |
99 | |
100 | /** Create an index page */ |
101 | MLOG_PAGE_CREATE = 19, |
102 | |
103 | /** insert an undo log record */ |
104 | MLOG_UNDO_INSERT = 20, |
105 | |
106 | /** erase an undo log page end (used in MariaDB 10.2) */ |
107 | MLOG_UNDO_ERASE_END = 21, |
108 | |
109 | /** initialize a page in an undo log */ |
110 | MLOG_UNDO_INIT = 22, |
111 | |
112 | /** reuse an insert undo log header (used in MariaDB 10.2) */ |
113 | MLOG_UNDO_HDR_REUSE = 24, |
114 | |
115 | /** create an undo log header */ |
116 | MLOG_UNDO_HDR_CREATE = 25, |
117 | |
118 | /** mark an index record as the predefined minimum record */ |
119 | MLOG_REC_MIN_MARK = 26, |
120 | |
121 | /** initialize an ibuf bitmap page */ |
122 | MLOG_IBUF_BITMAP_INIT = 27, |
123 | |
124 | #ifdef UNIV_LOG_LSN_DEBUG |
125 | /** Current LSN */ |
126 | MLOG_LSN = 28, |
127 | #endif /* UNIV_LOG_LSN_DEBUG */ |
128 | |
129 | /** write a string to a page */ |
130 | MLOG_WRITE_STRING = 30, |
131 | |
132 | /** If a single mtr writes several log records, this log |
133 | record ends the sequence of these records */ |
134 | MLOG_MULTI_REC_END = 31, |
135 | |
136 | /** dummy log record used to pad a log block full */ |
137 | MLOG_DUMMY_RECORD = 32, |
138 | |
139 | /** log record about an .ibd file creation */ |
140 | //MLOG_FILE_CREATE = 33, |
141 | |
142 | /** rename databasename/tablename (no .ibd file name suffix) */ |
143 | //MLOG_FILE_RENAME = 34, |
144 | |
145 | /** delete a tablespace file that starts with (space_id,page_no) */ |
146 | MLOG_FILE_DELETE = 35, |
147 | |
148 | /** mark a compact index record as the predefined minimum record */ |
149 | MLOG_COMP_REC_MIN_MARK = 36, |
150 | |
151 | /** create a compact index page */ |
152 | MLOG_COMP_PAGE_CREATE = 37, |
153 | |
154 | /** compact record insert */ |
155 | MLOG_COMP_REC_INSERT = 38, |
156 | |
157 | /** mark compact clustered index record deleted */ |
158 | MLOG_COMP_REC_CLUST_DELETE_MARK = 39, |
159 | |
160 | /** update of a compact record, preserves record field sizes */ |
161 | MLOG_COMP_REC_UPDATE_IN_PLACE = 41, |
162 | |
163 | /** delete a compact record from a page */ |
164 | MLOG_COMP_REC_DELETE = 42, |
165 | |
166 | /** delete compact record list end on index page */ |
167 | MLOG_COMP_LIST_END_DELETE = 43, |
168 | |
169 | /*** delete compact record list start on index page */ |
170 | MLOG_COMP_LIST_START_DELETE = 44, |
171 | |
172 | /** copy compact record list end to a new created index page */ |
173 | MLOG_COMP_LIST_END_COPY_CREATED = 45, |
174 | |
175 | /** reorganize an index page */ |
176 | MLOG_COMP_PAGE_REORGANIZE = 46, |
177 | |
178 | /** log record about creating an .ibd file, with format */ |
179 | MLOG_FILE_CREATE2 = 47, |
180 | |
181 | /** write the node pointer of a record on a compressed |
182 | non-leaf B-tree page */ |
183 | MLOG_ZIP_WRITE_NODE_PTR = 48, |
184 | |
185 | /** write the BLOB pointer of an externally stored column |
186 | on a compressed page */ |
187 | MLOG_ZIP_WRITE_BLOB_PTR = 49, |
188 | |
189 | /** write to compressed page header */ |
190 | = 50, |
191 | |
192 | /** compress an index page */ |
193 | MLOG_ZIP_PAGE_COMPRESS = 51, |
194 | |
195 | /** compress an index page without logging it's image */ |
196 | MLOG_ZIP_PAGE_COMPRESS_NO_DATA = 52, |
197 | |
198 | /** reorganize a compressed page */ |
199 | MLOG_ZIP_PAGE_REORGANIZE = 53, |
200 | |
201 | /** rename a tablespace file that starts with (space_id,page_no) */ |
202 | MLOG_FILE_RENAME2 = 54, |
203 | |
204 | /** note the first use of a tablespace file since checkpoint */ |
205 | MLOG_FILE_NAME = 55, |
206 | |
207 | /** note that all buffered log was written since a checkpoint */ |
208 | MLOG_CHECKPOINT = 56, |
209 | |
210 | /** Create a R-Tree index page */ |
211 | MLOG_PAGE_CREATE_RTREE = 57, |
212 | |
213 | /** create a R-tree compact page */ |
214 | MLOG_COMP_PAGE_CREATE_RTREE = 58, |
215 | |
216 | /** initialize a file page */ |
217 | MLOG_INIT_FILE_PAGE2 = 59, |
218 | |
219 | /** Table is being truncated. (Marked only for file-per-table) */ |
220 | MLOG_TRUNCATE = 60, |
221 | |
222 | /** notify that an index tree is being loaded without writing |
223 | redo log about individual pages */ |
224 | MLOG_INDEX_LOAD = 61, |
225 | |
226 | /** write DB_TRX_ID,DB_ROLL_PTR to a clustered index leaf page |
227 | of a ROW_FORMAT=COMPRESSED table */ |
228 | MLOG_ZIP_WRITE_TRX_ID = 62, |
229 | |
230 | /** biggest value (used in assertions) */ |
231 | MLOG_BIGGEST_TYPE = MLOG_ZIP_WRITE_TRX_ID, |
232 | |
233 | /** log record for writing/updating crypt data of |
234 | a tablespace */ |
235 | MLOG_FILE_WRITE_CRYPT_DATA = 100, |
236 | }; |
237 | |
238 | /* @} */ |
239 | |
240 | #define (x) \ |
241 | ((x) == MLOG_FILE_WRITE_CRYPT_DATA) |
242 | |
243 | /** Size of a MLOG_CHECKPOINT record in bytes. |
244 | The record consists of a MLOG_CHECKPOINT byte followed by |
245 | mach_write_to_8(checkpoint_lsn). */ |
246 | #define SIZE_OF_MLOG_CHECKPOINT 9 |
247 | |
248 | #ifndef UNIV_INNOCHECKSUM |
249 | /** Types for the mlock objects to store in the mtr memo; NOTE that the |
250 | first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */ |
251 | enum mtr_memo_type_t { |
252 | MTR_MEMO_PAGE_S_FIX = RW_S_LATCH, |
253 | |
254 | MTR_MEMO_PAGE_X_FIX = RW_X_LATCH, |
255 | |
256 | MTR_MEMO_PAGE_SX_FIX = RW_SX_LATCH, |
257 | |
258 | MTR_MEMO_BUF_FIX = RW_NO_LATCH, |
259 | |
260 | #ifdef UNIV_DEBUG |
261 | MTR_MEMO_MODIFY = 16, |
262 | #endif /* UNIV_DEBUG */ |
263 | |
264 | MTR_MEMO_S_LOCK = RW_S_LATCH << 5, |
265 | |
266 | MTR_MEMO_X_LOCK = RW_X_LATCH << 5, |
267 | |
268 | MTR_MEMO_SX_LOCK = RW_SX_LATCH << 5 |
269 | }; |
270 | #endif /* !UNIV_CHECKSUM */ |
271 | |
272 | #ifdef UNIV_DEBUG |
273 | # define MTR_MAGIC_N 54551 |
274 | #endif /* UNIV_DEBUG */ |
275 | |
276 | enum mtr_state_t { |
277 | MTR_STATE_INIT = 0, |
278 | MTR_STATE_ACTIVE = 12231, |
279 | MTR_STATE_COMMITTING = 56456, |
280 | MTR_STATE_COMMITTED = 34676 |
281 | }; |
282 | |
283 | #endif /* mtr0types_h */ |
284 | |