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/row0purge.h 29 Purge obsolete records 30 31 Created 3/14/1997 Heikki Tuuri 32 *******************************************************/ 33 34 #ifndef row0purge_h 35 #define row0purge_h 36 37 #include "univ.i" 38 #include "data0data.h" 39 #include "btr0types.h" 40 #include "btr0pcur.h" 41 #include "dict0types.h" 42 #include "trx0types.h" 43 #include "que0types.h" 44 #include "row0types.h" 45 #include "ut0vec.h" 46 47 /** Create a purge node to a query graph. 48 @param[in] parent parent node, i.e., a thr node 49 @param[in] heap memory heap where created 50 @return own: purge node */ 51 purge_node_t* 52 row_purge_node_create( 53 que_thr_t* parent, 54 mem_heap_t* heap) 55 MY_ATTRIBUTE((warn_unused_result)); 56 57 /***********************************************************//** 58 Determines if it is possible to remove a secondary index entry. 59 Removal is possible if the secondary index entry does not refer to any 60 not delete marked version of a clustered index record where DB_TRX_ID 61 is newer than the purge view. 62 63 NOTE: This function should only be called by the purge thread, only 64 while holding a latch on the leaf page of the secondary index entry 65 (or keeping the buffer pool watch on the page). It is possible that 66 this function first returns true and then false, if a user transaction 67 inserts a record that the secondary index entry would refer to. 68 However, in that case, the user transaction would also re-insert the 69 secondary index entry after purge has removed it and released the leaf 70 page latch. 71 @return true if the secondary index record can be purged */ 72 bool 73 row_purge_poss_sec( 74 /*===============*/ 75 purge_node_t* node, /*!< in/out: row purge node */ 76 dict_index_t* index, /*!< in: secondary index */ 77 const dtuple_t* entry) /*!< in: secondary index entry */ 78 MY_ATTRIBUTE((warn_unused_result)); 79 /*************************************************************** 80 Does the purge operation for a single undo log record. This is a high-level 81 function used in an SQL execution graph. 82 @return query thread to run next or NULL */ 83 que_thr_t* 84 row_purge_step( 85 /*===========*/ 86 que_thr_t* thr) /*!< in: query thread */ 87 MY_ATTRIBUTE((warn_unused_result)); 88 89 /* Purge node structure */ 90 91 struct purge_node_t{ 92 /** Info required to purge a record */ 93 struct rec_t{ 94 trx_undo_rec_t* undo_rec; /*!< Record to purge */ 95 roll_ptr_t roll_ptr; /*!< File pointer to UNDO record */ 96 }; 97 98 typedef std::vector<rec_t, mem_heap_allocator<rec_t> > Recs; 99 100 que_common_t common; /*!< node type: QUE_NODE_PURGE */ 101 /*----------------------*/ 102 /* Local storage for this graph node */ 103 roll_ptr_t roll_ptr;/* roll pointer to undo log record */ 104 ib_vector_t* undo_recs;/*!< Undo recs to purge */ 105 106 undo_no_t undo_no;/*!< undo number of the record */ 107 108 ulint rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC, 109 ... */ 110 dict_table_t* table; /*!< table where purge is done */ 111 112 ulint cmpl_info;/* compiler analysis info of an update */ 113 114 upd_t* update; /*!< update vector for a clustered index 115 record */ 116 dtuple_t* ref; /*!< NULL, or row reference to the next row to 117 handle */ 118 dtuple_t* row; /*!< NULL, or a copy (also fields copied to 119 heap) of the indexed fields of the row to 120 handle */ 121 dict_index_t* index; /*!< NULL, or the next index whose record should 122 be handled */ 123 mem_heap_t* heap; /*!< memory heap used as auxiliary storage for 124 row; this must be emptied after a successful 125 purge of a row */ 126 ibool found_clust;/* TRUE if the clustered index record 127 determined by ref was found in the clustered 128 index, and we were able to position pcur on 129 it */ 130 btr_pcur_t pcur; /*!< persistent cursor used in searching the 131 clustered index record */ 132 ibool done; /* Debug flag */ 133 trx_id_t trx_id; /*!< trx id for this purging record */ 134 Recs* recs; /*!< Undo recs to purge */ 135 136 #ifdef UNIV_DEBUG 137 /***********************************************************//** 138 Validate the persisent cursor. The purge node has two references 139 to the clustered index record - one via the ref member, and the 140 other via the persistent cursor. These two references must match 141 each other if the found_clust flag is set. 142 @return true if the persistent cursor is consistent with 143 the ref member.*/ 144 bool validate_pcur(); 145 #endif 146 }; 147 148 #ifndef UNIV_NONINL 149 #include "row0purge.ic" 150 #endif 151 152 #endif 153