1 /***************************************************************************** 2 3 Copyright (c) 1996, 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/btr0types.h 29 The index tree general types 30 31 Created 2/17/1996 Heikki Tuuri 32 *************************************************************************/ 33 34 #ifndef btr0types_h 35 #define btr0types_h 36 37 #include "univ.i" 38 39 #include "rem0types.h" 40 #include "page0types.h" 41 #include "sync0rw.h" 42 43 /** Persistent cursor */ 44 struct btr_pcur_t; 45 /** B-tree cursor */ 46 struct btr_cur_t; 47 /** B-tree search information for the adaptive hash index */ 48 struct btr_search_t; 49 50 #ifndef UNIV_HOTBACKUP 51 52 /** @brief The array of latches protecting the adaptive search partitions 53 54 These latches protect the 55 (1) hash index from the corresponding AHI partition; 56 (2) columns of a record to which we have a pointer in the hash index; 57 58 but do NOT protect: 59 60 (3) next record offset field in a record; 61 (4) next or previous records on the same page. 62 63 Bear in mind (3) and (4) when using the hash indexes. 64 */ 65 66 extern prio_rw_lock_t* btr_search_latch_arr; 67 68 #endif /* UNIV_HOTBACKUP */ 69 70 /** Flag: has the search system been enabled? 71 Protected by btr_search_latch. */ 72 extern char btr_search_enabled; 73 74 /** Number of adaptive hash index partitions */ 75 extern ulint btr_search_index_num; 76 77 #ifdef UNIV_BLOB_DEBUG 78 # include "buf0types.h" 79 /** An index->blobs entry for keeping track of off-page column references */ 80 struct btr_blob_dbg_t; 81 82 /** Insert to index->blobs a reference to an off-page column. 83 @param index the index tree 84 @param b the reference 85 @param ctx context (for logging) */ 86 UNIV_INTERN 87 void 88 btr_blob_dbg_rbt_insert( 89 /*====================*/ 90 dict_index_t* index, /*!< in/out: index tree */ 91 const btr_blob_dbg_t* b, /*!< in: the reference */ 92 const char* ctx) /*!< in: context (for logging) */ 93 MY_ATTRIBUTE((nonnull)); 94 95 /** Remove from index->blobs a reference to an off-page column. 96 @param index the index tree 97 @param b the reference 98 @param ctx context (for logging) */ 99 UNIV_INTERN 100 void 101 btr_blob_dbg_rbt_delete( 102 /*====================*/ 103 dict_index_t* index, /*!< in/out: index tree */ 104 const btr_blob_dbg_t* b, /*!< in: the reference */ 105 const char* ctx) /*!< in: context (for logging) */ 106 MY_ATTRIBUTE((nonnull)); 107 108 /**************************************************************//** 109 Add to index->blobs any references to off-page columns from a record. 110 @return number of references added */ 111 UNIV_INTERN 112 ulint 113 btr_blob_dbg_add_rec( 114 /*=================*/ 115 const rec_t* rec, /*!< in: record */ 116 dict_index_t* index, /*!< in/out: index */ 117 const ulint* offsets,/*!< in: offsets */ 118 const char* ctx) /*!< in: context (for logging) */ 119 MY_ATTRIBUTE((nonnull)); 120 /**************************************************************//** 121 Remove from index->blobs any references to off-page columns from a record. 122 @return number of references removed */ 123 UNIV_INTERN 124 ulint 125 btr_blob_dbg_remove_rec( 126 /*====================*/ 127 const rec_t* rec, /*!< in: record */ 128 dict_index_t* index, /*!< in/out: index */ 129 const ulint* offsets,/*!< in: offsets */ 130 const char* ctx) /*!< in: context (for logging) */ 131 MY_ATTRIBUTE((nonnull)); 132 /**************************************************************//** 133 Count and add to index->blobs any references to off-page columns 134 from records on a page. 135 @return number of references added */ 136 UNIV_INTERN 137 ulint 138 btr_blob_dbg_add( 139 /*=============*/ 140 const page_t* page, /*!< in: rewritten page */ 141 dict_index_t* index, /*!< in/out: index */ 142 const char* ctx) /*!< in: context (for logging) */ 143 MY_ATTRIBUTE((nonnull)); 144 /**************************************************************//** 145 Count and remove from index->blobs any references to off-page columns 146 from records on a page. 147 Used when reorganizing a page, before copying the records. 148 @return number of references removed */ 149 UNIV_INTERN 150 ulint 151 btr_blob_dbg_remove( 152 /*================*/ 153 const page_t* page, /*!< in: b-tree page */ 154 dict_index_t* index, /*!< in/out: index */ 155 const char* ctx) /*!< in: context (for logging) */ 156 MY_ATTRIBUTE((nonnull)); 157 /**************************************************************//** 158 Restore in index->blobs any references to off-page columns 159 Used when page reorganize fails due to compressed page overflow. */ 160 UNIV_INTERN 161 void 162 btr_blob_dbg_restore( 163 /*=================*/ 164 const page_t* npage, /*!< in: page that failed to compress */ 165 const page_t* page, /*!< in: copy of original page */ 166 dict_index_t* index, /*!< in/out: index */ 167 const char* ctx) /*!< in: context (for logging) */ 168 MY_ATTRIBUTE((nonnull)); 169 170 /** Operation that processes the BLOB references of an index record 171 @param[in] rec record on index page 172 @param[in/out] index the index tree of the record 173 @param[in] offsets rec_get_offsets(rec,index) 174 @param[in] ctx context (for logging) 175 @return number of BLOB references processed */ 176 typedef ulint (*btr_blob_dbg_op_f) 177 (const rec_t* rec,dict_index_t* index,const ulint* offsets,const char* ctx); 178 179 /**************************************************************//** 180 Count and process all references to off-page columns on a page. 181 @return number of references processed */ 182 UNIV_INTERN 183 ulint 184 btr_blob_dbg_op( 185 /*============*/ 186 const page_t* page, /*!< in: B-tree leaf page */ 187 const rec_t* rec, /*!< in: record to start from 188 (NULL to process the whole page) */ 189 dict_index_t* index, /*!< in/out: index */ 190 const char* ctx, /*!< in: context (for logging) */ 191 const btr_blob_dbg_op_f op) /*!< in: operation on records */ 192 MY_ATTRIBUTE((nonnull(1,3,4,5))); 193 #else /* UNIV_BLOB_DEBUG */ 194 # define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0) 195 # define btr_blob_dbg_add(page, index, ctx) ((void) 0) 196 # define btr_blob_dbg_remove_rec(rec, index, offsets, ctx) ((void) 0) 197 # define btr_blob_dbg_remove(page, index, ctx) ((void) 0) 198 # define btr_blob_dbg_restore(npage, page, index, ctx) ((void) 0) 199 # define btr_blob_dbg_op(page, rec, index, ctx, op) ((void) 0) 200 #endif /* UNIV_BLOB_DEBUG */ 201 202 /** The size of a reference to data stored on a different page. 203 The reference is stored at the end of the prefix of the field 204 in the index record. */ 205 #define BTR_EXTERN_FIELD_REF_SIZE 20 206 207 /** A BLOB field reference full of zero, for use in assertions and tests. 208 Initially, BLOB field references are set to zero, in 209 dtuple_convert_big_rec(). */ 210 extern const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE]; 211 212 #endif 213