Drizzled Public API Documentation

btr0cur.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 btr0cur_h
28 #define btr0cur_h
29 
30 #include "univ.i"
31 #include "dict0dict.h"
32 #include "page0cur.h"
33 #include "btr0types.h"
34 
35 /* Mode flags for btr_cur operations; these can be ORed */
36 #define BTR_NO_UNDO_LOG_FLAG 1 /* do no undo logging */
37 #define BTR_NO_LOCKING_FLAG 2 /* do no record lock checking */
38 #define BTR_KEEP_SYS_FLAG 4 /* sys fields will be found from the
39  update vector or inserted entry */
40 
41 #ifndef UNIV_HOTBACKUP
42 #include "que0types.h"
43 #include "row0types.h"
44 #include "ha0ha.h"
45 
46 #define BTR_CUR_ADAPT
47 #define BTR_CUR_HASH_ADAPT
48 
49 #ifdef UNIV_DEBUG
50 /*********************************************************/
53 UNIV_INLINE
55 btr_cur_get_page_cur(
56 /*=================*/
57  const btr_cur_t* cursor);
58 #else /* UNIV_DEBUG */
59 # define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
60 #endif /* UNIV_DEBUG */
61 /*********************************************************/
64 UNIV_INLINE
67 /*==============*/
68  btr_cur_t* cursor);
69 /*********************************************************/
72 UNIV_INLINE
73 rec_t*
75 /*============*/
76  btr_cur_t* cursor);
77 /*********************************************************/
80 UNIV_INLINE
83 /*=================*/
84  btr_cur_t* cursor);
85 /*********************************************************/
87 UNIV_INLINE
88 void
90 /*===============*/
91  btr_cur_t* cursor);
92 /*********************************************************/
95 UNIV_INLINE
96 page_t*
98 /*=============*/
99  btr_cur_t* cursor);
100 /*********************************************************/
103 UNIV_INLINE
106 /*==============*/
107  btr_cur_t* cursor);
108 /*********************************************************/
110 UNIV_INLINE
111 void
113 /*=============*/
114  dict_index_t* index,
115  rec_t* rec,
116  buf_block_t* block,
117  btr_cur_t* cursor);
118 /********************************************************************/
125 UNIV_INTERN
126 void
127 btr_cur_search_to_nth_level(
128 /*========================*/
129  dict_index_t* index,
130  ulint level,
131  const dtuple_t* tuple,
134  ulint mode,
141  ulint latch_mode,
152  btr_cur_t* cursor,
154  ulint has_search_latch,
157  const char* file,
158  ulint line,
159  mtr_t* mtr);
160 /*****************************************************************/
162 UNIV_INTERN
163 void
164 btr_cur_open_at_index_side_func(
165 /*============================*/
166  ibool from_left,
168  dict_index_t* index,
169  ulint latch_mode,
170  btr_cur_t* cursor,
171  const char* file,
172  ulint line,
173  mtr_t* mtr);
174 #define btr_cur_open_at_index_side(f,i,l,c,m) \
175  btr_cur_open_at_index_side_func(f,i,l,c,__FILE__,__LINE__,m)
176 /**********************************************************************/
178 UNIV_INTERN
179 void
180 btr_cur_open_at_rnd_pos_func(
181 /*=========================*/
182  dict_index_t* index,
183  ulint latch_mode,
184  btr_cur_t* cursor,
185  const char* file,
186  ulint line,
187  mtr_t* mtr);
188 #define btr_cur_open_at_rnd_pos(i,l,c,m) \
189  btr_cur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m)
190 /*************************************************************/
197 UNIV_INTERN
198 ulint
199 btr_cur_optimistic_insert(
200 /*======================*/
201  ulint flags,
204  btr_cur_t* cursor,
206  dtuple_t* entry,
207  rec_t** rec,
209  big_rec_t** big_rec,
212  ulint n_ext,
213  que_thr_t* thr,
214  mtr_t* mtr);
219 /*************************************************************/
225 UNIV_INTERN
226 ulint
227 btr_cur_pessimistic_insert(
228 /*=======================*/
229  ulint flags,
235  btr_cur_t* cursor,
237  dtuple_t* entry,
238  rec_t** rec,
240  big_rec_t** big_rec,
243  ulint n_ext,
244  que_thr_t* thr,
245  mtr_t* mtr);
246 /*************************************************************/
250 UNIV_INTERN
251 ibool
252 btr_cur_update_alloc_zip(
253 /*=====================*/
254  page_zip_des_t* page_zip,
255  buf_block_t* block,
256  dict_index_t* index,
257  ulint length,
258  ibool create,
260  mtr_t* mtr)
261  UNIV_WARN_UNUSED_RESULT_NONNULL;
262 /*************************************************************/
265 UNIV_INTERN
266 ulint
267 btr_cur_update_in_place(
268 /*====================*/
269  ulint flags,
270  btr_cur_t* cursor,
273  const upd_t* update,
274  ulint cmpl_info,
276  que_thr_t* thr,
277  mtr_t* mtr);
279 /*************************************************************/
287 UNIV_INTERN
288 ulint
289 btr_cur_optimistic_update(
290 /*======================*/
291  ulint flags,
292  btr_cur_t* cursor,
295  const upd_t* update,
297  ulint cmpl_info,
299  que_thr_t* thr,
300  mtr_t* mtr);
302 /*************************************************************/
308 UNIV_INTERN
309 ulint
310 btr_cur_pessimistic_update(
311 /*=======================*/
312  ulint flags,
314  btr_cur_t* cursor,
315  mem_heap_t** heap,
316  big_rec_t** big_rec,
318  const upd_t* update,
321  ulint cmpl_info,
323  que_thr_t* thr,
324  mtr_t* mtr);
326 /***********************************************************/
332 UNIV_INTERN
333 ulint
334 btr_cur_del_mark_set_clust_rec(
335 /*===========================*/
336  ulint flags,
337  btr_cur_t* cursor,
338  ibool val,
339  que_thr_t* thr,
340  mtr_t* mtr);
341 /***********************************************************/
344 UNIV_INTERN
345 ulint
346 btr_cur_del_mark_set_sec_rec(
347 /*=========================*/
348  ulint flags,
349  btr_cur_t* cursor,
350  ibool val,
351  que_thr_t* thr,
352  mtr_t* mtr);
353 /*************************************************************/
360 UNIV_INTERN
361 ibool
362 btr_cur_compress_if_useful(
363 /*=======================*/
364  btr_cur_t* cursor,
367  mtr_t* mtr);
368 /*******************************************************/
373 UNIV_INTERN
374 ibool
375 btr_cur_optimistic_delete(
376 /*======================*/
377  btr_cur_t* cursor,
381  mtr_t* mtr);
385 /*************************************************************/
393 UNIV_INTERN
394 ibool
395 btr_cur_pessimistic_delete(
396 /*=======================*/
397  ulint* err,
402  ibool has_reserved_extents,
406  btr_cur_t* cursor,
410  enum trx_rb_ctx rb_ctx,
411  mtr_t* mtr);
412 #endif /* !UNIV_HOTBACKUP */
413 /***********************************************************/
416 UNIV_INTERN
417 byte*
418 btr_cur_parse_update_in_place(
419 /*==========================*/
420  byte* ptr,
421  byte* end_ptr,
422  page_t* page,
423  page_zip_des_t* page_zip,
424  dict_index_t* index);
425 /****************************************************************/
429 UNIV_INTERN
430 byte*
431 btr_cur_parse_del_mark_set_clust_rec(
432 /*=================================*/
433  byte* ptr,
434  byte* end_ptr,
435  page_t* page,
436  page_zip_des_t* page_zip,
437  dict_index_t* index);
438 /****************************************************************/
442 UNIV_INTERN
443 byte*
444 btr_cur_parse_del_mark_set_sec_rec(
445 /*===============================*/
446  byte* ptr,
447  byte* end_ptr,
448  page_t* page,
449  page_zip_des_t* page_zip);
450 #ifndef UNIV_HOTBACKUP
451 /*******************************************************************/
454 UNIV_INTERN
455 ib_int64_t
456 btr_estimate_n_rows_in_range(
457 /*=========================*/
458  dict_index_t* index,
459  const dtuple_t* tuple1,
460  ulint mode1,
461  const dtuple_t* tuple2,
462  ulint mode2);
463 /*******************************************************************/
467 UNIV_INTERN
468 void
469 btr_estimate_number_of_different_key_vals(
470 /*======================================*/
471  dict_index_t* index);
472 /*******************************************************************/
478 UNIV_INTERN
479 ibool
480 btr_cur_mark_extern_inherited_fields(
481 /*=================================*/
482  page_zip_des_t* page_zip,
484  rec_t* rec,
485  dict_index_t* index,
486  const ulint* offsets,
487  const upd_t* update,
488  mtr_t* mtr);
489 /*******************************************************************/
493 UNIV_INTERN
494 void
495 btr_cur_mark_dtuple_inherited_extern(
496 /*=================================*/
497  dtuple_t* entry,
499  const upd_t* update);
500 /*******************************************************************/
502 UNIV_INTERN
503 void
504 btr_cur_unmark_dtuple_extern_fields(
505 /*================================*/
506  dtuple_t* entry);
507 /*******************************************************************/
513 UNIV_INTERN
514 ulint
515 btr_store_big_rec_extern_fields(
516 /*============================*/
517  dict_index_t* index,
519  buf_block_t* rec_block,
520  rec_t* rec,
521  const ulint* offsets,
525  big_rec_t* big_rec_vec,
527  mtr_t* local_mtr);
529 /*******************************************************************/
534 UNIV_INTERN
535 void
536 btr_free_externally_stored_field(
537 /*=============================*/
538  dict_index_t* index,
546  byte* field_ref,
547  const rec_t* rec,
549  const ulint* offsets,
551  page_zip_des_t* page_zip,
553  ulint i,
555  enum trx_rb_ctx rb_ctx,
556  mtr_t* local_mtr);
559 /*******************************************************************/
564 UNIV_INTERN
565 ulint
566 btr_copy_externally_stored_field_prefix(
567 /*====================================*/
568  byte* buf,
569  ulint len,
570  ulint zip_size,
572  const byte* data,
576  ulint local_len);
577 /*******************************************************************/
580 UNIV_INTERN
581 byte*
582 btr_rec_copy_externally_stored_field(
583 /*=================================*/
584  const rec_t* rec,
586  const ulint* offsets,
587  ulint zip_size,
589  ulint no,
590  ulint* len,
591  mem_heap_t* heap);
592 /*******************************************************************/
597 UNIV_INTERN
598 ulint
599 btr_push_update_extern_fields(
600 /*==========================*/
601  dtuple_t* tuple,
602  const upd_t* update,
603  mem_heap_t* heap)
604  __attribute__((nonnull));
605 /***********************************************************/
608 UNIV_INTERN
609 void
610 btr_cur_set_deleted_flag_for_ibuf(
611 /*==============================*/
612  rec_t* rec,
613  page_zip_des_t* page_zip,
617  ibool val,
618  mtr_t* mtr);
619 /*######################################################################*/
620 
623 #define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)
624 
630  ulint nth_rec;
635  ulint n_recs;
636  ulint page_no;
637  ulint page_level;
641 };
642 
643 #define BTR_PATH_ARRAY_N_SLOTS 250
646 enum btr_cur_method {
662 };
663 
675  /*------------------------------*/
682  /*------------------------------*/
685  /* @{ */
687  ulint tree_height;
690  ulint up_match;
704  ulint up_bytes;
708  ulint low_match;
716  ulint low_bytes;
720  ulint n_fields;
722  ulint n_bytes;
724  ulint fold;
726  /*----- Delete buffering -------*/
727  ulint ibuf_cnt; /* in searches done on insert buffer
728  trees, this contains the "counter"
729  value (the first two bytes of the
730  fourth field) extracted from the
731  page above the leaf page, from the
732  father node pointer that pointed to
733  the leaf page. in other words, it
734  contains the minimum counter value
735  for records to be inserted on the
736  chosen leaf page. If for some reason
737  this can't be read, or if the search
738  ended on the leftmost leaf page in
739  the tree (in which case the father
740  node pointer had the 'minimum
741  record' flag set), this is
742  ULINT_UNDEFINED. */
743  /*------------------------------*/
744  /* @} */
749 };
750 
754 #define BTR_CUR_RETRY_DELETE_N_TIMES 100
755 
758 #define BTR_CUR_RETRY_SLEEP_TIME 50000
759 
766 /*-------------------------------------- @{ */
767 #define BTR_EXTERN_SPACE_ID 0
768 #define BTR_EXTERN_PAGE_NO 4
769 #define BTR_EXTERN_OFFSET 8
771 #define BTR_EXTERN_LEN 12
776 /*-------------------------------------- @} */
777 /* #define BTR_EXTERN_FIELD_REF_SIZE 20 // moved to btr0types.h */
778 
783 #define BTR_EXTERN_OWNER_FLAG 128
784 
789 #define BTR_EXTERN_INHERITED_FLAG 64
790 
792 extern ulint btr_cur_n_non_sea;
795 extern ulint btr_cur_n_sea;
799 extern ulint btr_cur_n_non_sea_old;
803 extern ulint btr_cur_n_sea_old;
804 #endif /* !UNIV_HOTBACKUP */
805 
806 #ifndef UNIV_NONINL
807 #include "btr0cur.ic"
808 #endif
809 
810 #endif