Drizzled Public API Documentation

btr0cur.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #pragma once
00027 #ifndef btr0cur_h
00028 #define btr0cur_h
00029 
00030 #include "univ.i"
00031 #include "dict0dict.h"
00032 #include "page0cur.h"
00033 #include "btr0types.h"
00034 
00035 /* Mode flags for btr_cur operations; these can be ORed */
00036 #define BTR_NO_UNDO_LOG_FLAG  1 /* do no undo logging */
00037 #define BTR_NO_LOCKING_FLAG 2 /* do no record lock checking */
00038 #define BTR_KEEP_SYS_FLAG 4 /* sys fields will be found from the
00039           update vector or inserted entry */
00040 
00041 #ifndef UNIV_HOTBACKUP
00042 #include "que0types.h"
00043 #include "row0types.h"
00044 #include "ha0ha.h"
00045 
00046 #define BTR_CUR_ADAPT
00047 #define BTR_CUR_HASH_ADAPT
00048 
00049 #ifdef UNIV_DEBUG
00050 /*********************************************************/
00053 UNIV_INLINE
00054 page_cur_t*
00055 btr_cur_get_page_cur(
00056 /*=================*/
00057   const btr_cur_t*  cursor);
00058 #else /* UNIV_DEBUG */
00059 # define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
00060 #endif /* UNIV_DEBUG */
00061 /*********************************************************/
00064 UNIV_INLINE
00065 buf_block_t*
00066 btr_cur_get_block(
00067 /*==============*/
00068   btr_cur_t*  cursor);
00069 /*********************************************************/
00072 UNIV_INLINE
00073 rec_t*
00074 btr_cur_get_rec(
00075 /*============*/
00076   btr_cur_t*  cursor);
00077 /*********************************************************/
00080 UNIV_INLINE
00081 page_zip_des_t*
00082 btr_cur_get_page_zip(
00083 /*=================*/
00084   btr_cur_t*  cursor);
00085 /*********************************************************/
00087 UNIV_INLINE
00088 void
00089 btr_cur_invalidate(
00090 /*===============*/
00091   btr_cur_t*  cursor);
00092 /*********************************************************/
00095 UNIV_INLINE
00096 page_t*
00097 btr_cur_get_page(
00098 /*=============*/
00099   btr_cur_t*  cursor);
00100 /*********************************************************/
00103 UNIV_INLINE
00104 dict_index_t*
00105 btr_cur_get_index(
00106 /*==============*/
00107   btr_cur_t*  cursor);
00108 /*********************************************************/
00110 UNIV_INLINE
00111 void
00112 btr_cur_position(
00113 /*=============*/
00114   dict_index_t* index,  
00115   rec_t*    rec,  
00116   buf_block_t*  block,  
00117   btr_cur_t*  cursor);
00118 /********************************************************************/
00125 UNIV_INTERN
00126 void
00127 btr_cur_search_to_nth_level(
00128 /*========================*/
00129   dict_index_t* index,  
00130   ulint   level,  
00131   const dtuple_t* tuple,  
00134   ulint   mode, 
00141   ulint   latch_mode, 
00152   btr_cur_t*  cursor, 
00154   ulint   has_search_latch,
00157   const char* file, 
00158   ulint   line, 
00159   mtr_t*    mtr); 
00160 /*****************************************************************/
00162 UNIV_INTERN
00163 void
00164 btr_cur_open_at_index_side_func(
00165 /*============================*/
00166   ibool   from_left,  
00168   dict_index_t* index,    
00169   ulint   latch_mode, 
00170   btr_cur_t*  cursor,   
00171   const char* file,   
00172   ulint   line,   
00173   mtr_t*    mtr);   
00174 #define btr_cur_open_at_index_side(f,i,l,c,m)       \
00175   btr_cur_open_at_index_side_func(f,i,l,c,__FILE__,__LINE__,m)
00176 /**********************************************************************/
00178 UNIV_INTERN
00179 void
00180 btr_cur_open_at_rnd_pos_func(
00181 /*=========================*/
00182   dict_index_t* index,    
00183   ulint   latch_mode, 
00184   btr_cur_t*  cursor,   
00185   const char* file,   
00186   ulint   line,   
00187   mtr_t*    mtr);   
00188 #define btr_cur_open_at_rnd_pos(i,l,c,m)        \
00189   btr_cur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m)
00190 /*************************************************************/
00197 UNIV_INTERN
00198 ulint
00199 btr_cur_optimistic_insert(
00200 /*======================*/
00201   ulint   flags,  
00204   btr_cur_t*  cursor, 
00206   dtuple_t* entry,  
00207   rec_t**   rec,  
00209   big_rec_t** big_rec,
00212   ulint   n_ext,  
00213   que_thr_t*  thr,  
00214   mtr_t*    mtr); 
00219 /*************************************************************/
00225 UNIV_INTERN
00226 ulint
00227 btr_cur_pessimistic_insert(
00228 /*=======================*/
00229   ulint   flags,  
00235   btr_cur_t*  cursor, 
00237   dtuple_t* entry,  
00238   rec_t**   rec,  
00240   big_rec_t** big_rec,
00243   ulint   n_ext,  
00244   que_thr_t*  thr,  
00245   mtr_t*    mtr); 
00246 /*************************************************************/
00250 UNIV_INTERN
00251 ibool
00252 btr_cur_update_alloc_zip(
00253 /*=====================*/
00254   page_zip_des_t* page_zip,
00255   buf_block_t*  block,  
00256   dict_index_t* index,  
00257   ulint   length, 
00258   ibool   create, 
00260   mtr_t*    mtr)  
00261   UNIV_WARN_UNUSED_RESULT_NONNULL;
00262 /*************************************************************/
00265 UNIV_INTERN
00266 ulint
00267 btr_cur_update_in_place(
00268 /*====================*/
00269   ulint   flags,  
00270   btr_cur_t*  cursor, 
00273   const upd_t*  update, 
00274   ulint   cmpl_info,
00276   que_thr_t*  thr,  
00277   mtr_t*    mtr); 
00279 /*************************************************************/
00287 UNIV_INTERN
00288 ulint
00289 btr_cur_optimistic_update(
00290 /*======================*/
00291   ulint   flags,  
00292   btr_cur_t*  cursor, 
00295   const upd_t*  update, 
00297   ulint   cmpl_info,
00299   que_thr_t*  thr,  
00300   mtr_t*    mtr); 
00302 /*************************************************************/
00308 UNIV_INTERN
00309 ulint
00310 btr_cur_pessimistic_update(
00311 /*=======================*/
00312   ulint   flags,  
00314   btr_cur_t*  cursor, 
00315   mem_heap_t**  heap, 
00316   big_rec_t** big_rec,
00318   const upd_t*  update, 
00321   ulint   cmpl_info,
00323   que_thr_t*  thr,  
00324   mtr_t*    mtr); 
00326 /***********************************************************/
00332 UNIV_INTERN
00333 ulint
00334 btr_cur_del_mark_set_clust_rec(
00335 /*===========================*/
00336   ulint   flags,  
00337   btr_cur_t*  cursor, 
00338   ibool   val,  
00339   que_thr_t*  thr,  
00340   mtr_t*    mtr); 
00341 /***********************************************************/
00344 UNIV_INTERN
00345 ulint
00346 btr_cur_del_mark_set_sec_rec(
00347 /*=========================*/
00348   ulint   flags,  
00349   btr_cur_t*  cursor, 
00350   ibool   val,  
00351   que_thr_t*  thr,  
00352   mtr_t*    mtr); 
00353 /*************************************************************/
00360 UNIV_INTERN
00361 ibool
00362 btr_cur_compress_if_useful(
00363 /*=======================*/
00364   btr_cur_t*  cursor, 
00367   mtr_t*    mtr); 
00368 /*******************************************************/
00373 UNIV_INTERN
00374 ibool
00375 btr_cur_optimistic_delete(
00376 /*======================*/
00377   btr_cur_t*  cursor, 
00381   mtr_t*    mtr); 
00385 /*************************************************************/
00393 UNIV_INTERN
00394 ibool
00395 btr_cur_pessimistic_delete(
00396 /*=======================*/
00397   ulint*    err,  
00402   ibool   has_reserved_extents, 
00406   btr_cur_t*  cursor, 
00410   enum trx_rb_ctx rb_ctx, 
00411   mtr_t*    mtr); 
00412 #endif /* !UNIV_HOTBACKUP */
00413 /***********************************************************/
00416 UNIV_INTERN
00417 byte*
00418 btr_cur_parse_update_in_place(
00419 /*==========================*/
00420   byte*   ptr,  
00421   byte*   end_ptr,
00422   page_t*   page, 
00423   page_zip_des_t* page_zip,
00424   dict_index_t* index); 
00425 /****************************************************************/
00429 UNIV_INTERN
00430 byte*
00431 btr_cur_parse_del_mark_set_clust_rec(
00432 /*=================================*/
00433   byte*   ptr,  
00434   byte*   end_ptr,
00435   page_t*   page, 
00436   page_zip_des_t* page_zip,
00437   dict_index_t* index); 
00438 /****************************************************************/
00442 UNIV_INTERN
00443 byte*
00444 btr_cur_parse_del_mark_set_sec_rec(
00445 /*===============================*/
00446   byte*   ptr,  
00447   byte*   end_ptr,
00448   page_t*   page, 
00449   page_zip_des_t* page_zip);
00450 #ifndef UNIV_HOTBACKUP
00451 /*******************************************************************/
00454 UNIV_INTERN
00455 ib_int64_t
00456 btr_estimate_n_rows_in_range(
00457 /*=========================*/
00458   dict_index_t* index,  
00459   const dtuple_t* tuple1, 
00460   ulint   mode1,  
00461   const dtuple_t* tuple2, 
00462   ulint   mode2); 
00463 /*******************************************************************/
00467 UNIV_INTERN
00468 void
00469 btr_estimate_number_of_different_key_vals(
00470 /*======================================*/
00471   dict_index_t* index); 
00472 /*******************************************************************/
00478 UNIV_INTERN
00479 ibool
00480 btr_cur_mark_extern_inherited_fields(
00481 /*=================================*/
00482   page_zip_des_t* page_zip,
00484   rec_t*    rec,  
00485   dict_index_t* index,  
00486   const ulint*  offsets,
00487   const upd_t*  update, 
00488   mtr_t*    mtr); 
00489 /*******************************************************************/
00493 UNIV_INTERN
00494 void
00495 btr_cur_mark_dtuple_inherited_extern(
00496 /*=================================*/
00497   dtuple_t* entry,    
00499   const upd_t*  update);  
00500 /*******************************************************************/
00502 UNIV_INTERN
00503 void
00504 btr_cur_unmark_dtuple_extern_fields(
00505 /*================================*/
00506   dtuple_t* entry);   
00507 /*******************************************************************/
00513 UNIV_INTERN
00514 ulint
00515 btr_store_big_rec_extern_fields(
00516 /*============================*/
00517   dict_index_t* index,    
00519   buf_block_t*  rec_block,  
00520   rec_t*    rec,    
00521   const ulint*  offsets,  
00525   big_rec_t*  big_rec_vec,  
00527   mtr_t*    local_mtr); 
00529 /*******************************************************************/
00534 UNIV_INTERN
00535 void
00536 btr_free_externally_stored_field(
00537 /*=============================*/
00538   dict_index_t* index,    
00546   byte*   field_ref,  
00547   const rec_t*  rec,    
00549   const ulint*  offsets,  
00551   page_zip_des_t* page_zip, 
00553   ulint   i,    
00555   enum trx_rb_ctx rb_ctx,   
00556   mtr_t*    local_mtr); 
00559 /*******************************************************************/
00564 UNIV_INTERN
00565 ulint
00566 btr_copy_externally_stored_field_prefix(
00567 /*====================================*/
00568   byte*   buf,  
00569   ulint   len,  
00570   ulint   zip_size,
00572   const byte* data, 
00576   ulint   local_len);
00577 /*******************************************************************/
00580 UNIV_INTERN
00581 byte*
00582 btr_rec_copy_externally_stored_field(
00583 /*=================================*/
00584   const rec_t*  rec,  
00586   const ulint*  offsets,
00587   ulint   zip_size,
00589   ulint   no, 
00590   ulint*    len,  
00591   mem_heap_t* heap);  
00592 /*******************************************************************/
00597 UNIV_INTERN
00598 ulint
00599 btr_push_update_extern_fields(
00600 /*==========================*/
00601   dtuple_t* tuple,  
00602   const upd_t*  update, 
00603   mem_heap_t* heap) 
00604   __attribute__((nonnull));
00605 /***********************************************************/
00608 UNIV_INTERN
00609 void
00610 btr_cur_set_deleted_flag_for_ibuf(
00611 /*==============================*/
00612   rec_t*    rec,    
00613   page_zip_des_t* page_zip, 
00617   ibool   val,    
00618   mtr_t*    mtr);   
00619 /*######################################################################*/
00620 
00623 #define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)
00624 
00628 typedef struct btr_path_struct  btr_path_t;
00629 struct btr_path_struct{
00630   ulint nth_rec;  
00635   ulint n_recs;   
00636   ulint page_no;  
00637   ulint page_level; 
00641 };
00642 
00643 #define BTR_PATH_ARRAY_N_SLOTS  250 
00646 enum btr_cur_method {
00647   BTR_CUR_HASH = 1, 
00649   BTR_CUR_HASH_FAIL,  
00654   BTR_CUR_BINARY,   
00655   BTR_CUR_INSERT_TO_IBUF, 
00657   BTR_CUR_DEL_MARK_IBUF,  
00659   BTR_CUR_DELETE_IBUF,  
00661   BTR_CUR_DELETE_REF  
00662 };
00663 
00666 struct btr_cur_struct {
00667   dict_index_t* index;    
00668   page_cur_t  page_cur; 
00669   purge_node_t* purge_node; 
00670   buf_block_t*  left_block; 
00675   /*------------------------------*/
00676   que_thr_t*  thr;    
00682   /*------------------------------*/
00685   /* @{ */
00686   enum btr_cur_method flag; 
00687   ulint   tree_height;  
00690   ulint   up_match; 
00704   ulint   up_bytes; 
00708   ulint   low_match;  
00716   ulint   low_bytes;  
00720   ulint   n_fields; 
00722   ulint   n_bytes;  
00724   ulint   fold;   
00726   /*----- Delete buffering -------*/
00727   ulint   ibuf_cnt; /* in searches done on insert buffer
00728           trees, this contains the "counter"
00729           value (the first two bytes of the
00730           fourth field) extracted from the
00731           page above the leaf page, from the
00732           father node pointer that pointed to
00733           the leaf page. in other words, it
00734           contains the minimum counter value
00735           for records to be inserted on the
00736           chosen leaf page. If for some reason
00737           this can't be read, or if the search
00738           ended on the leftmost leaf page in
00739           the tree (in which case the father
00740           node pointer had the 'minimum
00741           record' flag set), this is
00742           ULINT_UNDEFINED. */
00743   /*------------------------------*/
00744   /* @} */
00745   btr_path_t* path_arr; 
00749 };
00750 
00754 #define BTR_CUR_RETRY_DELETE_N_TIMES  100
00755 
00758 #define BTR_CUR_RETRY_SLEEP_TIME  50000
00759 
00766 /*-------------------------------------- @{ */
00767 #define BTR_EXTERN_SPACE_ID   0 
00768 #define BTR_EXTERN_PAGE_NO    4 
00769 #define BTR_EXTERN_OFFSET   8 
00771 #define BTR_EXTERN_LEN      12  
00776 /*-------------------------------------- @} */
00777 /* #define BTR_EXTERN_FIELD_REF_SIZE  20 // moved to btr0types.h */
00778 
00783 #define BTR_EXTERN_OWNER_FLAG   128
00784 
00789 #define BTR_EXTERN_INHERITED_FLAG 64
00790 
00792 extern ulint  btr_cur_n_non_sea;
00795 extern ulint  btr_cur_n_sea;
00799 extern ulint  btr_cur_n_non_sea_old;
00803 extern ulint  btr_cur_n_sea_old;
00804 #endif /* !UNIV_HOTBACKUP */
00805 
00806 #ifndef UNIV_NONINL
00807 #include "btr0cur.ic"
00808 #endif
00809 
00810 #endif