1
/*****************************************************************************
3
Copyright (c) 1996, 2009, 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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 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 the counterpart for a clustered index below, but now we read a
344
secondary index record.
345
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
348
lock_sec_rec_read_check_and_lock(
349
/*=============================*/
350
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
351
bit is set, does nothing */
352
const buf_block_t* block, /*!< in: buffer block of rec */
353
const rec_t* rec, /*!< in: user record or page
354
supremum record which should
355
be read or passed over by a
357
dict_index_t* index, /*!< in: secondary index */
358
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
359
enum lock_mode mode, /*!< in: mode of the lock which
360
the read cursor should set on
361
records: LOCK_S or LOCK_X; the
362
latter is possible in
364
ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or
366
que_thr_t* thr); /*!< in: query thread */
367
/*********************************************************************//**
368
Checks if locks of other transactions prevent an immediate read, or passing
369
over by a read cursor, of a clustered index record. If they do, first tests
370
if the query thread should anyway be suspended for some reason; if not, then
371
puts the transaction and the query thread to the lock wait state and inserts a
372
waiting request for a record lock to the lock queue. Sets the requested mode
374
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
377
lock_clust_rec_read_check_and_lock(
378
/*===============================*/
379
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
380
bit is set, does nothing */
381
const buf_block_t* block, /*!< in: buffer block of rec */
382
const rec_t* rec, /*!< in: user record or page
383
supremum record which should
384
be read or passed over by a
386
dict_index_t* index, /*!< in: clustered index */
387
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
388
enum lock_mode mode, /*!< in: mode of the lock which
389
the read cursor should set on
390
records: LOCK_S or LOCK_X; the
391
latter is possible in
393
ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or
395
que_thr_t* thr); /*!< in: query thread */
396
/*********************************************************************//**
397
Checks if locks of other transactions prevent an immediate read, or passing
398
over by a read cursor, of a clustered index record. If they do, first tests
399
if the query thread should anyway be suspended for some reason; if not, then
400
puts the transaction and the query thread to the lock wait state and inserts a
401
waiting request for a record lock to the lock queue. Sets the requested mode
402
lock on the record. This is an alternative version of
403
lock_clust_rec_read_check_and_lock() that does not require the parameter
405
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
408
lock_clust_rec_read_check_and_lock_alt(
409
/*===================================*/
410
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG
411
bit is set, does nothing */
412
const buf_block_t* block, /*!< in: buffer block of rec */
413
const rec_t* rec, /*!< in: user record or page
414
supremum record which should
415
be read or passed over by a
417
dict_index_t* index, /*!< in: clustered index */
418
enum lock_mode mode, /*!< in: mode of the lock which
419
the read cursor should set on
420
records: LOCK_S or LOCK_X; the
421
latter is possible in
423
ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or
425
que_thr_t* thr); /*!< in: query thread */
426
/*********************************************************************//**
427
Checks that a record is seen in a consistent read.
428
@return TRUE if sees, or FALSE if an earlier version of the record
429
should be retrieved */
432
lock_clust_rec_cons_read_sees(
433
/*==========================*/
434
const rec_t* rec, /*!< in: user record which should be read or
435
passed over by a read cursor */
436
dict_index_t* index, /*!< in: clustered index */
437
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
438
read_view_t* view); /*!< in: consistent read view */
439
/*********************************************************************//**
440
Checks that a non-clustered index record is seen in a consistent read.
442
NOTE that a non-clustered index page contains so little information on
443
its modifications that also in the case FALSE, the present version of
444
rec may be the right, but we must check this from the clustered index
447
@return TRUE if certainly sees, or FALSE if an earlier version of the
448
clustered index record might be needed */
451
lock_sec_rec_cons_read_sees(
452
/*========================*/
453
const rec_t* rec, /*!< in: user record which
454
should be read or passed over
456
const read_view_t* view); /*!< in: consistent read view */
457
/*********************************************************************//**
458
Locks the specified database table in the mode given. If the lock cannot
459
be granted immediately, the query thread is put to wait.
460
@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
465
ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set,
467
dict_table_t* table, /*!< in: database table in dictionary cache */
468
enum lock_mode mode, /*!< in: lock mode */
469
que_thr_t* thr); /*!< in: query thread */
470
/*************************************************************//**
471
Removes a granted record lock of a transaction from the queue and grants
472
locks to other transactions waiting in the queue if they now are entitled
478
trx_t* trx, /*!< in: transaction that has
480
const buf_block_t* block, /*!< in: buffer block containing rec */
481
const rec_t* rec, /*!< in: record */
482
enum lock_mode lock_mode);/*!< in: LOCK_S or LOCK_X */
483
/*********************************************************************//**
484
Releases transaction locks, and releases possible other transactions waiting
485
because of these locks. */
488
lock_release_off_kernel(
489
/*====================*/
490
trx_t* trx); /*!< in: transaction */
491
/*********************************************************************//**
492
Cancels a waiting lock request and releases possible other transactions
493
waiting behind it. */
496
lock_cancel_waiting_and_release(
497
/*============================*/
498
lock_t* lock); /*!< in: waiting lock request */
500
/*********************************************************************//**
501
Removes locks on a table to be dropped or truncated.
502
If remove_also_table_sx_locks is TRUE then table-level S and X locks are
503
also removed in addition to other table-level and record-level locks.
504
No lock, that is going to be removed, is allowed to be a wait lock. */
507
lock_remove_all_on_table(
508
/*=====================*/
509
dict_table_t* table, /*!< in: table to be dropped
511
ibool remove_also_table_sx_locks);/*!< in: also removes
512
table S and X locks */
514
/*********************************************************************//**
515
Calculates the fold value of a page file address: used in inserting or
516
searching for a lock in the hash table.
517
@return folded value */
522
ulint space, /*!< in: space */
523
ulint page_no)/*!< in: page number */
524
__attribute__((const));
525
/*********************************************************************//**
526
Calculates the hash value of a page file address: used in inserting or
527
searching for a lock in the hash table.
528
@return hashed value */
533
ulint space, /*!< in: space */
534
ulint page_no);/*!< in: page number */
536
/**********************************************************************//**
537
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED,
539
@return bit index == heap number of the record, or ULINT_UNDEFINED if
543
lock_rec_find_set_bit(
544
/*==================*/
545
const lock_t* lock); /*!< in: record lock with at least one
548
/*********************************************************************//**
549
Gets the source table of an ALTER TABLE transaction. The table must be
550
covered by an IX or IS table lock.
551
@return the source table of transaction, if it is covered by an IX or
552
IS table lock; dest if there is no source table, and NULL if the
553
transaction is locking more than two tables or an inconsistency is
559
trx_t* trx, /*!< in: transaction */
560
dict_table_t* dest, /*!< in: destination of ALTER TABLE */
561
enum lock_mode* mode); /*!< out: lock mode of the source table */
562
/*********************************************************************//**
563
Determine if the given table is exclusively "owned" by the given
564
transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC
566
@return TRUE if table is only locked by trx, with LOCK_IX, and
567
possibly LOCK_AUTO_INC */
570
lock_is_table_exclusive(
571
/*====================*/
572
dict_table_t* table, /*!< in: table */
573
trx_t* trx); /*!< in: transaction */
574
/*********************************************************************//**
575
Checks if a lock request lock1 has to wait for request lock2.
576
@return TRUE if lock1 has to wait for lock2 to be removed */
581
const lock_t* lock1, /*!< in: waiting lock */
582
const lock_t* lock2); /*!< in: another lock; NOTE that it is
583
assumed that this has a lock bit set
584
on the same record as in lock1 if the
585
locks are record locks */
586
/*********************************************************************//**
587
Checks that a transaction id is sensible, i.e., not in the future.
588
@return TRUE if ok */
591
lock_check_trx_id_sanity(
592
/*=====================*/
593
trx_id_t trx_id, /*!< in: trx id */
594
const rec_t* rec, /*!< in: user record */
595
dict_index_t* index, /*!< in: clustered index */
596
const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */
597
ibool has_kernel_mutex);/*!< in: TRUE if the caller owns the
599
/*********************************************************************//**
600
Prints info of a table lock. */
605
FILE* file, /*!< in: file where to print */
606
const lock_t* lock); /*!< in: table type lock */
607
/*********************************************************************//**
608
Prints info of a record lock. */
613
FILE* file, /*!< in: file where to print */
614
const lock_t* lock); /*!< in: record type lock */
615
/*********************************************************************//**
616
Prints info of locks for all transactions. */
619
lock_print_info_summary(
620
/*====================*/
621
FILE* file); /*!< in: file where to print */
622
/*********************************************************************//**
623
Prints info of locks for each transaction. */
626
lock_print_info_all_transactions(
627
/*=============================*/
628
FILE* file); /*!< in: file where to print */
629
/*********************************************************************//**
630
Return approximate number or record locks (bits set in the bitmap) for
631
this transaction. Since delete-marked records may be removed, the
632
record count will not be precise. */
635
lock_number_of_rows_locked(
636
/*=======================*/
637
trx_t* trx); /*!< in: transaction */
638
/*******************************************************************//**
639
Check if a transaction holds any autoinc locks.
640
@return TRUE if the transaction holds any AUTOINC locks. */
643
lock_trx_holds_autoinc_locks(
644
/*=========================*/
645
const trx_t* trx); /*!< in: transaction */
646
/*******************************************************************//**
647
Release all the transaction's autoinc locks. */
650
lock_release_autoinc_locks(
651
/*=======================*/
652
trx_t* trx); /*!< in/out: transaction */
654
/*******************************************************************//**
655
Gets the type of a lock. Non-inline version for using outside of the
657
@return LOCK_TABLE or LOCK_REC */
662
const lock_t* lock); /*!< in: lock */
664
/*******************************************************************//**
665
Gets the id of the transaction owning a lock.
666
@return transaction id */
671
const lock_t* lock); /*!< in: lock */
673
/*******************************************************************//**
674
Gets the mode of a lock in a human readable string.
675
The string should not be free()'d or modified.
681
const lock_t* lock); /*!< in: lock */
683
/*******************************************************************//**
684
Gets the type of a lock in a human readable string.
685
The string should not be free()'d or modified.
691
const lock_t* lock); /*!< in: lock */
693
/*******************************************************************//**
694
Gets the id of the table on which the lock is.
695
@return id of the table */
700
const lock_t* lock); /*!< in: lock */
702
/*******************************************************************//**
703
Gets the name of the table on which the lock is.
704
The string should not be free()'d or modified.
705
@return name of the table */
710
const lock_t* lock); /*!< in: lock */
712
/*******************************************************************//**
713
For a record lock, gets the index on which the lock is.
719
const lock_t* lock); /*!< in: lock */
721
/*******************************************************************//**
722
For a record lock, gets the name of the index on which the lock is.
723
The string should not be free()'d or modified.
724
@return name of the index */
727
lock_rec_get_index_name(
728
/*====================*/
729
const lock_t* lock); /*!< in: lock */
731
/*******************************************************************//**
732
For a record lock, gets the tablespace number on which the lock is.
733
@return tablespace number */
736
lock_rec_get_space_id(
737
/*==================*/
738
const lock_t* lock); /*!< in: lock */
740
/*******************************************************************//**
741
For a record lock, gets the page number on which the lock is.
742
@return page number */
745
lock_rec_get_page_no(
746
/*=================*/
747
const lock_t* lock); /*!< in: lock */
749
/** Lock modes and types */
751
#define LOCK_MODE_MASK 0xFUL /*!< mask used to extract mode from the
752
type_mode field in a lock */
755
#define LOCK_TABLE 16 /*!< table lock */
756
#define LOCK_REC 32 /*!< record lock */
757
#define LOCK_TYPE_MASK 0xF0UL /*!< mask used to extract lock type from the
758
type_mode field in a lock */
759
#if LOCK_MODE_MASK & LOCK_TYPE_MASK
760
# error "LOCK_MODE_MASK & LOCK_TYPE_MASK"
763
#define LOCK_WAIT 256 /*!< Waiting lock flag; when set, it
764
means that the lock has not yet been
765
granted, it is just waiting for its
766
turn in the wait queue */
768
#define LOCK_ORDINARY 0 /*!< this flag denotes an ordinary
769
next-key lock in contrast to LOCK_GAP
770
or LOCK_REC_NOT_GAP */
771
#define LOCK_GAP 512 /*!< when this bit is set, it means that the
772
lock holds only on the gap before the record;
773
for instance, an x-lock on the gap does not
774
give permission to modify the record on which
775
the bit is set; locks of this type are created
776
when records are removed from the index chain
778
#define LOCK_REC_NOT_GAP 1024 /*!< this bit means that the lock is only on
779
the index record and does NOT block inserts
780
to the gap before the index record; this is
781
used in the case when we retrieve a record
782
with a unique key, and is also used in
783
locking plain SELECTs (not part of UPDATE
784
or DELETE) when the user has set the READ
785
COMMITTED isolation level */
786
#define LOCK_INSERT_INTENTION 2048 /*!< this bit is set when we place a waiting
787
gap type record lock request in order to let
788
an insert of an index record to wait until
789
there are no conflicting locks by other
790
transactions on the gap; note that this flag
791
remains set when the waiting lock is granted,
792
or if the lock is inherited to a neighboring
794
#if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_MODE_MASK
797
#if (LOCK_WAIT|LOCK_GAP|LOCK_REC_NOT_GAP|LOCK_INSERT_INTENTION)&LOCK_TYPE_MASK
802
/** Lock operation struct */
803
typedef struct lock_op_struct lock_op_t;
804
/** Lock operation struct */
805
struct lock_op_struct{
806
dict_table_t* table; /*!< table to be locked */
807
enum lock_mode mode; /*!< lock mode */
810
/** The lock system struct */
811
struct lock_sys_struct{
812
hash_table_t* rec_hash; /*!< hash table of the record locks */
815
/** The lock system */
816
extern lock_sys_t* lock_sys;
820
#include "lock0lock.ic"