Drizzled Public API Documentation

btr0btr.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1994, 2010, Innobase Oy. 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., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #pragma once
27 #ifndef btr0btr_h
28 #define btr0btr_h
29 
30 #include "univ.i"
31 
32 #include "dict0dict.h"
33 #include "data0data.h"
34 #include "page0cur.h"
35 #include "mtr0mtr.h"
36 #include "btr0types.h"
37 
38 #ifndef UNIV_HOTBACKUP
39 
41 #define BTR_PAGE_MAX_REC_SIZE (UNIV_PAGE_SIZE / 2 - 200)
42 
52 #define BTR_MAX_LEVELS 100
53 
57  BTR_SEARCH_LEAF = RW_S_LATCH,
59  BTR_MODIFY_LEAF = RW_X_LATCH,
61  BTR_NO_LATCHES = RW_NO_LATCH,
70 };
71 
72 /* BTR_INSERT, BTR_DELETE and BTR_DELETE_MARK are mutually exclusive. */
73 
77 #define BTR_INSERT 512
78 
81 #define BTR_ESTIMATE 1024
82 
86 #define BTR_IGNORE_SEC_UNIQUE 2048
87 
90 #define BTR_DELETE_MARK 4096
91 
94 #define BTR_DELETE 8192
95 
96 #ifdef UNIV_BLOB_DEBUG
97 # include "ut0rbt.h"
99 struct btr_blob_dbg_struct
100 {
101  unsigned blob_page_no:32;
102  unsigned ref_page_no:32;
103  unsigned ref_heap_no:16;
104  unsigned ref_field_no:10;
105  unsigned owner:1;
106  unsigned always_owner:1;
110  unsigned del:1;
112 };
113 
114 /**************************************************************/
116 UNIV_INTERN
117 void
118 btr_blob_dbg_add_blob(
119 /*==================*/
120  const rec_t* rec,
121  ulint field_no,
122  ulint page_no,
123  dict_index_t* index,
124  const char* ctx)
125  __attribute__((nonnull));
126 /**************************************************************/
130 UNIV_INTERN
131 void
132 btr_blob_dbg_print(
133 /*===============*/
134  const dict_index_t* index)
135  __attribute__((nonnull));
136 /**************************************************************/
140 UNIV_INTERN
141 ibool
142 btr_blob_dbg_is_empty(
143 /*==================*/
144  dict_index_t* index,
145  ulint page_no)
146  __attribute__((nonnull, warn_unused_result));
147 
148 /**************************************************************/
150 UNIV_INTERN
151 void
152 btr_blob_dbg_set_deleted_flag(
153 /*==========================*/
154  const rec_t* rec,
155  dict_index_t* index,
156  const ulint* offsets,
157  ibool del)
158  __attribute__((nonnull));
159 /**************************************************************/
161 UNIV_INTERN
162 void
163 btr_blob_dbg_owner(
164 /*===============*/
165  const rec_t* rec,
166  dict_index_t* index,
167  const ulint* offsets,
168  ulint i,
169  ibool own)
170  __attribute__((nonnull));
172 # define btr_blob_dbg_assert_empty(index, page_no) \
173  ut_a(btr_blob_dbg_is_empty(index, page_no))
174 #else /* UNIV_BLOB_DEBUG */
175 # define btr_blob_dbg_add_blob(rec, field_no, page, index, ctx) ((void) 0)
176 # define btr_blob_dbg_set_deleted_flag(rec, index, offsets, del)((void) 0)
177 # define btr_blob_dbg_owner(rec, index, offsets, i, val) ((void) 0)
178 # define btr_blob_dbg_assert_empty(index, page_no) ((void) 0)
179 #endif /* UNIV_BLOB_DEBUG */
180 
181 /**************************************************************/
184 UNIV_INTERN
185 page_t*
186 btr_root_get(
187 /*=========*/
188  dict_index_t* index,
189  mtr_t* mtr);
190 /**************************************************************/
192 UNIV_INLINE
195 /*===============*/
196  ulint space,
197  ulint zip_size,
199  ulint page_no,
200  ulint mode,
201  const char* file,
202  ulint line,
203  mtr_t* mtr)
204  __attribute__((nonnull));
212 # define btr_block_get(space,zip_size,page_no,mode,mtr) \
213  btr_block_get_func(space,zip_size,page_no,mode,__FILE__,__LINE__,mtr)
214 
221 # define btr_page_get(space,zip_size,page_no,mode,mtr) \
222  buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,mtr))
223 #endif /* !UNIV_HOTBACKUP */
224 /**************************************************************/
227 UNIV_INLINE
228 index_id_t
230 /*==================*/
231  const page_t* page);
232 #ifndef UNIV_HOTBACKUP
233 /********************************************************/
236 UNIV_INLINE
237 ulint
239 /*===================*/
240  const page_t* page);
241 /********************************************************/
244 UNIV_INLINE
245 ulint
247 /*===============*/
248  const page_t* page,
249  mtr_t* mtr);
250 /********************************************************/
253 UNIV_INLINE
254 ulint
256 /*==============*/
257  const page_t* page,
258  mtr_t* mtr);
259 /********************************************************/
262 UNIV_INLINE
263 ulint
265 /*==============*/
266  const page_t* page,
267  mtr_t* mtr);
268 /*************************************************************/
272 UNIV_INTERN
273 rec_t*
274 btr_get_prev_user_rec(
275 /*==================*/
276  rec_t* rec,
277  mtr_t* mtr);
279 /*************************************************************/
283 UNIV_INTERN
284 rec_t*
285 btr_get_next_user_rec(
286 /*==================*/
287  rec_t* rec,
288  mtr_t* mtr);
290 /**************************************************************/
292 UNIV_INLINE
293 void
295 /*==================*/
296  buf_block_t* block,
297  ulint latch_mode,
299  mtr_t* mtr);
300 /**************************************************************/
307 UNIV_INLINE
308 ulint
310 /*===========================*/
311  const rec_t* rec,
312  const ulint* offsets);
313 /************************************************************/
316 UNIV_INTERN
317 ulint
318 btr_create(
319 /*=======*/
320  ulint type,
321  ulint space,
322  ulint zip_size,
324  index_id_t index_id,
325  dict_index_t* index,
326  mtr_t* mtr);
327 /************************************************************/
330 UNIV_INTERN
331 void
332 btr_free_but_not_root(
333 /*==================*/
334  ulint space,
335  ulint zip_size,
337  ulint root_page_no);
338 /************************************************************/
340 UNIV_INTERN
341 void
342 btr_free_root(
343 /*==========*/
344  ulint space,
345  ulint zip_size,
347  ulint root_page_no,
348  mtr_t* mtr);
350 /*************************************************************/
357 UNIV_INTERN
358 rec_t*
359 btr_root_raise_and_insert(
360 /*======================*/
361  btr_cur_t* cursor,
365  const dtuple_t* tuple,
366  ulint n_ext,
367  mtr_t* mtr);
368 /*************************************************************/
375 UNIV_INTERN
376 ibool
377 btr_page_reorganize(
378 /*================*/
379  buf_block_t* block,
380  dict_index_t* index,
381  mtr_t* mtr);
382 /*************************************************************/
386 UNIV_INTERN
387 ibool
388 btr_page_get_split_rec_to_left(
389 /*===========================*/
390  btr_cur_t* cursor,
391  rec_t** split_rec);
394 /*************************************************************/
398 UNIV_INTERN
399 ibool
400 btr_page_get_split_rec_to_right(
401 /*============================*/
402  btr_cur_t* cursor,
403  rec_t** split_rec);
406 /*************************************************************/
415 UNIV_INTERN
416 rec_t*
417 btr_page_split_and_insert(
418 /*======================*/
419  btr_cur_t* cursor,
422  const dtuple_t* tuple,
423  ulint n_ext,
424  mtr_t* mtr);
425 /*******************************************************/
428 UNIV_INTERN
429 void
430 btr_insert_on_non_leaf_level_func(
431 /*==============================*/
432  dict_index_t* index,
433  ulint level,
434  dtuple_t* tuple,
435  const char* file,
436  ulint line,
437  mtr_t* mtr);
438 # define btr_insert_on_non_leaf_level(i,l,t,m) \
439  btr_insert_on_non_leaf_level_func(i,l,t,__FILE__,__LINE__,m)
440 #endif /* !UNIV_HOTBACKUP */
441 /****************************************************************/
443 UNIV_INTERN
444 void
445 btr_set_min_rec_mark(
446 /*=================*/
447  rec_t* rec,
448  mtr_t* mtr);
449 #ifndef UNIV_HOTBACKUP
450 /*************************************************************/
452 UNIV_INTERN
453 void
454 btr_node_ptr_delete(
455 /*================*/
456  dict_index_t* index,
457  buf_block_t* block,
458  mtr_t* mtr);
459 #ifdef UNIV_DEBUG
460 /************************************************************/
463 UNIV_INTERN
464 ibool
465 btr_check_node_ptr(
466 /*===============*/
467  dict_index_t* index,
468  buf_block_t* block,
469  mtr_t* mtr);
470 #endif /* UNIV_DEBUG */
471 /*************************************************************/
481 UNIV_INTERN
482 ibool
483 btr_compress(
484 /*=========*/
485  btr_cur_t* cursor,
489  mtr_t* mtr);
490 /*************************************************************/
494 UNIV_INTERN
495 void
496 btr_discard_page(
497 /*=============*/
498  btr_cur_t* cursor,
500  mtr_t* mtr);
501 #endif /* !UNIV_HOTBACKUP */
502 /****************************************************************/
506 UNIV_INTERN
507 byte*
508 btr_parse_set_min_rec_mark(
509 /*=======================*/
510  byte* ptr,
511  byte* end_ptr,
512  ulint comp,
513  page_t* page,
514  mtr_t* mtr);
515 /***********************************************************/
518 UNIV_INTERN
519 byte*
520 btr_parse_page_reorganize(
521 /*======================*/
522  byte* ptr,
523  byte* end_ptr,
524  dict_index_t* index,
525  buf_block_t* block,
526  mtr_t* mtr);
527 #ifndef UNIV_HOTBACKUP
528 /**************************************************************/
531 UNIV_INTERN
532 ulint
533 btr_get_size(
534 /*=========*/
535  dict_index_t* index,
536  ulint flag);
537 /**************************************************************/
541 UNIV_INTERN
543 btr_page_alloc(
544 /*===========*/
545  dict_index_t* index,
546  ulint hint_page_no,
547  byte file_direction,
549  ulint level,
551  mtr_t* mtr);
552 /**************************************************************/
555 UNIV_INTERN
556 void
557 btr_page_free(
558 /*==========*/
559  dict_index_t* index,
560  buf_block_t* block,
561  mtr_t* mtr);
562 /**************************************************************/
566 UNIV_INTERN
567 void
568 btr_page_free_low(
569 /*==============*/
570  dict_index_t* index,
571  buf_block_t* block,
572  ulint level,
573  mtr_t* mtr);
574 #ifdef UNIV_BTR_PRINT
575 /*************************************************************/
577 UNIV_INTERN
578 void
579 btr_print_size(
580 /*===========*/
581  dict_index_t* index);
582 /**************************************************************/
584 UNIV_INTERN
585 void
586 btr_print_index(
587 /*============*/
588  dict_index_t* index,
589  ulint width);
591 #endif /* UNIV_BTR_PRINT */
592 /************************************************************/
596 UNIV_INTERN
597 ibool
598 btr_index_rec_validate(
599 /*===================*/
600  const rec_t* rec,
601  const dict_index_t* index,
602  ibool dump_on_error);
605 /**************************************************************/
608 UNIV_INTERN
609 ibool
610 btr_validate_index(
611 /*===============*/
612  dict_index_t* index,
613  trx_t* trx);
615 #define BTR_N_LEAF_PAGES 1
616 #define BTR_TOTAL_SIZE 2
617 #endif /* !UNIV_HOTBACKUP */
618 
619 #ifndef UNIV_NONINL
620 #include "btr0btr.ic"
621 #endif
622 
623 #endif