1 /***************************************************************************** 2 3 Copyright (c) 1995, 2021, Oracle and/or its affiliates. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed 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 included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, 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 Street, Suite 500, Boston, MA 02110-1335 USA 24 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 #ifndef UNIV_INNOCHECKSUM 38 #include "sync0rw.h" 39 #endif /* UNIV_INNOCHECKSUM */ 40 41 struct mtr_t; 42 43 /** Logging modes for a mini-transaction */ 44 enum mtr_log_t { 45 /** Default mode: log all operations modifying disk-based data */ 46 MTR_LOG_ALL = 21, 47 48 /** Log no operations and dirty pages are not added to the flush list */ 49 MTR_LOG_NONE = 22, 50 51 /** Don't generate REDO log but add dirty pages to flush list */ 52 MTR_LOG_NO_REDO = 23, 53 54 /** Inserts are logged in a shorter form */ 55 MTR_LOG_SHORT_INSERTS = 24 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 /** discard an update undo log header */ 120 MLOG_UNDO_HDR_DISCARD = 23, 121 122 /** reuse an insert undo log header */ 123 MLOG_UNDO_HDR_REUSE = 24, 124 125 /** create an undo log header */ 126 MLOG_UNDO_HDR_CREATE = 25, 127 128 /** mark an index record as the predefined minimum record */ 129 MLOG_REC_MIN_MARK = 26, 130 131 /** initialize an ibuf bitmap page */ 132 MLOG_IBUF_BITMAP_INIT = 27, 133 134 #ifdef UNIV_LOG_LSN_DEBUG 135 /** Current LSN */ 136 MLOG_LSN = 28, 137 #endif /* UNIV_LOG_LSN_DEBUG */ 138 139 /** this means that a file page is taken into use and the prior 140 contents of the page should be ignored: in recovery we must not 141 trust the lsn values stored to the file page. 142 Note: it's deprecated because it causes crash recovery problem 143 in bulk create index, and actually we don't need to reset page 144 lsn in recv_recover_page_func() now. */ 145 MLOG_INIT_FILE_PAGE = 29, 146 147 /** write a string to a page */ 148 MLOG_WRITE_STRING = 30, 149 150 /** If a single mtr writes several log records, this log 151 record ends the sequence of these records */ 152 MLOG_MULTI_REC_END = 31, 153 154 /** dummy log record used to pad a log block full */ 155 MLOG_DUMMY_RECORD = 32, 156 157 /** log record about an .ibd file creation */ 158 //MLOG_FILE_CREATE = 33, 159 160 /** rename databasename/tablename (no .ibd file name suffix) */ 161 //MLOG_FILE_RENAME = 34, 162 163 /** delete a tablespace file that starts with (space_id,page_no) */ 164 MLOG_FILE_DELETE = 35, 165 166 /** mark a compact index record as the predefined minimum record */ 167 MLOG_COMP_REC_MIN_MARK = 36, 168 169 /** create a compact index page */ 170 MLOG_COMP_PAGE_CREATE = 37, 171 172 /** compact record insert */ 173 MLOG_COMP_REC_INSERT = 38, 174 175 /** mark compact clustered index record deleted */ 176 MLOG_COMP_REC_CLUST_DELETE_MARK = 39, 177 178 /** mark compact secondary index record deleted; this log 179 record type is redundant, as MLOG_REC_SEC_DELETE_MARK is 180 independent of the record format. */ 181 MLOG_COMP_REC_SEC_DELETE_MARK = 40, 182 183 /** update of a compact record, preserves record field sizes */ 184 MLOG_COMP_REC_UPDATE_IN_PLACE = 41, 185 186 /** delete a compact record from a page */ 187 MLOG_COMP_REC_DELETE = 42, 188 189 /** delete compact record list end on index page */ 190 MLOG_COMP_LIST_END_DELETE = 43, 191 192 /*** delete compact record list start on index page */ 193 MLOG_COMP_LIST_START_DELETE = 44, 194 195 /** copy compact record list end to a new created index page */ 196 MLOG_COMP_LIST_END_COPY_CREATED = 45, 197 198 /** reorganize an index page */ 199 MLOG_COMP_PAGE_REORGANIZE = 46, 200 201 /** log record about creating an .ibd file, with format */ 202 MLOG_FILE_CREATE2 = 47, 203 204 /** write the node pointer of a record on a compressed 205 non-leaf B-tree page */ 206 MLOG_ZIP_WRITE_NODE_PTR = 48, 207 208 /** write the BLOB pointer of an externally stored column 209 on a compressed page */ 210 MLOG_ZIP_WRITE_BLOB_PTR = 49, 211 212 /** write to compressed page header */ 213 MLOG_ZIP_WRITE_HEADER = 50, 214 215 /** compress an index page */ 216 MLOG_ZIP_PAGE_COMPRESS = 51, 217 218 /** compress an index page without logging it's image */ 219 MLOG_ZIP_PAGE_COMPRESS_NO_DATA = 52, 220 221 /** reorganize a compressed page */ 222 MLOG_ZIP_PAGE_REORGANIZE = 53, 223 224 /** rename a tablespace file that starts with (space_id,page_no) */ 225 MLOG_FILE_RENAME2 = 54, 226 227 /** note the first use of a tablespace file since checkpoint */ 228 MLOG_FILE_NAME = 55, 229 230 /** note that all buffered log was written since a checkpoint */ 231 MLOG_CHECKPOINT = 56, 232 233 /** Create a R-Tree index page */ 234 MLOG_PAGE_CREATE_RTREE = 57, 235 236 /** create a R-tree compact page */ 237 MLOG_COMP_PAGE_CREATE_RTREE = 58, 238 239 /** this means that a file page is taken into use. 240 We use it to replace MLOG_INIT_FILE_PAGE. */ 241 MLOG_INIT_FILE_PAGE2 = 59, 242 243 /** Table is being truncated. (Marked only for file-per-table) */ 244 MLOG_TRUNCATE = 60, 245 246 /** notify that an index tree is being loaded without writing 247 redo log about individual pages */ 248 MLOG_INDEX_LOAD = 61, 249 250 /** biggest value (used in assertions) */ 251 MLOG_BIGGEST_TYPE = MLOG_INDEX_LOAD 252 }; 253 254 /* @} */ 255 256 /** Size of a MLOG_CHECKPOINT record in bytes. 257 The record consists of a MLOG_CHECKPOINT byte followed by 258 mach_write_to_8(checkpoint_lsn). */ 259 #define SIZE_OF_MLOG_CHECKPOINT 9 260 261 /** Types for the mlock objects to store in the mtr memo; NOTE that the 262 first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */ 263 enum mtr_memo_type_t { 264 #ifndef UNIV_INNOCHECKSUM 265 MTR_MEMO_PAGE_S_FIX = RW_S_LATCH, 266 267 MTR_MEMO_PAGE_X_FIX = RW_X_LATCH, 268 269 MTR_MEMO_PAGE_SX_FIX = RW_SX_LATCH, 270 271 MTR_MEMO_BUF_FIX = RW_NO_LATCH, 272 #endif /* !UNIV_CHECKSUM */ 273 274 #ifdef UNIV_DEBUG 275 MTR_MEMO_MODIFY = 32, 276 #endif /* UNIV_DEBUG */ 277 278 MTR_MEMO_S_LOCK = 64, 279 280 MTR_MEMO_X_LOCK = 128, 281 282 MTR_MEMO_SX_LOCK = 256 283 }; 284 285 #ifdef UNIV_DEBUG 286 # define MTR_MAGIC_N 54551 287 #endif /* UNIV_DEBUG */ 288 289 enum mtr_state_t { 290 MTR_STATE_INIT = 0, 291 MTR_STATE_ACTIVE = 12231, 292 MTR_STATE_COMMITTING = 56456, 293 MTR_STATE_COMMITTED = 34676 294 }; 295 296 #endif /* mtr0types_h */ 297