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