1
/*****************************************************************************
3
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
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.
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.
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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/lock0lock.h
21
The transaction lock system
23
Created 5/7/1996 Heikki Tuuri
24
*******************************************************/
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"
42
extern ibool lock_print_waits;
43
#endif /* UNIV_DEBUG */
44
/* Buffer for storing information about the most recent deadlock error */
45
extern FILE* lock_latest_err_file;
47
/*********************************************************************//**
48
Gets the size of a lock struct.
49
@return size in bytes */
54
/*********************************************************************//**
55
Creates the lock system at database start. */
60
ulint n_cells); /*!< in: number of slots in lock hash table */
61
/*********************************************************************//**
62
Closes the lock system at database shutdown. */
67
/*********************************************************************//**
68
Checks if some transaction has an implicit x-lock on a record in a clustered
70
@return transaction which has the x-lock, or NULL */
73
lock_clust_rec_some_has_impl(
74
/*=========================*/
75
const rec_t* rec, /*!< in: user record */
76
dict_index_t* index, /*!< in: clustered index */
77
const ulint* offsets);/*!< in: rec_get_offsets(rec, index) */
78
/*********************************************************************//**
79
Gets the heap_no of the smallest user record on a page.
80
@return heap_no of smallest user record, or PAGE_HEAP_NO_SUPREMUM */
85
const buf_block_t* block); /*!< in: buffer block */
86
/*************************************************************//**
87
Updates the lock table when we have reorganized a page. NOTE: we copy
88
also the locks set on the infimum of the page; the infimum may carry
89
locks if an update of a record is occurring on the page, and its locks
90
were temporarily stored on the infimum. */
93
lock_move_reorganize_page(
94
/*======================*/
95
const buf_block_t* block, /*!< in: old index page, now
97
const buf_block_t* oblock);/*!< in: copy of the old, not
99
/*************************************************************//**
100
Moves the explicit locks on user records to another page if a record
101
list end is moved to another page. */
104
lock_move_rec_list_end(
105
/*===================*/
106
const buf_block_t* new_block, /*!< in: index page to move to */
107
const buf_block_t* block, /*!< in: index page */
108
const rec_t* rec); /*!< in: record on page: this
109
is the first record moved */
110
/*************************************************************//**
111
Moves the explicit locks on user records to another page if a record
112
list start is moved to another page. */
115
lock_move_rec_list_start(
116
/*=====================*/
117
const buf_block_t* new_block, /*!< in: index page to move to */
118
const buf_block_t* block, /*!< in: index page */
119
const rec_t* rec, /*!< in: record on page:
122
const rec_t* old_end); /*!< in: old
127
/*************************************************************//**
128
Updates the lock table when a page is split to the right. */
131
lock_update_split_right(
132
/*====================*/
133
const buf_block_t* right_block, /*!< in: right page */
134
const buf_block_t* left_block); /*!< in: left page */
135
/*************************************************************//**
136
Updates the lock table when a page is merged to the right. */
139
lock_update_merge_right(
140
/*====================*/
141
const buf_block_t* right_block, /*!< in: right page to
143
const rec_t* orig_succ, /*!< in: original
147
const buf_block_t* left_block); /*!< in: merged index
150
/*************************************************************//**
151
Updates the lock table when the root page is copied to another in
152
btr_root_raise_and_insert. Note that we leave lock structs on the
153
root page, even though they do not make sense on other than leaf
154
pages: the reason is that in a pessimistic update the infimum record
155
of the root page will act as a dummy carrier of the locks of the record
159
lock_update_root_raise(
160
/*===================*/
161
const buf_block_t* block, /*!< in: index page to which copied */
162
const buf_block_t* root); /*!< in: root page */
163
/*************************************************************//**
164
Updates the lock table when a page is copied to another and the original page
165
is removed from the chain of leaf pages, except if page is the root! */
168
lock_update_copy_and_discard(
169
/*=========================*/
170
const buf_block_t* new_block, /*!< in: index page to
172
const buf_block_t* block); /*!< in: index page;
174
/*************************************************************//**
175
Updates the lock table when a page is split to the left. */
178
lock_update_split_left(
179
/*===================*/
180
const buf_block_t* right_block, /*!< in: right page */
181
const buf_block_t* left_block); /*!< in: left page */
182
/*************************************************************//**
183
Updates the lock table when a page is merged to the left. */
186
lock_update_merge_left(
187
/*===================*/
188
const buf_block_t* left_block, /*!< in: left page to
190
const rec_t* orig_pred, /*!< in: original predecessor
191
of supremum on the left page
193
const buf_block_t* right_block); /*!< in: merged index page
194
which will be discarded */
195
/*************************************************************//**
196
Resets the original locks on heir and replaces them with gap type locks
197
inherited from rec. */
200
lock_rec_reset_and_inherit_gap_locks(
201
/*=================================*/
202
const buf_block_t* heir_block, /*!< in: block containing the
203
record which inherits */
204
const buf_block_t* block, /*!< in: block containing the
205
record from which inherited;
206
does NOT reset the locks on
208
ulint heir_heap_no, /*!< in: heap_no of the
210
ulint heap_no); /*!< in: heap_no of the
212
/*************************************************************//**
213
Updates the lock table when a page is discarded. */
218
const buf_block_t* heir_block, /*!< in: index page
219
which will inherit the locks */
220
ulint heir_heap_no, /*!< in: heap_no of the record
221
which will inherit the locks */
222
const buf_block_t* block); /*!< in: index page
223
which will be discarded */
224
/*************************************************************//**
225
Updates the lock table when a new user record is inserted. */
230
const buf_block_t* block, /*!< in: buffer block containing rec */
231
const rec_t* rec); /*!< in: the inserted record */
232
/*************************************************************//**
233
Updates the lock table when a record is removed. */
238
const buf_block_t* block, /*!< in: buffer block containing rec */
239
const rec_t* rec); /*!< in: the record to be removed */
240
/*********************************************************************//**
241
Stores on the page infimum record the explicit locks of another record.
242
This function is used to store the lock state of a record when it is
243
updated and the size of the record changes in the update. The record
244
is in such an update moved, perhaps to another page. The infimum record
245
acts as a dummy carrier record, taking care of lock releases while the
246
actual record is being moved. */
249
lock_rec_store_on_page_infimum(
250
/*===========================*/
251
const buf_block_t* block, /*!< in: buffer block containing rec */
252
const rec_t* rec); /*!< in: record whose lock state
253
is stored on the infimum
254
record of the same page; lock
255
bits are reset on the
257
/*********************************************************************//**
258
Restores the state of explicit lock requests on a single record, where the
259
state was stored on the infimum of the page. */
262
lock_rec_restore_from_page_infimum(
263
/*===============================*/
264
const buf_block_t* block, /*!< in: buffer block containing rec */
265
const rec_t* rec, /*!< in: record whose lock state
267
const buf_block_t* donator);/*!< in: page (rec is not
268
necessarily on this page)
269
whose infimum stored the lock
270
state; lock bits are reset on
272
/*********************************************************************//**
273
Returns TRUE if there are explicit record locks on a page.
274
@return TRUE if there are explicit record locks on the page */
277
lock_rec_expl_exist_on_page(
278
/*========================*/
279
ulint space, /*!< in: space id */
280
ulint page_no);/*!< in: page number */
281
/*********************************************************************//**
282
Checks if locks of other transactions prevent an immediate insert of
283
a record. If they do, first tests if the query thread should anyway
284
be suspended for some reason; if not, then puts the transaction and
285
the query thread to the lock wait state and inserts a waiting request
286
for a gap x-lock to the lock queue.
287
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
290
lock_rec_insert_check_and_lock(
291
/*===========================*/
292
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is
294
const rec_t* rec, /*!< in: record after which to insert */
295
buf_block_t* block, /*!< in/out: buffer block of rec */
296
dict_index_t* index, /*!< in: index */
297
que_thr_t* thr, /*!< in: query thread */
298
mtr_t* mtr, /*!< in/out: mini-transaction */
299
ibool* inherit);/*!< out: set to TRUE if the new
300
inserted record maybe should inherit
301
LOCK_GAP type locks from the successor
303
/*********************************************************************//**
304
Checks if locks of other transactions prevent an immediate modify (update,
305
delete mark, or delete unmark) of a clustered index record. If they do,
306
first tests if the query thread should anyway be suspended for some
307
reason; if not, then puts the transaction and the query thread to the
308
lock wait state and inserts a waiting request for a record x-lock to the
310
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
313
lock_clust_rec_modify_check_and_lock(
314
/*=================================*/
315
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
316
bit is set, does nothing */
317
const buf_block_t* block, /*!< in: buffer block of rec */
318
const rec_t* rec, /*!< in: record which should be
320
dict_index_t* index, /*!< in: clustered index */
321
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
322
que_thr_t* thr); /*!< in: query thread */
323
/*********************************************************************//**
324
Checks if locks of other transactions prevent an immediate modify
325
(delete mark or delete unmark) of a secondary index record.
326
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
329
lock_sec_rec_modify_check_and_lock(
330
/*===============================*/
331
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
332
bit is set, does nothing */
333
buf_block_t* block, /*!< in/out: buffer block of rec */
334
const rec_t* rec, /*!< in: record which should be
335
modified; NOTE: as this is a secondary
336
index, we always have to modify the
337
clustered index record first: see the
339
dict_index_t* index, /*!< in: secondary index */
340
que_thr_t* thr, /*!< in: query thread */
341
mtr_t* mtr); /*!< in/out: mini-transaction */
342
/*********************************************************************//**
343
Like lock_clust_rec_read_check_and_lock(), but reads a
344
secondary index record.
345
@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK,
346
or DB_QUE_THR_SUSPENDED */
349
lock_sec_rec_read_check_and_lock(
350
/*=============================*/
351
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
352
bit is set, does nothing */
353
const buf_block_t* block, /*!< in: buffer block of rec */
354
const rec_t* rec, /*!< in: user record or page
355
supremum record which should
356
be read or passed over by a
358
dict_index_t* index, /*!< in: secondary index */
359
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
360
enum lock_mode mode, /*!< in: mode of the lock which
361
the read cursor should set on
362
records: LOCK_S or LOCK_X; the
363
latter is possible in
365
ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or
367
que_thr_t* thr); /*!< in: query thread */
368
/*********************************************************************//**
369
Checks if locks of other transactions prevent an immediate read, or passing
370
over by a read cursor, of a clustered index record. If they do, first tests
371
if the query thread should anyway be suspended for some reason; if not, then
372
puts the transaction and the query thread to the lock wait state and inserts a
373
waiting request for a record lock to the lock queue. Sets the requested mode
375
@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK,
376
or DB_QUE_THR_SUSPENDED */
379
lock_clust_rec_read_check_and_lock(
380
/*===============================*/
381
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
382
bit is set, does nothing */
383
const buf_block_t* block, /*!< in: buffer block of rec */
384
const rec_t* rec, /*!< in: user record or page
385
supremum record which should
386
be read or passed over by a
388
dict_index_t* index, /*!< in: clustered index */
389
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
390
enum lock_mode mode, /*!< in: mode of the lock which
391
the read cursor should set on
392
records: LOCK_S or LOCK_X; the
393
latter is possible in
395
ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or
397
que_thr_t* thr); /*!< in: query thread */
398
/*********************************************************************//**
399
Checks if locks of other transactions prevent an immediate read, or passing
400
over by a read cursor, of a clustered index record. If they do, first tests
401
if the query thread should anyway be suspended for some reason; if not, then
402
puts the transaction and the query thread to the lock wait state and inserts a
403
waiting request for a record lock to the lock queue. Sets the requested mode
404
lock on the record. This is an alternative version of
405
lock_clust_rec_read_check_and_lock() that does not require the parameter
407
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
410
lock_clust_rec_read_check_and_lock_alt(
411
/*===================================*/
412
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
413
bit is set, does nothing */
414
const buf_block_t* block, /*!< in: buffer block of rec */
415
const rec_t* rec, /*!< in: user record or page
416
supremum record which should
417
be read or passed over by a
419
dict_index_t* index, /*!< in: clustered index */
420
enum lock_mode mode, /*!< in: mode of the lock which
421
the read cursor should set on
422
records: LOCK_S or LOCK_X; the
423
latter is possible in
425
ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or
427
que_thr_t* thr); /*!< in: query thread */
428
/*********************************************************************//**
429
Checks that a record is seen in a consistent read.
430
@return TRUE if sees, or FALSE if an earlier version of the record
431
should be retrieved */
434
lock_clust_rec_cons_read_sees(
435
/*==========================*/
436
const rec_t* rec, /*!< in: user record which should be read or
437
passed over by a read cursor */
438
dict_index_t* index, /*!< in: clustered index */
439
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
440
read_view_t* view); /*!< in: consistent read view */
441
/*********************************************************************//**
442
Checks that a non-clustered index record is seen in a consistent read.
444
NOTE that a non-clustered index page contains so little information on
445
its modifications that also in the case FALSE, the present version of
446
rec may be the right, but we must check this from the clustered index
449
@return TRUE if certainly sees, or FALSE if an earlier version of the
450
clustered index record might be needed */
453
lock_sec_rec_cons_read_sees(
454
/*========================*/
455
const rec_t* rec, /*!< in: user record which
456
should be read or passed over
458
const read_view_t* view); /*!< in: consistent read view */
459
/*********************************************************************//**
460
Locks the specified database table in the mode given. If the lock cannot
461
be granted immediately, the query thread is put to wait.
462
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
467
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set,
469
dict_table_t* table, /*!< in: database table in dictionary cache */
470
enum lock_mode mode, /*!< in: lock mode */
471
que_thr_t* thr); /*!< in: query thread */
472
/*************************************************************//**
473
Removes a granted record lock of a transaction from the queue and grants
474
locks to other transactions waiting in the queue if they now are entitled
480
trx_t* trx, /*!< in: transaction that has
482
const buf_block_t* block, /*!< in: buffer block containing rec */
483
const rec_t* rec, /*!< in: record */
484
enum lock_mode lock_mode);/*!< in: LOCK_S or LOCK_X */
485
/*********************************************************************//**
486
Releases transaction locks, and releases possible other transactions waiting
487
because of these locks. */
490
lock_release_off_kernel(
491
/*====================*/
492
trx_t* trx); /*!< in: transaction */
493
/*********************************************************************//**
494
Cancels a waiting lock request and releases possible other transactions
495
waiting behind it. */
498
lock_cancel_waiting_and_release(
499
/*============================*/
500
lock_t* lock); /*!< in: waiting lock request */
502
/*********************************************************************//**
503
Removes locks on a table to be dropped or truncated.
504
If remove_also_table_sx_locks is TRUE then table-level S and X locks are
505
also removed in addition to other table-level and record-level locks.
506
No lock, that is going to be removed, is allowed to be a wait lock. */
509
lock_remove_all_on_table(
510
/*=====================*/
511
dict_table_t* table, /*!< in: table to be dropped
513
ibool remove_also_table_sx_locks);/*!< in: also removes
514
table S and X locks */
516
/*********************************************************************//**
517
Calculates the fold value of a page file address: used in inserting or
518
searching for a lock in the hash table.
519
@return folded value */
524
ulint space, /*!< in: space */
525
ulint page_no)/*!< in: page number */
526
__attribute__((const));
527
/*********************************************************************//**
528
Calculates the hash value of a page file address: used in inserting or
529
searching for a lock in the hash table.
530
@return hashed value */
535
ulint space, /*!< in: space */
536
ulint page_no);/*!< in: page number */
538
/**********************************************************************//**
539
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED,
541
@return bit index == heap number of the record, or ULINT_UNDEFINED if
545
lock_rec_find_set_bit(
546
/*==================*/
547
const lock_t* lock); /*!< in: record lock with at least one
550
/*********************************************************************//**
551
Gets the source table of an ALTER TABLE transaction. The table must be
552
covered by an IX or IS table lock.
553
@return the source table of transaction, if it is covered by an IX or
554
IS table lock; dest if there is no source table, and NULL if the
555
transaction is locking more than two tables or an inconsistency is
561
trx_t* trx, /*!< in: transaction */
562
dict_table_t* dest, /*!< in: destination of ALTER TABLE */
563
enum lock_mode* mode); /*!< out: lock mode of the source table */
564
/*********************************************************************//**
565
Determine if the given table is exclusively "owned" by the given
566
transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC
568
@return TRUE if table is only locked by trx, with LOCK_IX, and
569
possibly LOCK_AUTO_INC */
572
lock_is_table_exclusive(
573
/*====================*/
574
dict_table_t* table, /*!< in: table */
575
trx_t* trx); /*!< in: transaction */
576
/*********************************************************************//**
577
Checks if a lock request lock1 has to wait for request lock2.
578
@return TRUE if lock1 has to wait for lock2 to be removed */
583
const lock_t* lock1, /*!< in: waiting lock */
584
const lock_t* lock2); /*!< in: another lock; NOTE that it is
585
assumed that this has a lock bit set
586
on the same record as in lock1 if the
587
locks are record locks */
588
/*********************************************************************//**
589
Checks that a transaction id is sensible, i.e., not in the future.
590
@return TRUE if ok */
593
lock_check_trx_id_sanity(
594
/*=====================*/
595
trx_id_t trx_id, /*!< in: trx id */
596
const rec_t* rec, /*!< in: user record */
597
dict_index_t* index, /*!< in: clustered index */
598
const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */
599
ibool has_kernel_mutex);/*!< in: TRUE if the caller owns the
601
/*********************************************************************//**
602
Prints info of a table lock. */
607
FILE* file, /*!< in: file where to print */
608
const lock_t* lock); /*!< in: table type lock */
609
/*********************************************************************//**
610
Prints info of a record lock. */
615
FILE* file, /*!< in: file where to print */
616
const lock_t* lock); /*!< in: record type lock */
617
/*********************************************************************//**
618
Prints info of locks for all transactions.
619
@return FALSE if not able to obtain kernel mutex
620
and exits without printing info */
623
lock_print_info_summary(
624
/*====================*/
625
FILE* file, /*!< in: file where to print */
626
ibool nowait);/*!< in: whether to wait for the kernel mutex */
627
/*************************************************************************
628
Prints info of locks for each transaction. */
631
lock_print_info_all_transactions(
632
/*=============================*/
633
FILE* file); /*!< in: file where to print */
634
/*********************************************************************//**
635
Return approximate number or record locks (bits set in the bitmap) for
636
this transaction. Since delete-marked records may be removed, the
637
record count will not be precise. */
640
lock_number_of_rows_locked(
641
/*=======================*/
642
const trx_t* trx); /*!< in: transaction */
643
/*******************************************************************//**
644
Check if a transaction holds any autoinc locks.
645
@return TRUE if the transaction holds any AUTOINC locks. */
648
lock_trx_holds_autoinc_locks(
649
/*=========================*/
650
const trx_t* trx); /*!< in: transaction */
651
/*******************************************************************//**
652
Release all the transaction's autoinc locks. */
655
lock_release_autoinc_locks(
656
/*=======================*/
657
trx_t* trx); /*!< in/out: transaction */
659
/*******************************************************************//**
660
Gets the type of a lock. Non-inline version for using outside of the
662
@return LOCK_TABLE or LOCK_REC */
667
const lock_t* lock); /*!< in: lock */
669
/*******************************************************************//**
670
Gets the id of the transaction owning a lock.
671
@return transaction id */
676
const lock_t* lock); /*!< in: lock */
678
/*******************************************************************//**
679
Gets the mode of a lock in a human readable string.
680
The string should not be free()'d or modified.
686
const lock_t* lock); /*!< in: lock */
688
/*******************************************************************//**
689
Gets the type of a lock in a human readable string.
690
The string should not be free()'d or modified.
696
const lock_t* lock); /*!< in: lock */
698
/*******************************************************************//**
699
Gets the id of the table on which the lock is.
700
@return id of the table */
705
const lock_t* lock); /*!< in: lock */
707
/*******************************************************************//**
708
Gets the name of the table on which the lock is.
709
The string should not be free()'d or modified.
710
@return name of the table */
715
const lock_t* lock); /*!< in: lock */
717
/*******************************************************************//**
718
For a record lock, gets the index on which the lock is.
724
const lock_t* lock); /*!< in: lock */
726
/*******************************************************************//**
727
For a record lock, gets the name of the index on which the lock is.
728
The string should not be free()'d or modified.
729
@return name of the index */
732
lock_rec_get_index_name(
733
/*====================*/
734
const lock_t* lock); /*!< in: lock */
736
/*******************************************************************//**
737
For a record lock, gets the tablespace number on which the lock is.
738
@return tablespace number */
741
lock_rec_get_space_id(
742
/*==================*/
743
const lock_t* lock); /*!< in: lock */
745
/*******************************************************************//**
746
For a record lock, gets the page number on which the lock is.
747
@return page number */
750
lock_rec_get_page_no(
751
/*=================*/
752
const lock_t* lock); /*!< in: lock */
754
/** Lock modes and types */
756
#define LOCK_MODE_MASK 0xFUL /*!< mask used to extract mode from the
757
type_mode field in a lock */
760
#define LOCK_TABLE 16 /*!< table lock */
761
#define LOCK_REC 32 /*!< record lock */
762
#define LOCK_TYPE_MASK 0xF0UL /*!< mask used to extract lock type from the
763
type_mode field in a lock */
764
#if LOCK_MODE_MASK & LOCK_TYPE_MASK
765
# error "LOCK_MODE_MASK & LOCK_TYPE_MASK"
768
#define LOCK_WAIT 256 /*!< Waiting lock flag; when set, it
769
means that the lock has not yet been
770
granted, it is just waiting for its
771
turn in the wait queue */
773
#define LOCK_ORDINARY 0 /*!< this flag denotes an ordinary
774
next-key lock in contrast to LOCK_GAP
775
or LOCK_REC_NOT_GAP */
776
#define LOCK_GAP 512 /*!< when this bit is set, it means that the
777
lock holds only on the gap before the record;
778
for instance, an x-lock on the gap does not
779
give permission to modify the record on which
780
the bit is set; locks of this type are created
781
when records are removed from the index chain
783
#define LOCK_REC_NOT_GAP 1024 /*!< this bit means that the lock is only on
784
the index record and does NOT block inserts
785
to the gap before the index record; this is
786
used in the case when we retrieve a record
787
with a unique key, and is also used in
788
locking plain SELECTs (not part of UPDATE
789
or DELETE) when the user has set the READ
790
COMMITTED isolation level */
791
#define LOCK_INSERT_INTENTION 2048 /*!< this bit is set when we place a waiting
792
gap type record lock request in order to let
793
an insert of an index record to wait until
794
there are no conflicting locks by other
795
transactions on the gap; note that this flag
796
remains set when the waiting lock is granted,
797
or if the lock is inherited to a neighboring
799
#if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_MODE_MASK
802
#if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_TYPE_MASK
807
/** Lock operation struct */
808
typedef struct lock_op_struct lock_op_t;
809
/** Lock operation struct */
810
struct lock_op_struct{
811
dict_table_t* table; /*!< table to be locked */
812
enum lock_mode mode; /*!< lock mode */
815
/** The lock system struct */
816
struct lock_sys_struct{
817
hash_table_t* rec_hash; /*!< hash table of the record locks */
820
/** The lock system */
821
extern lock_sys_t* lock_sys;
825
#include "lock0lock.ic"