Drizzled Public API Documentation

lock0lock.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1996, 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 lock0lock_h
00028 #define lock0lock_h
00029 
00030 #include "univ.i"
00031 #include "buf0types.h"
00032 #include "trx0types.h"
00033 #include "mtr0types.h"
00034 #include "rem0types.h"
00035 #include "dict0types.h"
00036 #include "que0types.h"
00037 #include "lock0types.h"
00038 #include "read0types.h"
00039 #include "hash0hash.h"
00040 #include "ut0vec.h"
00041 
00042 #ifdef UNIV_DEBUG
00043 extern ibool  lock_print_waits;
00044 #endif /* UNIV_DEBUG */
00045 /* Buffer for storing information about the most recent deadlock error */
00046 extern FILE*  lock_latest_err_file;
00047 
00048 /*********************************************************************/
00051 UNIV_INTERN
00052 ulint
00053 lock_get_size(void);
00054 /*===============*/
00055 /*********************************************************************/
00057 UNIV_INTERN
00058 void
00059 lock_sys_create(
00060 /*============*/
00061   ulint n_cells); 
00062 /*********************************************************************/
00064 UNIV_INTERN
00065 void
00066 lock_sys_close(void);
00067 /*================*/
00068 /*********************************************************************/
00072 UNIV_INLINE
00073 trx_t*
00074 lock_clust_rec_some_has_impl(
00075 /*=========================*/
00076   const rec_t*  rec,  
00077   dict_index_t* index,  
00078   const ulint*  offsets);
00079 /*********************************************************************/
00082 UNIV_INLINE
00083 ulint
00084 lock_get_min_heap_no(
00085 /*=================*/
00086   const buf_block_t*  block); 
00087 /*************************************************************/
00092 UNIV_INTERN
00093 void
00094 lock_move_reorganize_page(
00095 /*======================*/
00096   const buf_block_t*  block,  
00098   const buf_block_t*  oblock);
00100 /*************************************************************/
00103 UNIV_INTERN
00104 void
00105 lock_move_rec_list_end(
00106 /*===================*/
00107   const buf_block_t*  new_block,  
00108   const buf_block_t*  block,    
00109   const rec_t*    rec);   
00111 /*************************************************************/
00114 UNIV_INTERN
00115 void
00116 lock_move_rec_list_start(
00117 /*=====================*/
00118   const buf_block_t*  new_block,  
00119   const buf_block_t*  block,    
00120   const rec_t*    rec,    
00123   const rec_t*    old_end); 
00128 /*************************************************************/
00130 UNIV_INTERN
00131 void
00132 lock_update_split_right(
00133 /*====================*/
00134   const buf_block_t*  right_block,  
00135   const buf_block_t*  left_block);  
00136 /*************************************************************/
00138 UNIV_INTERN
00139 void
00140 lock_update_merge_right(
00141 /*====================*/
00142   const buf_block_t*  right_block,  
00144   const rec_t*    orig_succ,  
00148   const buf_block_t*  left_block);  
00151 /*************************************************************/
00158 UNIV_INTERN
00159 void
00160 lock_update_root_raise(
00161 /*===================*/
00162   const buf_block_t*  block,  
00163   const buf_block_t*  root);  
00164 /*************************************************************/
00167 UNIV_INTERN
00168 void
00169 lock_update_copy_and_discard(
00170 /*=========================*/
00171   const buf_block_t*  new_block,  
00173   const buf_block_t*  block);   
00175 /*************************************************************/
00177 UNIV_INTERN
00178 void
00179 lock_update_split_left(
00180 /*===================*/
00181   const buf_block_t*  right_block,  
00182   const buf_block_t*  left_block);  
00183 /*************************************************************/
00185 UNIV_INTERN
00186 void
00187 lock_update_merge_left(
00188 /*===================*/
00189   const buf_block_t*  left_block, 
00191   const rec_t*    orig_pred,  
00194   const buf_block_t*  right_block); 
00196 /*************************************************************/
00199 UNIV_INTERN
00200 void
00201 lock_rec_reset_and_inherit_gap_locks(
00202 /*=================================*/
00203   const buf_block_t*  heir_block, 
00205   const buf_block_t*  block,    
00209   ulint     heir_heap_no, 
00211   ulint     heap_no); 
00213 /*************************************************************/
00215 UNIV_INTERN
00216 void
00217 lock_update_discard(
00218 /*================*/
00219   const buf_block_t*  heir_block, 
00221   ulint     heir_heap_no, 
00223   const buf_block_t*  block);   
00225 /*************************************************************/
00227 UNIV_INTERN
00228 void
00229 lock_update_insert(
00230 /*===============*/
00231   const buf_block_t*  block,  
00232   const rec_t*    rec); 
00233 /*************************************************************/
00235 UNIV_INTERN
00236 void
00237 lock_update_delete(
00238 /*===============*/
00239   const buf_block_t*  block,  
00240   const rec_t*    rec); 
00241 /*********************************************************************/
00248 UNIV_INTERN
00249 void
00250 lock_rec_store_on_page_infimum(
00251 /*===========================*/
00252   const buf_block_t*  block,  
00253   const rec_t*    rec); 
00258 /*********************************************************************/
00261 UNIV_INTERN
00262 void
00263 lock_rec_restore_from_page_infimum(
00264 /*===============================*/
00265   const buf_block_t*  block,  
00266   const rec_t*    rec,  
00268   const buf_block_t*  donator);
00273 /*********************************************************************/
00276 UNIV_INTERN
00277 ibool
00278 lock_rec_expl_exist_on_page(
00279 /*========================*/
00280   ulint space,  
00281   ulint page_no);
00282 /*********************************************************************/
00289 UNIV_INTERN
00290 ulint
00291 lock_rec_insert_check_and_lock(
00292 /*===========================*/
00293   ulint   flags,  
00295   const rec_t*  rec,  
00296   buf_block_t*  block,  
00297   dict_index_t* index,  
00298   que_thr_t*  thr,  
00299   mtr_t*    mtr,  
00300   ibool*    inherit);
00304 /*********************************************************************/
00312 UNIV_INTERN
00313 ulint
00314 lock_clust_rec_modify_check_and_lock(
00315 /*=================================*/
00316   ulint     flags,  
00318   const buf_block_t*  block,  
00319   const rec_t*    rec,  
00321   dict_index_t*   index,  
00322   const ulint*    offsets,
00323   que_thr_t*    thr); 
00324 /*********************************************************************/
00328 UNIV_INTERN
00329 ulint
00330 lock_sec_rec_modify_check_and_lock(
00331 /*===============================*/
00332   ulint   flags,  
00334   buf_block_t*  block,  
00335   const rec_t*  rec,  
00340   dict_index_t* index,  
00341   que_thr_t*  thr,  
00342   mtr_t*    mtr); 
00343 /*********************************************************************/
00348 UNIV_INTERN
00349 enum db_err
00350 lock_sec_rec_read_check_and_lock(
00351 /*=============================*/
00352   ulint     flags,  
00354   const buf_block_t*  block,  
00355   const rec_t*    rec,  
00359   dict_index_t*   index,  
00360   const ulint*    offsets,
00361   enum lock_mode    mode, 
00366   ulint     gap_mode,
00368   que_thr_t*    thr); 
00369 /*********************************************************************/
00378 UNIV_INTERN
00379 enum db_err
00380 lock_clust_rec_read_check_and_lock(
00381 /*===============================*/
00382   ulint     flags,  
00384   const buf_block_t*  block,  
00385   const rec_t*    rec,  
00389   dict_index_t*   index,  
00390   const ulint*    offsets,
00391   enum lock_mode    mode, 
00396   ulint     gap_mode,
00398   que_thr_t*    thr); 
00399 /*********************************************************************/
00409 UNIV_INTERN
00410 ulint
00411 lock_clust_rec_read_check_and_lock_alt(
00412 /*===================================*/
00413   ulint     flags,  
00415   const buf_block_t*  block,  
00416   const rec_t*    rec,  
00420   dict_index_t*   index,  
00421   enum lock_mode    mode, 
00426   ulint     gap_mode,
00428   que_thr_t*    thr); 
00429 /*********************************************************************/
00433 UNIV_INTERN
00434 ibool
00435 lock_clust_rec_cons_read_sees(
00436 /*==========================*/
00437   const rec_t*  rec,  
00439   dict_index_t* index,  
00440   const ulint*  offsets,
00441   read_view_t*  view);  
00442 /*********************************************************************/
00452 UNIV_INTERN
00453 ulint
00454 lock_sec_rec_cons_read_sees(
00455 /*========================*/
00456   const rec_t*    rec,  
00459   const read_view_t*  view);  
00460 /*********************************************************************/
00464 UNIV_INTERN
00465 ulint
00466 lock_table(
00467 /*=======*/
00468   ulint   flags,  
00470   dict_table_t* table,  
00471   enum lock_mode  mode, 
00472   que_thr_t*  thr); 
00473 /*************************************************************/
00477 UNIV_INTERN
00478 void
00479 lock_rec_unlock(
00480 /*============*/
00481   trx_t*      trx,  
00483   const buf_block_t*  block,  
00484   const rec_t*    rec,  
00485   enum lock_mode    lock_mode);
00486 /*********************************************************************/
00489 UNIV_INTERN
00490 void
00491 lock_release_off_kernel(
00492 /*====================*/
00493   trx_t*  trx); 
00494 /*********************************************************************/
00497 UNIV_INTERN
00498 void
00499 lock_cancel_waiting_and_release(
00500 /*============================*/
00501   lock_t* lock);  
00503 /*********************************************************************/
00508 UNIV_INTERN
00509 void
00510 lock_remove_all_on_table(
00511 /*=====================*/
00512   dict_table_t* table,      
00514   ibool   remove_also_table_sx_locks);
00517 /*********************************************************************/
00521 UNIV_INLINE
00522 ulint
00523 lock_rec_fold(
00524 /*==========*/
00525   ulint space,  
00526   ulint page_no)
00527   __attribute__((const));
00528 /*********************************************************************/
00532 UNIV_INLINE
00533 ulint
00534 lock_rec_hash(
00535 /*==========*/
00536   ulint space,  
00537   ulint page_no);
00539 /**********************************************************************/
00544 UNIV_INTERN
00545 ulint
00546 lock_rec_find_set_bit(
00547 /*==================*/
00548   const lock_t* lock);  
00551 /*********************************************************************/
00558 UNIV_INTERN
00559 dict_table_t*
00560 lock_get_src_table(
00561 /*===============*/
00562   trx_t*    trx,  
00563   dict_table_t* dest, 
00564   enum lock_mode* mode);  
00565 /*********************************************************************/
00571 UNIV_INTERN
00572 ibool
00573 lock_is_table_exclusive(
00574 /*====================*/
00575   dict_table_t* table,  
00576   trx_t*    trx); 
00577 /*********************************************************************/
00580 UNIV_INTERN
00581 ibool
00582 lock_has_to_wait(
00583 /*=============*/
00584   const lock_t* lock1,  
00585   const lock_t* lock2); 
00589 /*********************************************************************/
00592 UNIV_INTERN
00593 ibool
00594 lock_check_trx_id_sanity(
00595 /*=====================*/
00596   trx_id_t  trx_id,   
00597   const rec_t*  rec,    
00598   dict_index_t* index,    
00599   const ulint*  offsets,  
00600   ibool   has_kernel_mutex);
00602 /*********************************************************************/
00604 UNIV_INTERN
00605 void
00606 lock_table_print(
00607 /*=============*/
00608   FILE*   file, 
00609   const lock_t* lock);  
00610 /*********************************************************************/
00612 UNIV_INTERN
00613 void
00614 lock_rec_print(
00615 /*===========*/
00616   FILE*   file, 
00617   const lock_t* lock);  
00618 /*********************************************************************/
00622 UNIV_INTERN
00623 ibool
00624 lock_print_info_summary(
00625 /*====================*/
00626   FILE* file, 
00627   ibool   nowait);
00628 /*************************************************************************
00629 Prints info of locks for each transaction. */
00630 UNIV_INTERN
00631 void
00632 lock_print_info_all_transactions(
00633 /*=============================*/
00634   FILE* file);  
00635 /*********************************************************************/
00639 UNIV_INTERN
00640 ulint
00641 lock_number_of_rows_locked(
00642 /*=======================*/
00643   const trx_t*  trx); 
00644 /*******************************************************************/
00647 UNIV_INTERN
00648 ibool
00649 lock_trx_holds_autoinc_locks(
00650 /*=========================*/
00651   const trx_t*  trx);   
00652 /*******************************************************************/
00654 UNIV_INTERN
00655 void
00656 lock_release_autoinc_locks(
00657 /*=======================*/
00658   trx_t*    trx);   
00660 /*******************************************************************/
00664 UNIV_INTERN
00665 ulint
00666 lock_get_type(
00667 /*==========*/
00668   const lock_t* lock);  
00670 /*******************************************************************/
00673 UNIV_INTERN
00674 trx_id_t
00675 lock_get_trx_id(
00676 /*============*/
00677   const lock_t* lock);  
00679 /*******************************************************************/
00683 UNIV_INTERN
00684 const char*
00685 lock_get_mode_str(
00686 /*==============*/
00687   const lock_t* lock);  
00689 /*******************************************************************/
00693 UNIV_INTERN
00694 const char*
00695 lock_get_type_str(
00696 /*==============*/
00697   const lock_t* lock);  
00699 /*******************************************************************/
00702 UNIV_INTERN
00703 table_id_t
00704 lock_get_table_id(
00705 /*==============*/
00706   const lock_t* lock);  
00708 /*******************************************************************/
00712 UNIV_INTERN
00713 const char*
00714 lock_get_table_name(
00715 /*================*/
00716   const lock_t* lock);  
00718 /*******************************************************************/
00721 UNIV_INTERN
00722 const dict_index_t*
00723 lock_rec_get_index(
00724 /*===============*/
00725   const lock_t* lock);  
00727 /*******************************************************************/
00731 UNIV_INTERN
00732 const char*
00733 lock_rec_get_index_name(
00734 /*====================*/
00735   const lock_t* lock);  
00737 /*******************************************************************/
00740 UNIV_INTERN
00741 ulint
00742 lock_rec_get_space_id(
00743 /*==================*/
00744   const lock_t* lock);  
00746 /*******************************************************************/
00749 UNIV_INTERN
00750 ulint
00751 lock_rec_get_page_no(
00752 /*=================*/
00753   const lock_t* lock);  
00756 /* @{ */
00757 #define LOCK_MODE_MASK  0xFUL 
00760 /* @{ */
00761 #define LOCK_TABLE  16  
00762 #define LOCK_REC  32  
00763 #define LOCK_TYPE_MASK  0xF0UL  
00765 #if LOCK_MODE_MASK & LOCK_TYPE_MASK
00766 # error "LOCK_MODE_MASK & LOCK_TYPE_MASK"
00767 #endif
00768 
00769 #define LOCK_WAIT 256 
00773 /* Precise modes */
00774 #define LOCK_ORDINARY 0 
00777 #define LOCK_GAP  512 
00784 #define LOCK_REC_NOT_GAP 1024 
00792 #define LOCK_INSERT_INTENTION 2048 
00800 #if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_MODE_MASK
00801 # error
00802 #endif
00803 #if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_TYPE_MASK
00804 # error
00805 #endif
00806 /* @} */
00807 
00809 typedef struct lock_op_struct lock_op_t;
00811 struct lock_op_struct{
00812   dict_table_t* table;  
00813   enum lock_mode  mode; 
00814 };
00815 
00817 struct lock_sys_struct{
00818   hash_table_t* rec_hash; 
00819 };
00820 
00822 extern lock_sys_t*  lock_sys;
00823 
00824 
00825 #ifndef UNIV_NONINL
00826 #include "lock0lock.ic"
00827 #endif
00828 
00829 #endif