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