1 /***************************************************************************** 2 3 Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 4 5 This program is free software; you can redistribute it and/or modify it under 6 the terms of the GNU General Public License as published by the Free Software 7 Foundation; version 2 of the License. 8 9 This program is distributed in the hope that it will be useful, but WITHOUT 10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 this program; if not, write to the Free Software Foundation, Inc., 15 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 17 *****************************************************************************/ 18 19 /********************************************************************//** 20 @file include/btr0types.h 21 The index tree general types 22 23 Created 2/17/1996 Heikki Tuuri 24 *************************************************************************/ 25 26 #ifndef btr0types_h 27 #define btr0types_h 28 29 #include "univ.i" 30 31 #include "rem0types.h" 32 #include "page0types.h" 33 #include "sync0rw.h" 34 35 /** Persistent cursor */ 36 typedef struct btr_pcur_struct btr_pcur_t; 37 /** B-tree cursor */ 38 typedef struct btr_cur_struct btr_cur_t; 39 /** B-tree search information for the adaptive hash index */ 40 typedef struct btr_search_struct btr_search_t; 41 42 #ifndef UNIV_HOTBACKUP 43 44 /** @brief The latch protecting the adaptive search system 45 46 This latch protects the 47 (1) hash index; 48 (2) columns of a record to which we have a pointer in the hash index; 49 50 but does NOT protect: 51 52 (3) next record offset field in a record; 53 (4) next or previous records on the same page. 54 55 Bear in mind (3) and (4) when using the hash index. 56 */ 57 extern rw_lock_t* btr_search_latch_temp; 58 59 #endif /* UNIV_HOTBACKUP */ 60 61 /** The latch protecting the adaptive search system */ 62 #define btr_search_latch (*btr_search_latch_temp) 63 64 /** Flag: has the search system been enabled? 65 Protected by btr_search_latch. */ 66 extern char btr_search_enabled; 67 68 #ifdef UNIV_BLOB_DEBUG 69 # include "buf0types.h" 70 /** An index->blobs entry for keeping track of off-page column references */ 71 typedef struct btr_blob_dbg_struct btr_blob_dbg_t; 72 73 /** Insert to index->blobs a reference to an off-page column. 74 @param index the index tree 75 @param b the reference 76 @param ctx context (for logging) */ 77 UNIV_INTERN 78 void 79 btr_blob_dbg_rbt_insert( 80 /*====================*/ 81 dict_index_t* index, /*!< in/out: index tree */ 82 const btr_blob_dbg_t* b, /*!< in: the reference */ 83 const char* ctx) /*!< in: context (for logging) */ 84 __attribute__((nonnull)); 85 86 /** Remove from index->blobs a reference to an off-page column. 87 @param index the index tree 88 @param b the reference 89 @param ctx context (for logging) */ 90 UNIV_INTERN 91 void 92 btr_blob_dbg_rbt_delete( 93 /*====================*/ 94 dict_index_t* index, /*!< in/out: index tree */ 95 const btr_blob_dbg_t* b, /*!< in: the reference */ 96 const char* ctx) /*!< in: context (for logging) */ 97 __attribute__((nonnull)); 98 99 /**************************************************************//** 100 Add to index->blobs any references to off-page columns from a record. 101 @return number of references added */ 102 UNIV_INTERN 103 ulint 104 btr_blob_dbg_add_rec( 105 /*=================*/ 106 const rec_t* rec, /*!< in: record */ 107 dict_index_t* index, /*!< in/out: index */ 108 const ulint* offsets,/*!< in: offsets */ 109 const char* ctx) /*!< in: context (for logging) */ 110 __attribute__((nonnull)); 111 /**************************************************************//** 112 Remove from index->blobs any references to off-page columns from a record. 113 @return number of references removed */ 114 UNIV_INTERN 115 ulint 116 btr_blob_dbg_remove_rec( 117 /*====================*/ 118 const rec_t* rec, /*!< in: record */ 119 dict_index_t* index, /*!< in/out: index */ 120 const ulint* offsets,/*!< in: offsets */ 121 const char* ctx) /*!< in: context (for logging) */ 122 __attribute__((nonnull)); 123 /**************************************************************//** 124 Count and add to index->blobs any references to off-page columns 125 from records on a page. 126 @return number of references added */ 127 UNIV_INTERN 128 ulint 129 btr_blob_dbg_add( 130 /*=============*/ 131 const page_t* page, /*!< in: rewritten page */ 132 dict_index_t* index, /*!< in/out: index */ 133 const char* ctx) /*!< in: context (for logging) */ 134 __attribute__((nonnull)); 135 /**************************************************************//** 136 Count and remove from index->blobs any references to off-page columns 137 from records on a page. 138 Used when reorganizing a page, before copying the records. 139 @return number of references removed */ 140 UNIV_INTERN 141 ulint 142 btr_blob_dbg_remove( 143 /*================*/ 144 const page_t* page, /*!< in: b-tree page */ 145 dict_index_t* index, /*!< in/out: index */ 146 const char* ctx) /*!< in: context (for logging) */ 147 __attribute__((nonnull)); 148 /**************************************************************//** 149 Restore in index->blobs any references to off-page columns 150 Used when page reorganize fails due to compressed page overflow. */ 151 UNIV_INTERN 152 void 153 btr_blob_dbg_restore( 154 /*=================*/ 155 const page_t* npage, /*!< in: page that failed to compress */ 156 const page_t* page, /*!< in: copy of original page */ 157 dict_index_t* index, /*!< in/out: index */ 158 const char* ctx) /*!< in: context (for logging) */ 159 __attribute__((nonnull)); 160 161 /** Operation that processes the BLOB references of an index record 162 @param[in] rec record on index page 163 @param[in/out] index the index tree of the record 164 @param[in] offsets rec_get_offsets(rec,index) 165 @param[in] ctx context (for logging) 166 @return number of BLOB references processed */ 167 typedef ulint (*btr_blob_dbg_op_f) 168 (const rec_t* rec,dict_index_t* index,const ulint* offsets,const char* ctx); 169 170 /**************************************************************//** 171 Count and process all references to off-page columns on a page. 172 @return number of references processed */ 173 UNIV_INTERN 174 ulint 175 btr_blob_dbg_op( 176 /*============*/ 177 const page_t* page, /*!< in: B-tree leaf page */ 178 const rec_t* rec, /*!< in: record to start from 179 (NULL to process the whole page) */ 180 dict_index_t* index, /*!< in/out: index */ 181 const char* ctx, /*!< in: context (for logging) */ 182 const btr_blob_dbg_op_f op) /*!< in: operation on records */ 183 __attribute__((nonnull(1,3,4,5))); 184 #else /* UNIV_BLOB_DEBUG */ 185 # define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0) 186 # define btr_blob_dbg_add(page, index, ctx) ((void) 0) 187 # define btr_blob_dbg_remove_rec(rec, index, offsets, ctx) ((void) 0) 188 # define btr_blob_dbg_remove(page, index, ctx) ((void) 0) 189 # define btr_blob_dbg_restore(npage, page, index, ctx) ((void) 0) 190 # define btr_blob_dbg_op(page, rec, index, ctx, op) ((void) 0) 191 #endif /* UNIV_BLOB_DEBUG */ 192 193 /** The size of a reference to data stored on a different page. 194 The reference is stored at the end of the prefix of the field 195 in the index record. */ 196 #define BTR_EXTERN_FIELD_REF_SIZE 20 197 198 /** A BLOB field reference full of zero, for use in assertions and tests. 199 Initially, BLOB field references are set to zero, in 200 dtuple_convert_big_rec(). */ 201 extern const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE]; 202 203 #endif 204