1 /***************************************************************************** 2 3 Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. 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/trx0types.h 29 Transaction system global type definitions 30 31 Created 3/26/1996 Heikki Tuuri 32 *******************************************************/ 33 34 #ifndef trx0types_h 35 #define trx0types_h 36 37 #include "ut0byte.h" 38 39 /** printf(3) format used for printing DB_TRX_ID and other system fields */ 40 #define TRX_ID_FMT IB_ID_FMT 41 42 /** maximum length that a formatted trx_t::id could take, not including 43 the terminating NUL character. */ 44 #define TRX_ID_MAX_LEN 17 45 46 /** Transaction execution states when trx->state == TRX_STATE_ACTIVE */ 47 enum trx_que_t { 48 TRX_QUE_RUNNING, /*!< transaction is running */ 49 TRX_QUE_LOCK_WAIT, /*!< transaction is waiting for 50 a lock */ 51 TRX_QUE_ROLLING_BACK, /*!< transaction is rolling back */ 52 TRX_QUE_COMMITTING /*!< transaction is committing */ 53 }; 54 55 /** Transaction states (trx_t::state) */ 56 enum trx_state_t { 57 TRX_STATE_NOT_STARTED, 58 TRX_STATE_ACTIVE, 59 TRX_STATE_PREPARED, /* Support for 2PC/XA */ 60 TRX_STATE_COMMITTED_IN_MEMORY 61 }; 62 63 /** Type of data dictionary operation */ 64 enum trx_dict_op_t { 65 /** The transaction is not modifying the data dictionary. */ 66 TRX_DICT_OP_NONE = 0, 67 /** The transaction is creating a table or an index, or 68 dropping a table. The table must be dropped in crash 69 recovery. This and TRX_DICT_OP_NONE are the only possible 70 operation modes in crash recovery. */ 71 TRX_DICT_OP_TABLE = 1, 72 /** The transaction is creating or dropping an index in an 73 existing table. In crash recovery, the data dictionary 74 must be locked, but the table must not be dropped. */ 75 TRX_DICT_OP_INDEX = 2 76 }; 77 78 /** Memory objects */ 79 /* @{ */ 80 /** Transaction */ 81 struct trx_t; 82 /** The locks and state of an active transaction */ 83 struct trx_lock_t; 84 /** Transaction system */ 85 struct trx_sys_t; 86 /** Signal */ 87 struct trx_sig_t; 88 /** Rollback segment */ 89 struct trx_rseg_t; 90 /** Transaction undo log */ 91 struct trx_undo_t; 92 /** Array of undo numbers of undo records being rolled back or purged */ 93 struct trx_undo_arr_t; 94 /** A cell of trx_undo_arr_t */ 95 struct trx_undo_inf_t; 96 /** The control structure used in the purge operation */ 97 struct trx_purge_t; 98 /** Rollback command node in a query graph */ 99 struct roll_node_t; 100 /** Commit command node in a query graph */ 101 struct commit_node_t; 102 /** SAVEPOINT command node in a query graph */ 103 struct trx_named_savept_t; 104 /* @} */ 105 106 /** Rollback contexts */ 107 enum trx_rb_ctx { 108 RB_NONE = 0, /*!< no rollback */ 109 RB_NORMAL, /*!< normal rollback */ 110 RB_RECOVERY_PURGE_REC, 111 /*!< rolling back an incomplete transaction, 112 in crash recovery, rolling back an 113 INSERT that was performed by updating a 114 delete-marked record; if the delete-marked record 115 no longer exists in an active read view, it will 116 be purged */ 117 RB_RECOVERY /*!< rolling back an incomplete transaction, 118 in crash recovery */ 119 }; 120 121 /** Row identifier (DB_ROW_ID, DATA_ROW_ID) */ 122 typedef ib_id_t row_id_t; 123 /** Transaction identifier (DB_TRX_ID, DATA_TRX_ID) */ 124 typedef ib_id_t trx_id_t; 125 /** Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR) */ 126 typedef ib_id_t roll_ptr_t; 127 /** Undo number */ 128 typedef ib_id_t undo_no_t; 129 130 /** Maximum transaction identifier */ 131 #define TRX_ID_MAX IB_ID_MAX 132 133 /** Transaction savepoint */ 134 struct trx_savept_t{ 135 undo_no_t least_undo_no; /*!< least undo number to undo */ 136 }; 137 138 /** File objects */ 139 /* @{ */ 140 /** Transaction system header */ 141 typedef byte trx_sysf_t; 142 /** Rollback segment header */ 143 typedef byte trx_rsegf_t; 144 /** Undo segment header */ 145 typedef byte trx_usegf_t; 146 /** Undo log header */ 147 typedef byte trx_ulogf_t; 148 /** Undo log page header */ 149 typedef byte trx_upagef_t; 150 151 /** Undo log record */ 152 typedef byte trx_undo_rec_t; 153 /* @} */ 154 155 #endif 156