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
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
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
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
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
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
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
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
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
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
335 /*===========================*/
336  ulint flags,
337  buf_block_t* block,
338  rec_t* rec,
339  dict_index_t* index,
340  const ulint* offsets,
341  ibool val,
342  que_thr_t* thr,
343  mtr_t* mtr)
344  __attribute__((nonnull));
345 /***********************************************************/
348 UNIV_INTERN
349 ulint
351 /*=========================*/
352  ulint flags,
353  btr_cur_t* cursor,
354  ibool val,
355  que_thr_t* thr,
356  mtr_t* mtr);
357 /*************************************************************/
364 UNIV_INTERN
365 ibool
367 /*=======================*/
368  btr_cur_t* cursor,
371  mtr_t* mtr);
372 /*******************************************************/
377 UNIV_INTERN
378 ibool
380 /*======================*/
381  btr_cur_t* cursor,
385  mtr_t* mtr);
389 /*************************************************************/
397 UNIV_INTERN
398 ibool
400 /*=======================*/
401  ulint* err,
406  ibool has_reserved_extents,
410  btr_cur_t* cursor,
414  enum trx_rb_ctx rb_ctx,
415  mtr_t* mtr);
416 #endif /* !UNIV_HOTBACKUP */
417 /***********************************************************/
420 UNIV_INTERN
421 byte*
423 /*==========================*/
424  byte* ptr,
425  byte* end_ptr,
426  page_t* page,
427  page_zip_des_t* page_zip,
428  dict_index_t* index);
429 /****************************************************************/
433 UNIV_INTERN
434 byte*
436 /*=================================*/
437  byte* ptr,
438  byte* end_ptr,
439  page_t* page,
440  page_zip_des_t* page_zip,
441  dict_index_t* index);
442 /****************************************************************/
446 UNIV_INTERN
447 byte*
449 /*===============================*/
450  byte* ptr,
451  byte* end_ptr,
452  page_t* page,
453  page_zip_des_t* page_zip);
454 #ifndef UNIV_HOTBACKUP
455 /*******************************************************************/
458 UNIV_INTERN
459 ib_int64_t
461 /*=========================*/
462  dict_index_t* index,
463  const dtuple_t* tuple1,
464  ulint mode1,
465  const dtuple_t* tuple2,
466  ulint mode2);
467 /*******************************************************************/
474 UNIV_INTERN
475 void
477 /*======================================*/
478  dict_index_t* index);
479 /*******************************************************************/
484 UNIV_INTERN
485 void
487 /*============================*/
488  page_zip_des_t* page_zip,
490  rec_t* rec,
491  dict_index_t* index,
492  const ulint* offsets,
493  const upd_t* update,
494  mtr_t* mtr)
495  __attribute__((nonnull(2,3,4,5,6)));
496 /*******************************************************************/
502 UNIV_INTERN
503 ulint
505 /*=================================*/
506  dict_index_t* index,
508  buf_block_t* rec_block,
509  rec_t* rec,
510  const ulint* offsets,
514 #ifdef UNIV_DEBUG
515  mtr_t* local_mtr,
517 #endif /* UNIV_DEBUG */
518 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
519  ibool update_in_place,
521 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
522  const big_rec_t*big_rec_vec)
524  __attribute__((nonnull));
525 
539 #ifdef UNIV_DEBUG
540 # define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
541  btr_store_big_rec_extern_fields_func(index,b,rec,offsets,mtr,upd,big)
542 #elif defined UNIV_BLOB_LIGHT_DEBUG
543 # define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
544  btr_store_big_rec_extern_fields_func(index,b,rec,offsets,upd,big)
545 #else
546 # define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
547  btr_store_big_rec_extern_fields_func(index,b,rec,offsets,big)
548 #endif
549 
550 /*******************************************************************/
555 UNIV_INTERN
556 void
558 /*=============================*/
559  dict_index_t* index,
567  byte* field_ref,
568  const rec_t* rec,
570  const ulint* offsets,
572  page_zip_des_t* page_zip,
574  ulint i,
576  enum trx_rb_ctx rb_ctx,
577  mtr_t* local_mtr);
580 /*******************************************************************/
585 UNIV_INTERN
586 ulint
588 /*====================================*/
589  byte* buf,
590  ulint len,
591  ulint zip_size,
593  const byte* data,
597  ulint local_len);
598 /*******************************************************************/
601 UNIV_INTERN
602 byte*
604 /*=================================*/
605  const rec_t* rec,
607  const ulint* offsets,
608  ulint zip_size,
610  ulint no,
611  ulint* len,
612  mem_heap_t* heap);
613 /*******************************************************************/
618 UNIV_INTERN
619 ulint
621 /*==========================*/
622  dtuple_t* tuple,
623  const upd_t* update,
624  mem_heap_t* heap)
625  __attribute__((nonnull));
626 /***********************************************************/
629 UNIV_INTERN
630 void
632 /*==============================*/
633  rec_t* rec,
634  page_zip_des_t* page_zip,
638  ibool val,
639  mtr_t* mtr);
640 /*######################################################################*/
641 
644 #define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)
645 
651  ulint nth_rec;
656  ulint n_recs;
657  ulint page_no;
658  ulint page_level;
662 };
663 
664 #define BTR_PATH_ARRAY_N_SLOTS 250
667 enum btr_cur_method {
683 };
684 
696  /*------------------------------*/
703  /*------------------------------*/
706  /* @{ */
708  ulint tree_height;
711  ulint up_match;
725  ulint up_bytes;
729  ulint low_match;
737  ulint low_bytes;
741  ulint n_fields;
743  ulint n_bytes;
745  ulint fold;
747  /*----- Delete buffering -------*/
748  ulint ibuf_cnt; /* in searches done on insert buffer
749  trees, this contains the "counter"
750  value (the first two bytes of the
751  fourth field) extracted from the
752  page above the leaf page, from the
753  father node pointer that pointed to
754  the leaf page. in other words, it
755  contains the minimum counter value
756  for records to be inserted on the
757  chosen leaf page. If for some reason
758  this can't be read, or if the search
759  ended on the leftmost leaf page in
760  the tree (in which case the father
761  node pointer had the 'minimum
762  record' flag set), this is
763  ULINT_UNDEFINED. */
764  /*------------------------------*/
765  /* @} */
770 };
771 
775 #define BTR_CUR_RETRY_DELETE_N_TIMES 100
776 
779 #define BTR_CUR_RETRY_SLEEP_TIME 50000
780 
787 /*-------------------------------------- @{ */
788 #define BTR_EXTERN_SPACE_ID 0
789 #define BTR_EXTERN_PAGE_NO 4
790 #define BTR_EXTERN_OFFSET 8
792 #define BTR_EXTERN_LEN 12
797 /*-------------------------------------- @} */
798 /* #define BTR_EXTERN_FIELD_REF_SIZE 20 // moved to btr0types.h */
799 
804 #define BTR_EXTERN_OWNER_FLAG 128
805 
810 #define BTR_EXTERN_INHERITED_FLAG 64
811 
813 extern ulint btr_cur_n_non_sea;
816 extern ulint btr_cur_n_sea;
820 extern ulint btr_cur_n_non_sea_old;
824 extern ulint btr_cur_n_sea_old;
825 #endif /* !UNIV_HOTBACKUP */
826 
827 #ifndef UNIV_NONINL
828 #include "btr0cur.ic"
829 #endif
830 
831 #endif
UNIV_INTERN void btr_estimate_number_of_different_key_vals(dict_index_t *index)
Definition: btr0cur.cc:3547
ulint nth_rec
Definition: btr0cur.h:651
ulint btr_cur_n_non_sea_old
Definition: btr0cur.cc:94
UNIV_INTERN byte * btr_rec_copy_externally_stored_field(const rec_t *rec, const ulint *offsets, ulint zip_size, ulint no, ulint *len, mem_heap_t *heap)
Definition: btr0cur.cc:5207
ulint fold
Definition: btr0cur.h:745
ulint n_bytes
Definition: btr0cur.h:743
UNIV_INTERN byte * btr_cur_parse_update_in_place(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index)
Definition: btr0cur.cc:1684
ulint btr_cur_n_sea
Definition: btr0cur.cc:90
UNIV_INTERN ibool btr_cur_optimistic_delete(btr_cur_t *cursor, mtr_t *mtr)
Definition: btr0cur.cc:2906
ulint tree_height
Definition: btr0cur.h:708
que_thr_t * thr
Definition: btr0cur.h:697
purge_node_t * purge_node
Definition: btr0cur.h:690
UNIV_INTERN void btr_cur_search_to_nth_level(dict_index_t *index, ulint level, const dtuple_t *tuple, ulint mode, ulint latch_mode, btr_cur_t *cursor, ulint has_search_latch, const char *file, ulint line, mtr_t *mtr)
Definition: btr0cur.cc:346
UNIV_INTERN ibool btr_cur_update_alloc_zip(page_zip_des_t *page_zip, buf_block_t *block, dict_index_t *index, ulint length, ibool create, mtr_t *mtr) UNIV_WARN_UNUSED_RESULT_NONNULL
Definition: btr0cur.cc:1764
trx_rb_ctx
Definition: trx0types.h:68
UNIV_INTERN ulint btr_copy_externally_stored_field_prefix(byte *buf, ulint len, ulint zip_size, const byte *data, ulint local_len)
Definition: btr0cur.cc:5098
ulint n_fields
Definition: btr0cur.h:741
ulint up_match
Definition: btr0cur.h:711
buf_block_t * left_block
Definition: btr0cur.h:691
UNIV_INTERN ulint btr_cur_optimistic_update(ulint flags, btr_cur_t *cursor, const upd_t *update, ulint cmpl_info, que_thr_t *thr, mtr_t *mtr)
Definition: btr0cur.cc:1952
UNIV_INTERN ulint btr_cur_pessimistic_insert(ulint flags, btr_cur_t *cursor, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, ulint n_ext, que_thr_t *thr, mtr_t *mtr)
Definition: btr0cur.cc:1429
UNIV_INTERN void btr_cur_open_at_rnd_pos_func(dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr)
Definition: btr0cur.cc:949
UNIV_INTERN void UNIV_INTERN ulint btr_store_big_rec_extern_fields_func(dict_index_t *index, buf_block_t *rec_block, rec_t *rec, const ulint *offsets, const big_rec_t *big_rec_vec) __attribute__((nonnull))
Definition: btr0cur.cc:4106
btr_path_t * path_arr
Definition: btr0cur.h:766
enum btr_cur_method flag
Definition: btr0cur.h:707
ulint up_bytes
Definition: btr0cur.h:725
UNIV_INLINE page_t * btr_cur_get_page(btr_cur_t *cursor)
btr_cur_method
Definition: btr0cur.h:667
ulint low_bytes
Definition: btr0cur.h:737
UNIV_INTERN ulint btr_cur_optimistic_insert(ulint flags, btr_cur_t *cursor, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, ulint n_ext, que_thr_t *thr, mtr_t *mtr)
Definition: btr0cur.cc:1167
page_cur_t page_cur
Definition: btr0cur.h:689
UNIV_INTERN ib_int64_t btr_estimate_n_rows_in_range(dict_index_t *index, const dtuple_t *tuple1, ulint mode1, const dtuple_t *tuple2, ulint mode2)
Definition: btr0cur.cc:3342
UNIV_INTERN ibool btr_cur_compress_if_useful(btr_cur_t *cursor, mtr_t *mtr)
Definition: btr0cur.cc:2882
UNIV_INTERN void btr_cur_open_at_index_side_func(ibool from_left, dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr)
Definition: btr0cur.cc:817
UNIV_INTERN void btr_cur_set_deleted_flag_for_ibuf(rec_t *rec, page_zip_des_t *page_zip, ibool val, mtr_t *mtr)
Definition: btr0cur.cc:2853
UNIV_INTERN void btr_cur_disown_inherited_fields(page_zip_des_t *page_zip, rec_t *rec, dict_index_t *index, const ulint *offsets, const upd_t *update, mtr_t *mtr) __attribute__((nonnull(2
UNIV_INTERN ulint btr_cur_del_mark_set_clust_rec(ulint flags, buf_block_t *block, rec_t *rec, dict_index_t *index, const ulint *offsets, ibool val, que_thr_t *thr, mtr_t *mtr) __attribute__((nonnull))
Definition: btr0cur.cc:2642
UNIV_INLINE rec_t * btr_cur_get_rec(btr_cur_t *cursor)
UNIV_INTERN void btr_free_externally_stored_field(dict_index_t *index, byte *field_ref, const rec_t *rec, const ulint *offsets, page_zip_des_t *page_zip, ulint i, enum trx_rb_ctx rb_ctx, mtr_t *local_mtr)
Definition: btr0cur.cc:4564
UNIV_INTERN ulint btr_cur_del_mark_set_sec_rec(ulint flags, btr_cur_t *cursor, ibool val, que_thr_t *thr, mtr_t *mtr)
Definition: btr0cur.cc:2799
UNIV_INTERN byte * btr_cur_parse_del_mark_set_sec_rec(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip)
Definition: btr0cur.cc:2756
UNIV_INLINE dict_index_t * btr_cur_get_index(btr_cur_t *cursor)
UNIV_INTERN ibool btr_cur_pessimistic_delete(ulint *err, ibool has_reserved_extents, btr_cur_t *cursor, enum trx_rb_ctx rb_ctx, mtr_t *mtr)
Definition: btr0cur.cc:2995
UNIV_INLINE void btr_cur_invalidate(btr_cur_t *cursor)
ulint n_recs
Definition: btr0cur.h:656
UNIV_INTERN ulint btr_push_update_extern_fields(dtuple_t *tuple, const upd_t *update, mem_heap_t *heap) __attribute__((nonnull))
Definition: btr0cur.cc:3958
ulint btr_cur_n_sea_old
Definition: btr0cur.cc:98
dict_index_t * index
Definition: btr0cur.h:688
UNIV_INLINE void btr_cur_position(dict_index_t *index, rec_t *rec, buf_block_t *block, btr_cur_t *cursor)
UNIV_INTERN ulint btr_cur_update_in_place(ulint flags, btr_cur_t *cursor, const upd_t *update, ulint cmpl_info, que_thr_t *thr, mtr_t *mtr)
Definition: btr0cur.cc:1824
UNIV_INLINE buf_block_t * btr_cur_get_block(btr_cur_t *cursor)
UNIV_INLINE page_zip_des_t * btr_cur_get_page_zip(btr_cur_t *cursor)
byte page_t
Definition: page0types.h:37
UNIV_INTERN byte * btr_cur_parse_del_mark_set_clust_rec(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index)
Definition: btr0cur.cc:2559
ulint page_no
Definition: btr0cur.h:657
ulint page_level
Definition: btr0cur.h:658
ulint btr_cur_n_non_sea
Definition: btr0cur.cc:87
ulint low_match
Definition: btr0cur.h:729
UNIV_INTERN ulint btr_cur_pessimistic_update(ulint flags, btr_cur_t *cursor, mem_heap_t **heap, big_rec_t **big_rec, const upd_t *update, ulint cmpl_info, que_thr_t *thr, mtr_t *mtr)
Definition: btr0cur.cc:2205