InnoDB Plugin  1.0
lock0lock.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2014, 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 lock0lock_h
27 #define lock0lock_h
28 
29 #include "univ.i"
30 #include "buf0types.h"
31 #include "trx0types.h"
32 #include "mtr0types.h"
33 #include "rem0types.h"
34 #include "dict0types.h"
35 #include "que0types.h"
36 #include "lock0types.h"
37 #include "read0types.h"
38 #include "hash0hash.h"
39 #include "srv0srv.h"
40 #include "ut0vec.h"
41 
42 #ifdef UNIV_DEBUG
43 extern ibool lock_print_waits;
44 #endif /* UNIV_DEBUG */
45 
46 /*********************************************************************/
49 UNIV_INTERN
50 ulint
51 lock_get_size(void);
52 /*===============*/
53 /*********************************************************************/
55 UNIV_INTERN
56 void
58 /*============*/
59  ulint n_cells);
60 /*********************************************************************/
62 UNIV_INTERN
63 void
64 lock_sys_close(void);
65 /*================*/
66 /*********************************************************************/
69 UNIV_INLINE
70 ulint
72 /*=================*/
73  const buf_block_t* block);
74 /*************************************************************/
79 UNIV_INTERN
80 void
82 /*======================*/
83  const buf_block_t* block,
85  const buf_block_t* oblock);
87 /*************************************************************/
90 UNIV_INTERN
91 void
93 /*===================*/
94  const buf_block_t* new_block,
95  const buf_block_t* block,
96  const rec_t* rec);
98 /*************************************************************/
101 UNIV_INTERN
102 void
104 /*=====================*/
105  const buf_block_t* new_block,
106  const buf_block_t* block,
107  const rec_t* rec,
110  const rec_t* old_end);
115 /*************************************************************/
117 UNIV_INTERN
118 void
120 /*====================*/
121  const buf_block_t* right_block,
122  const buf_block_t* left_block);
123 /*************************************************************/
125 UNIV_INTERN
126 void
128 /*====================*/
129  const buf_block_t* right_block,
131  const rec_t* orig_succ,
135  const buf_block_t* left_block);
138 /*************************************************************/
145 UNIV_INTERN
146 void
148 /*===================*/
149  const buf_block_t* block,
150  const buf_block_t* root);
151 /*************************************************************/
154 UNIV_INTERN
155 void
157 /*=========================*/
158  const buf_block_t* new_block,
160  const buf_block_t* block);
162 /*************************************************************/
164 UNIV_INTERN
165 void
167 /*===================*/
168  const buf_block_t* right_block,
169  const buf_block_t* left_block);
170 /*************************************************************/
172 UNIV_INTERN
173 void
175 /*===================*/
176  const buf_block_t* left_block,
178  const rec_t* orig_pred,
181  const buf_block_t* right_block);
183 /*************************************************************/
186 UNIV_INTERN
187 void
189 /*=================================*/
190  const buf_block_t* heir_block,
192  const buf_block_t* block,
196  ulint heir_heap_no,
198  ulint heap_no);
200 /*************************************************************/
202 UNIV_INTERN
203 void
205 /*================*/
206  const buf_block_t* heir_block,
208  ulint heir_heap_no,
210  const buf_block_t* block);
212 /*************************************************************/
214 UNIV_INTERN
215 void
217 /*===============*/
218  const buf_block_t* block,
219  const rec_t* rec);
220 /*************************************************************/
222 UNIV_INTERN
223 void
225 /*===============*/
226  const buf_block_t* block,
227  const rec_t* rec);
228 /*********************************************************************/
235 UNIV_INTERN
236 void
238 /*===========================*/
239  const buf_block_t* block,
240  const rec_t* rec);
245 /*********************************************************************/
248 UNIV_INTERN
249 void
251 /*===============================*/
252  const buf_block_t* block,
253  const rec_t* rec,
255  const buf_block_t* donator);
260 /*********************************************************************/
263 UNIV_INTERN
264 lock_t*
266 /*========================*/
267  ulint space,
268  ulint page_no)
269  __attribute__((warn_unused_result));
270 /*********************************************************************/
277 UNIV_INTERN
278 dberr_t
280 /*===========================*/
281  ulint flags,
283  const rec_t* rec,
284  buf_block_t* block,
285  dict_index_t* index,
286  que_thr_t* thr,
287  mtr_t* mtr,
288  ibool* inherit)
292  __attribute__((nonnull, warn_unused_result));
293 /*********************************************************************/
301 UNIV_INTERN
302 dberr_t
304 /*=================================*/
305  ulint flags,
307  const buf_block_t* block,
308  const rec_t* rec,
310  dict_index_t* index,
311  const ulint* offsets,
312  que_thr_t* thr)
313  __attribute__((warn_unused_result, nonnull));
314 /*********************************************************************/
318 UNIV_INTERN
319 dberr_t
321 /*===============================*/
322  ulint flags,
324  buf_block_t* block,
325  const rec_t* rec,
330  dict_index_t* index,
331  que_thr_t* thr,
333  mtr_t* mtr)
334  __attribute__((warn_unused_result, nonnull(2,3,4,6)));
335 /*********************************************************************/
340 UNIV_INTERN
341 dberr_t
343 /*=============================*/
344  ulint flags,
346  const buf_block_t* block,
347  const rec_t* rec,
351  dict_index_t* index,
352  const ulint* offsets,
353  enum lock_mode mode,
358  ulint gap_mode,
360  que_thr_t* thr);
361 /*********************************************************************/
370 UNIV_INTERN
371 dberr_t
373 /*===============================*/
374  ulint flags,
376  const buf_block_t* block,
377  const rec_t* rec,
381  dict_index_t* index,
382  const ulint* offsets,
383  enum lock_mode mode,
388  ulint gap_mode,
390  que_thr_t* thr);
391 /*********************************************************************/
401 UNIV_INTERN
402 dberr_t
404 /*===================================*/
405  ulint flags,
407  const buf_block_t* block,
408  const rec_t* rec,
412  dict_index_t* index,
413  enum lock_mode mode,
418  ulint gap_mode,
420  que_thr_t* thr)
421  __attribute__((nonnull, warn_unused_result));
422 /*********************************************************************/
426 UNIV_INTERN
427 bool
429 /*==========================*/
430  const rec_t* rec,
432  dict_index_t* index,
433  const ulint* offsets,
434  read_view_t* view);
435 /*********************************************************************/
445 UNIV_INTERN
446 bool
448 /*========================*/
449  const rec_t* rec,
452  const read_view_t* view)
453  __attribute__((nonnull, warn_unused_result));
454 /*********************************************************************/
458 UNIV_INTERN
459 dberr_t
460 lock_table(
461 /*=======*/
462  ulint flags,
464  dict_table_t* table,
466  enum lock_mode mode,
467  que_thr_t* thr)
468  __attribute__((nonnull, warn_unused_result));
469 /*********************************************************************/
471 UNIV_INTERN
472 void
474 /*====================*/
475  dict_table_t* table,
476  trx_t* trx);
477 /*************************************************************/
481 UNIV_INTERN
482 void
484 /*============*/
485  trx_t* trx,
487  const buf_block_t* block,
488  const rec_t* rec,
489  enum lock_mode lock_mode);
490 /*********************************************************************/
494 UNIV_INTERN
495 void
497 /*===================*/
498  trx_t* trx);
499 /*********************************************************************/
504 UNIV_INTERN
505 void
507 /*=====================*/
508  dict_table_t* table,
510  ibool remove_also_table_sx_locks);
513 /*********************************************************************/
517 UNIV_INLINE
518 ulint
520 /*==========*/
521  ulint space,
522  ulint page_no)
523  __attribute__((const));
524 /*********************************************************************/
528 UNIV_INLINE
529 ulint
531 /*==========*/
532  ulint space,
533  ulint page_no);
535 /**********************************************************************/
540 UNIV_INTERN
541 ulint
543 /*==================*/
544  const lock_t* lock);
547 /*********************************************************************/
554 UNIV_INTERN
557 /*===============*/
558  trx_t* trx,
559  dict_table_t* dest,
560  enum lock_mode* mode);
561 /*********************************************************************/
567 UNIV_INTERN
568 ibool
570 /*====================*/
571  const dict_table_t* table,
572  const trx_t* trx)
573  __attribute__((nonnull));
574 /*********************************************************************/
577 UNIV_INTERN
578 ibool
580 /*=============*/
581  const lock_t* lock1,
582  const lock_t* lock2);
586 /*********************************************************************/
588 UNIV_INTERN
589 void
591 /*========================*/
592  trx_id_t trx_id,
593  const rec_t* rec,
594  dict_index_t* index,
595  const ulint* offsets,
596  trx_id_t max_trx_id)
597  __attribute__((nonnull));
598 /*********************************************************************/
600 UNIV_INTERN
601 void
603 /*=============*/
604  FILE* file,
605  const lock_t* lock);
606 /*********************************************************************/
608 UNIV_INTERN
609 void
611 /*===========*/
612  FILE* file,
613  const lock_t* lock);
614 /*********************************************************************/
618 UNIV_INTERN
619 ibool
621 /*====================*/
622  FILE* file,
623  ibool nowait)
624  __attribute__((nonnull, warn_unused_result));
625 /*********************************************************************/
629 UNIV_INTERN
630 void
632 /*=============================*/
633  FILE* file);
634 /*********************************************************************/
639 UNIV_INTERN
640 ulint
642 /*=======================*/
643  const trx_lock_t* trx_lock)
644  __attribute__((nonnull, warn_unused_result));
645 
646 /*******************************************************************/
650 UNIV_INTERN
651 ulint
653 /*==========*/
654  const lock_t* lock);
656 /*******************************************************************/
659 UNIV_INTERN
660 trx_id_t
662 /*============*/
663  const lock_t* lock);
665 /*******************************************************************/
669 UNIV_INTERN
670 const char*
672 /*==============*/
673  const lock_t* lock);
675 /*******************************************************************/
679 UNIV_INTERN
680 const char*
682 /*==============*/
683  const lock_t* lock);
685 /*******************************************************************/
688 UNIV_INTERN
689 table_id_t
691 /*==============*/
692  const lock_t* lock);
694 /*******************************************************************/
698 UNIV_INTERN
699 const char*
701 /*================*/
702  const lock_t* lock);
704 /*******************************************************************/
707 UNIV_INTERN
708 const dict_index_t*
710 /*===============*/
711  const lock_t* lock);
713 /*******************************************************************/
717 UNIV_INTERN
718 const char*
720 /*====================*/
721  const lock_t* lock);
723 /*******************************************************************/
726 UNIV_INTERN
727 ulint
729 /*==================*/
730  const lock_t* lock);
732 /*******************************************************************/
735 UNIV_INTERN
736 ulint
738 /*=================*/
739  const lock_t* lock);
740 /*******************************************************************/
743 UNIV_INTERN
744 ibool
746 /*=================*/
747  const dict_table_t* table);
751 /*********************************************************************/
754 extern "C" UNIV_INTERN
755 os_thread_ret_t
757 /*=====================================*/
758  void* arg);
761 /********************************************************************/
764 UNIV_INTERN
765 void
767 /*==================================*/
768  que_thr_t* thr);
771 /***************************************************************/
777 UNIV_INTERN
778 void
780 /*=====================*/
781  que_thr_t* thr);
783 /*********************************************************************/
787 UNIV_INTERN
788 void
790 /*======================*/
791  trx_t* trx);
792 /*********************************************************************/
797 UNIV_INTERN
798 dberr_t
800 /*=================*/
801  trx_t* trx)
802  __attribute__((nonnull));
803 /*********************************************************************/
806 UNIV_INTERN
807 ulint
809 /*===================*/
810  const dict_table_t* table)
811  __attribute__((nonnull));
812 #ifdef UNIV_DEBUG
813 /*********************************************************************/
816 UNIV_INTERN
817 bool
819 /*=====================*/
820  trx_id_t trx_id,
821  const rec_t* rec,
822  dict_index_t* index,
823  const ulint* offsets)
824  __attribute__((nonnull, warn_unused_result));
825 /*******************************************************************/
829 UNIV_INTERN
830 const lock_t*
832 /*=========================*/
833  const trx_t* trx)
834  __attribute__((warn_unused_result));
835 
836 /*******************************************************************/
839 UNIV_INTERN
840 bool
842 /*====================*/
843  const trx_t* trx,
844  const dict_table_t* table,
845  const buf_block_t* block,
846  ulint heap_no)
847  __attribute__((nonnull, warn_unused_result));
848 #endif /* UNIV_DEBUG */
849 
851 /* @{ */
852 #define LOCK_MODE_MASK 0xFUL
855 /* @{ */
856 #define LOCK_TABLE 16
857 #define LOCK_REC 32
858 #define LOCK_TYPE_MASK 0xF0UL
860 #if LOCK_MODE_MASK & LOCK_TYPE_MASK
861 # error "LOCK_MODE_MASK & LOCK_TYPE_MASK"
862 #endif
863 
864 #define LOCK_WAIT 256
868 /* Precise modes */
869 #define LOCK_ORDINARY 0
872 #define LOCK_GAP 512
879 #define LOCK_REC_NOT_GAP 1024
887 #define LOCK_INSERT_INTENTION 2048
896 #if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_MODE_MASK
897 # error
898 #endif
899 #if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_TYPE_MASK
900 # error
901 #endif
902 /* @} */
903 
905 struct lock_op_t{
907  enum lock_mode mode;
908 };
909 
911 struct lock_sys_t{
941 };
942 
944 extern lock_sys_t* lock_sys;
945 
947 #define lock_mutex_enter_nowait() mutex_enter_nowait(&lock_sys->mutex)
948 
950 #define lock_mutex_own() mutex_own(&lock_sys->mutex)
951 
953 #define lock_mutex_enter() do { \
954  mutex_enter(&lock_sys->mutex); \
955 } while (0)
956 
958 #define lock_mutex_exit() do { \
959  mutex_exit(&lock_sys->mutex); \
960 } while (0)
961 
963 #define lock_wait_mutex_own() mutex_own(&lock_sys->wait_mutex)
964 
966 #define lock_wait_mutex_enter() do { \
967  mutex_enter(&lock_sys->wait_mutex); \
968 } while (0)
969 
971 #define lock_wait_mutex_exit() do { \
972  mutex_exit(&lock_sys->wait_mutex); \
973 } while (0)
974 
975 #ifndef UNIV_NONINL
976 #include "lock0lock.ic"
977 #endif
978 
979 #endif