MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
btr0cur.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1994, 2013, Oracle and/or its affiliates. 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.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #ifndef btr0cur_h
27 #define btr0cur_h
28 
29 #include "univ.i"
30 #include "dict0dict.h"
31 #include "page0cur.h"
32 #include "btr0types.h"
33 
35 enum {
53 };
54 
55 #ifndef UNIV_HOTBACKUP
56 #include "que0types.h"
57 #include "row0types.h"
58 #include "ha0ha.h"
59 
60 #define BTR_CUR_ADAPT
61 #define BTR_CUR_HASH_ADAPT
62 
63 #ifdef UNIV_DEBUG
64 /*********************************************************/
67 UNIV_INLINE
69 btr_cur_get_page_cur(
70 /*=================*/
71  const btr_cur_t* cursor);
72 /*********************************************************/
75 UNIV_INLINE
77 btr_cur_get_block(
78 /*==============*/
79  const btr_cur_t* cursor);
80 /*********************************************************/
83 UNIV_INLINE
84 rec_t*
85 btr_cur_get_rec(
86 /*============*/
87  const btr_cur_t* cursor);
88 #else /* UNIV_DEBUG */
89 # define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
90 # define btr_cur_get_block(cursor) ((cursor)->page_cur.block)
91 # define btr_cur_get_rec(cursor) ((cursor)->page_cur.rec)
92 #endif /* UNIV_DEBUG */
93 /*********************************************************/
96 UNIV_INLINE
99 /*=================*/
100  btr_cur_t* cursor);
101 /*********************************************************/
103 UNIV_INLINE
104 void
106 /*===============*/
107  btr_cur_t* cursor);
108 /*********************************************************/
111 UNIV_INLINE
112 page_t*
114 /*=============*/
115  btr_cur_t* cursor);
116 /*********************************************************/
120 #define btr_cur_get_index(cursor) ((cursor)->index)
121 /*********************************************************/
123 UNIV_INLINE
124 void
126 /*=============*/
128  rec_t* rec,
129  buf_block_t* block,
130  btr_cur_t* cursor);
131 /********************************************************************/
138 UNIV_INTERN
139 void
141 /*========================*/
143  ulint level,
144  const dtuple_t* tuple,
147  ulint mode,
154  ulint latch_mode,
165  btr_cur_t* cursor,
167  ulint has_search_latch,
170  const char* file,
171  ulint line,
172  mtr_t* mtr);
173 /*****************************************************************/
175 UNIV_INTERN
176 void
178 /*============================*/
179  bool from_left,
182  ulint latch_mode,
183  btr_cur_t* cursor,
184  ulint level,
186  const char* file,
187  ulint line,
188  mtr_t* mtr)
189  __attribute__((nonnull));
190 #define btr_cur_open_at_index_side(f,i,l,c,lv,m) \
191  btr_cur_open_at_index_side_func(f,i,l,c,lv,__FILE__,__LINE__,m)
192 /**********************************************************************/
194 UNIV_INTERN
195 void
197 /*=========================*/
199  ulint latch_mode,
200  btr_cur_t* cursor,
201  const char* file,
202  ulint line,
203  mtr_t* mtr);
204 #define btr_cur_open_at_rnd_pos(i,l,c,m) \
205  btr_cur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m)
206 /*************************************************************/
213 UNIV_INTERN
214 dberr_t
216 /*======================*/
217  ulint flags,
220  btr_cur_t* cursor,
222  ulint** offsets,
223  mem_heap_t** heap,
224  dtuple_t* entry,
225  rec_t** rec,
227  big_rec_t** big_rec,
230  ulint n_ext,
231  que_thr_t* thr,
232  mtr_t* mtr)
238  __attribute__((nonnull(2,3,4,5,6,7,10), warn_unused_result));
239 /*************************************************************/
245 UNIV_INTERN
246 dberr_t
248 /*=======================*/
249  ulint flags,
255  btr_cur_t* cursor,
257  ulint** offsets,
258  mem_heap_t** heap,
260  dtuple_t* entry,
261  rec_t** rec,
263  big_rec_t** big_rec,
266  ulint n_ext,
267  que_thr_t* thr,
268  mtr_t* mtr)
269  __attribute__((nonnull(2,3,4,5,6,7,10), warn_unused_result));
270 /*************************************************************/
282 UNIV_INTERN
283 bool
285 /*==========================*/
286  page_zip_des_t* page_zip,
287  page_cur_t* cursor,
289 #ifdef UNIV_DEBUG
290  ulint* offsets,
291 #endif /* UNIV_DEBUG */
292  ulint length,
293  bool create,
295  mtr_t* mtr)
296  __attribute__((nonnull, warn_unused_result));
297 #ifdef UNIV_DEBUG
298 # define btr_cur_update_alloc_zip(page_zip,cursor,index,offsets,len,cr,mtr) \
299  btr_cur_update_alloc_zip_func(page_zip,cursor,index,offsets,len,cr,mtr)
300 #else /* UNIV_DEBUG */
301 # define btr_cur_update_alloc_zip(page_zip,cursor,index,offsets,len,cr,mtr) \
302  btr_cur_update_alloc_zip_func(page_zip,cursor,index,len,cr,mtr)
303 #endif /* UNIV_DEBUG */
304 /*************************************************************/
310 UNIV_INTERN
311 dberr_t
313 /*====================*/
314  ulint flags,
315  btr_cur_t* cursor,
318  ulint* offsets,
319  const upd_t* update,
320  ulint cmpl_info,
322  que_thr_t* thr,
323  trx_id_t trx_id,
324  mtr_t* mtr)
328  __attribute__((warn_unused_result, nonnull));
329 /*************************************************************/
340 UNIV_INTERN
341 dberr_t
343 /*======================*/
344  ulint flags,
345  btr_cur_t* cursor,
348  ulint** offsets,
349  mem_heap_t** heap,
350  const upd_t* update,
352  ulint cmpl_info,
354  que_thr_t* thr,
355  trx_id_t trx_id,
356  mtr_t* mtr)
360  __attribute__((warn_unused_result, nonnull));
361 /*************************************************************/
367 UNIV_INTERN
368 dberr_t
370 /*=======================*/
371  ulint flags,
373  btr_cur_t* cursor,
376  ulint** offsets,
380  mem_heap_t* entry_heap,
383  big_rec_t** big_rec,
385  const upd_t* update,
388  ulint cmpl_info,
390  que_thr_t* thr,
391  trx_id_t trx_id,
392  mtr_t* mtr)
394  __attribute__((warn_unused_result, nonnull));
395 /***********************************************************/
401 UNIV_INTERN
402 dberr_t
404 /*===========================*/
405  buf_block_t* block,
406  rec_t* rec,
408  const ulint* offsets,
409  que_thr_t* thr,
410  mtr_t* mtr)
411  __attribute__((nonnull, warn_unused_result));
412 /***********************************************************/
415 UNIV_INTERN
416 dberr_t
418 /*=========================*/
419  ulint flags,
420  btr_cur_t* cursor,
421  ibool val,
422  que_thr_t* thr,
423  mtr_t* mtr)
424  __attribute__((nonnull, warn_unused_result));
425 /*************************************************************/
432 UNIV_INTERN
433 ibool
435 /*=======================*/
436  btr_cur_t* cursor,
439  ibool adjust,
441  mtr_t* mtr)
442  __attribute__((nonnull));
443 /*******************************************************/
448 UNIV_INTERN
449 ibool
451 /*===========================*/
452  btr_cur_t* cursor,
456 # ifdef UNIV_DEBUG
457  ulint flags,
458 # endif /* UNIV_DEBUG */
459  mtr_t* mtr)
463  __attribute__((nonnull, warn_unused_result));
464 # ifdef UNIV_DEBUG
465 # define btr_cur_optimistic_delete(cursor, flags, mtr) \
466  btr_cur_optimistic_delete_func(cursor, flags, mtr)
467 # else /* UNIV_DEBUG */
468 # define btr_cur_optimistic_delete(cursor, flags, mtr) \
469  btr_cur_optimistic_delete_func(cursor, mtr)
470 # endif /* UNIV_DEBUG */
471 /*************************************************************/
479 UNIV_INTERN
480 ibool
482 /*=======================*/
483  dberr_t* err,
488  ibool has_reserved_extents,
492  btr_cur_t* cursor,
496  ulint flags,
497  enum trx_rb_ctx rb_ctx,
498  mtr_t* mtr)
499  __attribute__((nonnull));
500 #endif /* !UNIV_HOTBACKUP */
501 /***********************************************************/
504 UNIV_INTERN
505 byte*
507 /*==========================*/
508  byte* ptr,
509  byte* end_ptr,
510  page_t* page,
511  page_zip_des_t* page_zip,
512  dict_index_t* index);
513 /****************************************************************/
517 UNIV_INTERN
518 byte*
520 /*=================================*/
521  byte* ptr,
522  byte* end_ptr,
523  page_t* page,
524  page_zip_des_t* page_zip,
525  dict_index_t* index);
526 /****************************************************************/
530 UNIV_INTERN
531 byte*
533 /*===============================*/
534  byte* ptr,
535  byte* end_ptr,
536  page_t* page,
537  page_zip_des_t* page_zip);
538 #ifndef UNIV_HOTBACKUP
539 /*******************************************************************/
542 UNIV_INTERN
543 ib_int64_t
545 /*=========================*/
547  const dtuple_t* tuple1,
548  ulint mode1,
549  const dtuple_t* tuple2,
550  ulint mode2);
551 /*******************************************************************/
560 UNIV_INTERN
561 void
563 /*======================================*/
564  dict_index_t* index);
565 /*******************************************************************/
570 UNIV_INTERN
571 void
573 /*============================*/
574  page_zip_des_t* page_zip,
576  rec_t* rec,
578  const ulint* offsets,
579  const upd_t* update,
580  mtr_t* mtr)
581  __attribute__((nonnull(2,3,4,5,6)));
582 
584 enum blob_op {
591 };
592 
593 /*******************************************************************/
596 UNIV_INLINE
597 ibool
599 /*==================*/
600  enum blob_op op)
601  __attribute__((warn_unused_result));
602 
603 /*******************************************************************/
609 UNIV_INTERN
610 dberr_t
612 /*============================*/
615  buf_block_t* rec_block,
616  rec_t* rec,
617  const ulint* offsets,
621  const big_rec_t*big_rec_vec,
623  mtr_t* btr_mtr,
625  enum blob_op op)
626  __attribute__((nonnull, warn_unused_result));
627 
628 /*******************************************************************/
633 UNIV_INTERN
634 void
636 /*=============================*/
645  byte* field_ref,
646  const rec_t* rec,
648  const ulint* offsets,
650  page_zip_des_t* page_zip,
652  ulint i,
654  enum trx_rb_ctx rb_ctx,
655  mtr_t* local_mtr);
658 /*******************************************************************/
663 UNIV_INTERN
664 ulint
666 /*====================================*/
667  byte* buf,
668  ulint len,
669  ulint zip_size,
671  const byte* data,
675  ulint local_len);
676 /*******************************************************************/
680 UNIV_INTERN
681 byte*
683 /*=============================*/
684  ulint* len,
685  const byte* data,
689  ulint zip_size,
691  ulint local_len,
692  mem_heap_t* heap);
693 /*******************************************************************/
696 UNIV_INTERN
697 byte*
699 /*=================================*/
700  const rec_t* rec,
702  const ulint* offsets,
703  ulint zip_size,
705  ulint no,
706  ulint* len,
707  mem_heap_t* heap);
708 /*******************************************************************/
713 UNIV_INTERN
714 ulint
716 /*==========================*/
717  dtuple_t* tuple,
718  const upd_t* update,
719  mem_heap_t* heap)
720  __attribute__((nonnull));
721 /***********************************************************/
724 UNIV_INTERN
725 void
727 /*==============================*/
728  rec_t* rec,
729  page_zip_des_t* page_zip,
733  ibool val,
734  mtr_t* mtr);
735 /*######################################################################*/
736 
739 #define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)
740 
744 struct btr_path_t{
745  ulint nth_rec;
750  ulint n_recs;
751  ulint page_no;
752  ulint page_level;
756 };
757 
758 #define BTR_PATH_ARRAY_N_SLOTS 250
761 enum btr_cur_method {
777 };
778 
781 struct btr_cur_t {
790  /*------------------------------*/
797  /*------------------------------*/
800  /* @{ */
802  ulint tree_height;
805  ulint up_match;
819  ulint up_bytes;
823  ulint low_match;
831  ulint low_bytes;
835  ulint n_fields;
837  ulint n_bytes;
839  ulint fold;
841  /* @} */
846 };
847 
851 #define BTR_CUR_RETRY_DELETE_N_TIMES 100
852 
855 #define BTR_CUR_RETRY_SLEEP_TIME 50000
856 
863 /*-------------------------------------- @{ */
864 #define BTR_EXTERN_SPACE_ID 0
865 #define BTR_EXTERN_PAGE_NO 4
866 #define BTR_EXTERN_OFFSET 8
868 #define BTR_EXTERN_LEN 12
873 /*-------------------------------------- @} */
874 /* #define BTR_EXTERN_FIELD_REF_SIZE 20 // moved to btr0types.h */
875 
880 #define BTR_EXTERN_OWNER_FLAG 128
881 
886 #define BTR_EXTERN_INHERITED_FLAG 64
887 
889 extern ulint btr_cur_n_non_sea;
892 extern ulint btr_cur_n_sea;
896 extern ulint btr_cur_n_non_sea_old;
900 extern ulint btr_cur_n_sea_old;
901 #endif /* !UNIV_HOTBACKUP */
902 
903 #ifdef UNIV_DEBUG
904 /* Flag to limit optimistic insert records */
905 extern uint btr_cur_limit_optimistic_insert_debug;
906 #endif /* UNIV_DEBUG */
907 
908 #ifndef UNIV_NONINL
909 #include "btr0cur.ic"
910 #endif
911 
912 #endif