1 /***************************************************************************** 2 3 Copyright (c) 1997, 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/row0vers.h 29 Row versions 30 31 Created 2/6/1997 Heikki Tuuri 32 *******************************************************/ 33 34 #ifndef row0vers_h 35 #define row0vers_h 36 37 #include "univ.i" 38 #include "data0data.h" 39 #include "dict0types.h" 40 #include "trx0types.h" 41 #include "que0types.h" 42 #include "rem0types.h" 43 #include "mtr0mtr.h" 44 #include "dict0mem.h" 45 46 // Forward declaration 47 class ReadView; 48 49 /*****************************************************************//** 50 Finds out if an active transaction has inserted or modified a secondary 51 index record. 52 @return 0 if committed, else the active transaction id; 53 NOTE that this function can return false positives but never false 54 negatives. The caller must confirm all positive results by calling 55 trx_is_active() while holding lock_sys->mutex. */ 56 trx_t* 57 row_vers_impl_x_locked( 58 /*===================*/ 59 const rec_t* rec, /*!< in: record in a secondary index */ 60 dict_index_t* index, /*!< in: the secondary index */ 61 const ulint* offsets);/*!< in: rec_get_offsets(rec, index) */ 62 63 /*****************************************************************//** 64 Finds out if we must preserve a delete marked earlier version of a clustered 65 index record, because it is >= the purge view. 66 @param[in] trx_id transaction id in the version 67 @param[in] name table name 68 @param[in,out] mtr mini transaction holding the latch on the 69 clustered index record; it will also hold 70 the latch on purge_view 71 @return TRUE if earlier version should be preserved */ 72 ibool 73 row_vers_must_preserve_del_marked( 74 /*==============================*/ 75 trx_id_t trx_id, 76 const table_name_t& name, 77 mtr_t* mtr); 78 79 /*****************************************************************//** 80 Finds out if a version of the record, where the version >= the current 81 purge view, should have ientry as its secondary index entry. We check 82 if there is any not delete marked version of the record where the trx 83 id >= purge view, and the secondary index entry == ientry; exactly in 84 this case we return TRUE. 85 @return TRUE if earlier version should have */ 86 ibool 87 row_vers_old_has_index_entry( 88 /*=========================*/ 89 ibool also_curr,/*!< in: TRUE if also rec is included in the 90 versions to search; otherwise only versions 91 prior to it are searched */ 92 const rec_t* rec, /*!< in: record in the clustered index; the 93 caller must have a latch on the page */ 94 mtr_t* mtr, /*!< in: mtr holding the latch on rec; it will 95 also hold the latch on purge_view */ 96 dict_index_t* index, /*!< in: the secondary index */ 97 const dtuple_t* ientry, /*!< in: the secondary index entry */ 98 roll_ptr_t roll_ptr,/*!< in: roll_ptr for the purge record */ 99 trx_id_t trx_id, /*!< in: transaction ID on the purging record */ 100 row_prebuilt_t* prebuilt);/*!< in: compress_heap must be taken from 101 here */ 102 103 /*****************************************************************//** 104 Constructs the version of a clustered index record which a consistent 105 read should see. We assume that the trx id stored in rec is such that 106 the consistent read should not see rec in its present version. 107 @return DB_SUCCESS or DB_MISSING_HISTORY */ 108 dberr_t 109 row_vers_build_for_consistent_read( 110 /*===============================*/ 111 const rec_t* rec, /*!< in: record in a clustered index; the 112 caller must have a latch on the page; this 113 latch locks the top of the stack of versions 114 of this records */ 115 mtr_t* mtr, /*!< in: mtr holding the latch on rec; it will 116 also hold the latch on purge_view */ 117 dict_index_t* index, /*!< in: the clustered index */ 118 ulint** offsets,/*!< in/out: offsets returned by 119 rec_get_offsets(rec, index) */ 120 ReadView* view, /*!< in: the consistent read view */ 121 mem_heap_t** offset_heap,/*!< in/out: memory heap from which 122 the offsets are allocated */ 123 mem_heap_t* in_heap,/*!< in: memory heap from which the memory for 124 *old_vers is allocated; memory for possible 125 intermediate versions is allocated and freed 126 locally within the function */ 127 rec_t** old_vers,/*!< out, own: old version, or NULL 128 if the history is missing or the record 129 does not exist in the view, that is, 130 it was freshly inserted afterwards */ 131 const dtuple_t**vrow); /*!< out: reports virtual column info if any */ 132 133 /*****************************************************************//** 134 Constructs the last committed version of a clustered index record, 135 which should be seen by a semi-consistent read. */ 136 void 137 row_vers_build_for_semi_consistent_read( 138 /*====================================*/ 139 const rec_t* rec, /*!< in: record in a clustered index; the 140 caller must have a latch on the page; this 141 latch locks the top of the stack of versions 142 of this records */ 143 mtr_t* mtr, /*!< in: mtr holding the latch on rec */ 144 dict_index_t* index, /*!< in: the clustered index */ 145 ulint** offsets,/*!< in/out: offsets returned by 146 rec_get_offsets(rec, index) */ 147 mem_heap_t** offset_heap,/*!< in/out: memory heap from which 148 the offsets are allocated */ 149 mem_heap_t* in_heap,/*!< in: memory heap from which the memory for 150 *old_vers is allocated; memory for possible 151 intermediate versions is allocated and freed 152 locally within the function */ 153 const rec_t** old_vers,/*!< out: rec, old version, or NULL if the 154 record does not exist in the view, that is, 155 it was freshly inserted afterwards */ 156 const dtuple_t**vrow); /*!< out: holds virtual column info if any 157 is updated in the view */ 158 159 160 #ifndef UNIV_NONINL 161 #include "row0vers.ic" 162 #endif 163 164 #endif 165