drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
btr0cur.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
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/*********************************************************/
53UNIV_INLINE
55btr_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/*********************************************************/
64UNIV_INLINE
67/*==============*/
68 btr_cur_t* cursor);
69/*********************************************************/
72UNIV_INLINE
73rec_t*
75/*============*/
76 btr_cur_t* cursor);
77/*********************************************************/
80UNIV_INLINE
83/*=================*/
84 btr_cur_t* cursor);
85/*********************************************************/
87UNIV_INLINE
88void
90/*===============*/
91 btr_cur_t* cursor);
92/*********************************************************/
95UNIV_INLINE
98/*=============*/
99 btr_cur_t* cursor);
100/*********************************************************/
103UNIV_INLINE
104dict_index_t*
106/*==============*/
107 btr_cur_t* cursor);
108/*********************************************************/
110UNIV_INLINE
111void
113/*=============*/
114 dict_index_t* index,
115 rec_t* rec,
116 buf_block_t* block,
117 btr_cur_t* cursor);
118/********************************************************************/
125UNIV_INTERN
126void
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/*****************************************************************/
162UNIV_INTERN
163void
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/**********************************************************************/
178UNIV_INTERN
179void
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/*************************************************************/
197UNIV_INTERN
198ulint
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/*************************************************************/
225UNIV_INTERN
226ulint
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/*************************************************************/
250UNIV_INTERN
251ibool
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/*************************************************************/
265UNIV_INTERN
266ulint
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/*************************************************************/
287UNIV_INTERN
288ulint
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/*************************************************************/
308UNIV_INTERN
309ulint
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/***********************************************************/
332UNIV_INTERN
333ulint
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/***********************************************************/
348UNIV_INTERN
349ulint
351/*=========================*/
352 ulint flags,
353 btr_cur_t* cursor,
354 ibool val,
355 que_thr_t* thr,
356 mtr_t* mtr);
357/*************************************************************/
364UNIV_INTERN
365ibool
367/*=======================*/
368 btr_cur_t* cursor,
371 mtr_t* mtr);
372/*******************************************************/
377UNIV_INTERN
378ibool
380/*======================*/
381 btr_cur_t* cursor,
385 mtr_t* mtr);
389/*************************************************************/
397UNIV_INTERN
398ibool
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/***********************************************************/
420UNIV_INTERN
421byte*
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/****************************************************************/
433UNIV_INTERN
434byte*
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/****************************************************************/
446UNIV_INTERN
447byte*
449/*===============================*/
450 byte* ptr,
451 byte* end_ptr,
452 page_t* page,
453 page_zip_des_t* page_zip);
454#ifndef UNIV_HOTBACKUP
455/*******************************************************************/
458UNIV_INTERN
459ib_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/*******************************************************************/
474UNIV_INTERN
475void
477/*======================================*/
478 dict_index_t* index);
479/*******************************************************************/
484UNIV_INTERN
485void
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/*******************************************************************/
502UNIV_INTERN
503ulint
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/*******************************************************************/
555UNIV_INTERN
556void
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/*******************************************************************/
585UNIV_INTERN
586ulint
588/*====================================*/
589 byte* buf,
590 ulint len,
591 ulint zip_size,
593 const byte* data,
597 ulint local_len);
598/*******************************************************************/
601UNIV_INTERN
602byte*
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/*******************************************************************/
618UNIV_INTERN
619ulint
621/*==========================*/
622 dtuple_t* tuple,
623 const upd_t* update,
624 mem_heap_t* heap)
625 __attribute__((nonnull));
626/***********************************************************/
629UNIV_INTERN
630void
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};
664#define BTR_PATH_ARRAY_N_SLOTS 250
665
666/** Values for the flag documenting the used search method */
668 BTR_CUR_HASH = 1,
683};
684
686to know struct size! */
688 dict_index_t* index;
690 purge_node_t* purge_node;
696 /*------------------------------*/
697 que_thr_t* thr;
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
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
810#define BTR_EXTERN_INHERITED_FLAG 64
811
813extern ulint btr_cur_n_non_sea;
816extern ulint btr_cur_n_sea;
820extern ulint btr_cur_n_non_sea_old;
824extern 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_cur_set_deleted_flag_for_ibuf(rec_t *rec, page_zip_des_t *page_zip, ibool val, mtr_t *mtr)
Definition btr0cur.cc:2850
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:2639
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:2202
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:4103
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_INLINE rec_t * btr_cur_get_rec(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:1821
UNIV_INLINE buf_block_t * btr_cur_get_block(btr_cur_t *cursor)
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:5204
UNIV_INTERN ibool btr_cur_compress_if_useful(btr_cur_t *cursor, mtr_t *mtr)
Definition btr0cur.cc:2879
UNIV_INLINE dict_index_t * btr_cur_get_index(btr_cur_t *cursor)
UNIV_INTERN ibool btr_cur_optimistic_delete(btr_cur_t *cursor, mtr_t *mtr)
Definition btr0cur.cc:2903
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:1164
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:343
UNIV_INLINE page_zip_des_t * btr_cur_get_page_zip(btr_cur_t *cursor)
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:1426
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:2992
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:1761
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:814
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:5095
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:2556
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:2753
UNIV_INTERN void btr_estimate_number_of_different_key_vals(dict_index_t *index)
Definition btr0cur.cc:3544
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:2796
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:3339
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:946
UNIV_INLINE void btr_cur_invalidate(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:4561
btr_cur_method
Definition btr0cur.h:666
@ BTR_CUR_HASH_FAIL
Definition btr0cur.h:669
@ BTR_CUR_DELETE_REF
Definition btr0cur.h:681
@ BTR_CUR_INSERT_TO_IBUF
Definition btr0cur.h:675
@ BTR_CUR_BINARY
Definition btr0cur.h:674
@ BTR_CUR_HASH
Definition btr0cur.h:667
@ BTR_CUR_DELETE_IBUF
Definition btr0cur.h:679
@ BTR_CUR_DEL_MARK_IBUF
Definition btr0cur.h:677
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:1949
UNIV_INTERN ulint btr_push_update_extern_fields(dtuple_t *tuple, const upd_t *update, mem_heap_t *heap) __attribute__((nonnull))
Definition btr0cur.cc:3955
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:1681
struct btr_path_struct btr_path_t
Definition btr0cur.h:648
UNIV_INLINE void btr_cur_position(dict_index_t *index, rec_t *rec, buf_block_t *block, btr_cur_t *cursor)
UNIV_INLINE page_t * btr_cur_get_page(btr_cur_t *cursor)
struct btr_cur_struct btr_cur_t
Definition btr0types.h:38
struct buf_block_struct buf_block_t
Definition buf0types.h:33
struct big_rec_struct big_rec_t
Definition data0data.h:39
struct page_cur_struct page_cur_t
Definition page0types.h:39
struct page_zip_des_struct page_zip_des_t
Definition page0types.h:44
#define page_t
Definition page0types.h:35
ulint low_match
Definition btr0cur.h:728
ulint low_bytes
Definition btr0cur.h:736
page_cur_t page_cur
Definition btr0cur.h:688
ulint n_bytes
Definition btr0cur.h:742
btr_path_t * path_arr
Definition btr0cur.h:765
dict_index_t * index
Definition btr0cur.h:687
buf_block_t * left_block
Definition btr0cur.h:690
que_thr_t * thr
Definition btr0cur.h:696
purge_node_t * purge_node
Definition btr0cur.h:689
ulint up_bytes
Definition btr0cur.h:724
ulint tree_height
Definition btr0cur.h:707
ulint up_match
Definition btr0cur.h:710
ulint n_fields
Definition btr0cur.h:740
enum btr_cur_method flag
Definition btr0cur.h:706
ulint page_level
Definition btr0cur.h:657
trx_rb_ctx
Definition trx0types.h:68