00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027 #ifndef btr0btr_h
00028 #define btr0btr_h
00029
00030 #include "univ.i"
00031
00032 #include "dict0dict.h"
00033 #include "data0data.h"
00034 #include "page0cur.h"
00035 #include "mtr0mtr.h"
00036 #include "btr0types.h"
00037
00038 #ifndef UNIV_HOTBACKUP
00039
00041 #define BTR_PAGE_MAX_REC_SIZE (UNIV_PAGE_SIZE / 2 - 200)
00042
00052 #define BTR_MAX_LEVELS 100
00053
00055 enum btr_latch_mode {
00057 BTR_SEARCH_LEAF = RW_S_LATCH,
00059 BTR_MODIFY_LEAF = RW_X_LATCH,
00061 BTR_NO_LATCHES = RW_NO_LATCH,
00063 BTR_MODIFY_TREE = 33,
00065 BTR_CONT_MODIFY_TREE = 34,
00067 BTR_SEARCH_PREV = 35,
00069 BTR_MODIFY_PREV = 36
00070 };
00071
00072
00073
00077 #define BTR_INSERT 512
00078
00081 #define BTR_ESTIMATE 1024
00082
00086 #define BTR_IGNORE_SEC_UNIQUE 2048
00087
00090 #define BTR_DELETE_MARK 4096
00091
00094 #define BTR_DELETE 8192
00095
00096
00099 UNIV_INTERN
00100 page_t*
00101 btr_root_get(
00102
00103 dict_index_t* index,
00104 mtr_t* mtr);
00105
00107 UNIV_INLINE
00108 buf_block_t*
00109 btr_block_get_func(
00110
00111 ulint space,
00112 ulint zip_size,
00114 ulint page_no,
00115 ulint mode,
00116 const char* file,
00117 ulint line,
00118 mtr_t* mtr)
00119 __attribute__((nonnull));
00127 # define btr_block_get(space,zip_size,page_no,mode,mtr) \
00128 btr_block_get_func(space,zip_size,page_no,mode,__FILE__,__LINE__,mtr)
00129
00136 # define btr_page_get(space,zip_size,page_no,mode,mtr) \
00137 buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,mtr))
00138 #endif
00139
00142 UNIV_INLINE
00143 index_id_t
00144 btr_page_get_index_id(
00145
00146 const page_t* page);
00147 #ifndef UNIV_HOTBACKUP
00148
00151 UNIV_INLINE
00152 ulint
00153 btr_page_get_level_low(
00154
00155 const page_t* page);
00156
00159 UNIV_INLINE
00160 ulint
00161 btr_page_get_level(
00162
00163 const page_t* page,
00164 mtr_t* mtr);
00165
00168 UNIV_INLINE
00169 ulint
00170 btr_page_get_next(
00171
00172 const page_t* page,
00173 mtr_t* mtr);
00174
00177 UNIV_INLINE
00178 ulint
00179 btr_page_get_prev(
00180
00181 const page_t* page,
00182 mtr_t* mtr);
00183
00187 UNIV_INTERN
00188 rec_t*
00189 btr_get_prev_user_rec(
00190
00191 rec_t* rec,
00192 mtr_t* mtr);
00194
00198 UNIV_INTERN
00199 rec_t*
00200 btr_get_next_user_rec(
00201
00202 rec_t* rec,
00203 mtr_t* mtr);
00205
00207 UNIV_INLINE
00208 void
00209 btr_leaf_page_release(
00210
00211 buf_block_t* block,
00212 ulint latch_mode,
00214 mtr_t* mtr);
00215
00222 UNIV_INLINE
00223 ulint
00224 btr_node_ptr_get_child_page_no(
00225
00226 const rec_t* rec,
00227 const ulint* offsets);
00228
00231 UNIV_INTERN
00232 ulint
00233 btr_create(
00234
00235 ulint type,
00236 ulint space,
00237 ulint zip_size,
00239 index_id_t index_id,
00240 dict_index_t* index,
00241 mtr_t* mtr);
00242
00245 UNIV_INTERN
00246 void
00247 btr_free_but_not_root(
00248
00249 ulint space,
00250 ulint zip_size,
00252 ulint root_page_no);
00253
00255 UNIV_INTERN
00256 void
00257 btr_free_root(
00258
00259 ulint space,
00260 ulint zip_size,
00262 ulint root_page_no,
00263 mtr_t* mtr);
00265
00272 UNIV_INTERN
00273 rec_t*
00274 btr_root_raise_and_insert(
00275
00276 btr_cur_t* cursor,
00280 const dtuple_t* tuple,
00281 ulint n_ext,
00282 mtr_t* mtr);
00283
00290 UNIV_INTERN
00291 ibool
00292 btr_page_reorganize(
00293
00294 buf_block_t* block,
00295 dict_index_t* index,
00296 mtr_t* mtr);
00297
00301 UNIV_INTERN
00302 ibool
00303 btr_page_get_split_rec_to_left(
00304
00305 btr_cur_t* cursor,
00306 rec_t** split_rec);
00309
00313 UNIV_INTERN
00314 ibool
00315 btr_page_get_split_rec_to_right(
00316
00317 btr_cur_t* cursor,
00318 rec_t** split_rec);
00321
00330 UNIV_INTERN
00331 rec_t*
00332 btr_page_split_and_insert(
00333
00334 btr_cur_t* cursor,
00337 const dtuple_t* tuple,
00338 ulint n_ext,
00339 mtr_t* mtr);
00340
00343 UNIV_INTERN
00344 void
00345 btr_insert_on_non_leaf_level_func(
00346
00347 dict_index_t* index,
00348 ulint level,
00349 dtuple_t* tuple,
00350 const char* file,
00351 ulint line,
00352 mtr_t* mtr);
00353 # define btr_insert_on_non_leaf_level(i,l,t,m) \
00354 btr_insert_on_non_leaf_level_func(i,l,t,__FILE__,__LINE__,m)
00355 #endif
00356
00358 UNIV_INTERN
00359 void
00360 btr_set_min_rec_mark(
00361
00362 rec_t* rec,
00363 mtr_t* mtr);
00364 #ifndef UNIV_HOTBACKUP
00365
00367 UNIV_INTERN
00368 void
00369 btr_node_ptr_delete(
00370
00371 dict_index_t* index,
00372 buf_block_t* block,
00373 mtr_t* mtr);
00374 #ifdef UNIV_DEBUG
00375
00378 UNIV_INTERN
00379 ibool
00380 btr_check_node_ptr(
00381
00382 dict_index_t* index,
00383 buf_block_t* block,
00384 mtr_t* mtr);
00385 #endif
00386
00396 UNIV_INTERN
00397 ibool
00398 btr_compress(
00399
00400 btr_cur_t* cursor,
00404 mtr_t* mtr);
00405
00409 UNIV_INTERN
00410 void
00411 btr_discard_page(
00412
00413 btr_cur_t* cursor,
00415 mtr_t* mtr);
00416 #endif
00417
00421 UNIV_INTERN
00422 byte*
00423 btr_parse_set_min_rec_mark(
00424
00425 byte* ptr,
00426 byte* end_ptr,
00427 ulint comp,
00428 page_t* page,
00429 mtr_t* mtr);
00430
00433 UNIV_INTERN
00434 byte*
00435 btr_parse_page_reorganize(
00436
00437 byte* ptr,
00438 byte* end_ptr,
00439 dict_index_t* index,
00440 buf_block_t* block,
00441 mtr_t* mtr);
00442 #ifndef UNIV_HOTBACKUP
00443
00446 UNIV_INTERN
00447 ulint
00448 btr_get_size(
00449
00450 dict_index_t* index,
00451 ulint flag);
00452
00456 UNIV_INTERN
00457 buf_block_t*
00458 btr_page_alloc(
00459
00460 dict_index_t* index,
00461 ulint hint_page_no,
00462 byte file_direction,
00464 ulint level,
00466 mtr_t* mtr);
00467
00470 UNIV_INTERN
00471 void
00472 btr_page_free(
00473
00474 dict_index_t* index,
00475 buf_block_t* block,
00476 mtr_t* mtr);
00477
00481 UNIV_INTERN
00482 void
00483 btr_page_free_low(
00484
00485 dict_index_t* index,
00486 buf_block_t* block,
00487 ulint level,
00488 mtr_t* mtr);
00489 #ifdef UNIV_BTR_PRINT
00490
00492 UNIV_INTERN
00493 void
00494 btr_print_size(
00495
00496 dict_index_t* index);
00497
00499 UNIV_INTERN
00500 void
00501 btr_print_index(
00502
00503 dict_index_t* index,
00504 ulint width);
00506 #endif
00507
00511 UNIV_INTERN
00512 ibool
00513 btr_index_rec_validate(
00514
00515 const rec_t* rec,
00516 const dict_index_t* index,
00517 ibool dump_on_error);
00520
00523 UNIV_INTERN
00524 ibool
00525 btr_validate_index(
00526
00527 dict_index_t* index,
00528 trx_t* trx);
00530 #define BTR_N_LEAF_PAGES 1
00531 #define BTR_TOTAL_SIZE 2
00532 #endif
00533
00534 #ifndef UNIV_NONINL
00535 #include "btr0btr.ic"
00536 #endif
00537
00538 #endif