MySQL 5.6.14 Source Code Document
|
#include "univ.i"
#include "buf0types.h"
#include "trx0types.h"
#include "mtr0types.h"
#include "rem0types.h"
#include "dict0types.h"
#include "que0types.h"
#include "lock0types.h"
#include "read0types.h"
#include "hash0hash.h"
#include "srv0srv.h"
#include "ut0vec.h"
#include "lock0lock.ic"
Go to the source code of this file.
Classes | |
struct | lock_op_t |
struct | lock_sys_t |
Macros | |
#define | lock_is_wait_not_by_other(type_mode) ((type_mode & (LOCK_CONV_BY_OTHER | LOCK_WAIT)) == LOCK_WAIT) |
#define | lock_mutex_enter_nowait() mutex_enter_nowait(&lock_sys->mutex) |
#define | lock_mutex_own() mutex_own(&lock_sys->mutex) |
#define | lock_mutex_enter() |
#define | lock_mutex_exit() |
#define | lock_wait_mutex_own() mutex_own(&lock_sys->wait_mutex) |
#define | lock_wait_mutex_enter() |
#define | lock_wait_mutex_exit() |
#define | LOCK_MODE_MASK 0xFUL |
#define | LOCK_TABLE 16 |
#define | LOCK_REC 32 |
#define | LOCK_TYPE_MASK 0xF0UL |
#define | LOCK_WAIT 256 |
#define | LOCK_ORDINARY 0 |
#define | LOCK_GAP 512 |
#define | LOCK_REC_NOT_GAP 1024 |
#define | LOCK_INSERT_INTENTION 2048 |
#define | LOCK_CONV_BY_OTHER 4096 |
Functions | |
UNIV_INTERN ulint | lock_get_size (void) |
UNIV_INTERN void | lock_sys_create (ulint n_cells) |
UNIV_INTERN void | lock_sys_close (void) |
UNIV_INLINE ulint | lock_get_min_heap_no (const buf_block_t *block) |
UNIV_INTERN void | lock_move_reorganize_page (const buf_block_t *block, const buf_block_t *oblock) |
UNIV_INTERN void | lock_move_rec_list_end (const buf_block_t *new_block, const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_move_rec_list_start (const buf_block_t *new_block, const buf_block_t *block, const rec_t *rec, const rec_t *old_end) |
UNIV_INTERN void | lock_update_split_right (const buf_block_t *right_block, const buf_block_t *left_block) |
UNIV_INTERN void | lock_update_merge_right (const buf_block_t *right_block, const rec_t *orig_succ, const buf_block_t *left_block) |
UNIV_INTERN void | lock_update_root_raise (const buf_block_t *block, const buf_block_t *root) |
UNIV_INTERN void | lock_update_copy_and_discard (const buf_block_t *new_block, const buf_block_t *block) |
UNIV_INTERN void | lock_update_split_left (const buf_block_t *right_block, const buf_block_t *left_block) |
UNIV_INTERN void | lock_update_merge_left (const buf_block_t *left_block, const rec_t *orig_pred, const buf_block_t *right_block) |
UNIV_INTERN void | lock_rec_reset_and_inherit_gap_locks (const buf_block_t *heir_block, const buf_block_t *block, ulint heir_heap_no, ulint heap_no) |
UNIV_INTERN void | lock_update_discard (const buf_block_t *heir_block, ulint heir_heap_no, const buf_block_t *block) |
UNIV_INTERN void | lock_update_insert (const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_update_delete (const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_rec_store_on_page_infimum (const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_rec_restore_from_page_infimum (const buf_block_t *block, const rec_t *rec, const buf_block_t *donator) |
UNIV_INTERN lock_t * | lock_rec_expl_exist_on_page (ulint space, ulint page_no) __attribute__((warn_unused_result)) |
UNIV_INTERN dberr_t | lock_rec_insert_check_and_lock (ulint flags, const rec_t *rec, buf_block_t *block, dict_index_t *index, que_thr_t *thr, mtr_t *mtr, ibool *inherit) __attribute__((nonnull |
UNIV_INTERN dberr_t | lock_clust_rec_modify_check_and_lock (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, const ulint *offsets, que_thr_t *thr) __attribute__((warn_unused_result |
UNIV_INTERN dberr_t | lock_sec_rec_modify_check_and_lock (ulint flags, buf_block_t *block, const rec_t *rec, dict_index_t *index, que_thr_t *thr, mtr_t *mtr) __attribute__((warn_unused_result |
UNIV_INTERN dberr_t | nonnull (2, 3, 4, 6))) |
UNIV_INTERN dberr_t | lock_sec_rec_read_check_and_lock (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, const ulint *offsets, enum lock_mode mode, ulint gap_mode, que_thr_t *thr) |
UNIV_INTERN dberr_t | lock_clust_rec_read_check_and_lock (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, const ulint *offsets, enum lock_mode mode, ulint gap_mode, que_thr_t *thr) |
UNIV_INTERN dberr_t | lock_clust_rec_read_check_and_lock_alt (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, enum lock_mode mode, ulint gap_mode, que_thr_t *thr) __attribute__((nonnull |
UNIV_INTERN bool | lock_clust_rec_cons_read_sees (const rec_t *rec, dict_index_t *index, const ulint *offsets, read_view_t *view) |
UNIV_INTERN bool | lock_sec_rec_cons_read_sees (const rec_t *rec, const read_view_t *view) __attribute__((nonnull |
UNIV_INTERN dberr_t | lock_table (ulint flags, dict_table_t *table, enum lock_mode mode, que_thr_t *thr) __attribute__((nonnull |
UNIV_INTERN void | lock_table_ix_resurrect (dict_table_t *table, trx_t *trx) |
UNIV_INTERN void | lock_rec_unlock (trx_t *trx, const buf_block_t *block, const rec_t *rec, enum lock_mode lock_mode) |
UNIV_INTERN void | lock_trx_release_locks (trx_t *trx) |
UNIV_INTERN void | lock_remove_all_on_table (dict_table_t *table, ibool remove_also_table_sx_locks) |
UNIV_INLINE ulint | lock_rec_fold (ulint space, ulint page_no) __attribute__((const )) |
UNIV_INLINE ulint | lock_rec_hash (ulint space, ulint page_no) |
UNIV_INTERN ulint | lock_rec_find_set_bit (const lock_t *lock) |
UNIV_INTERN dict_table_t * | lock_get_src_table (trx_t *trx, dict_table_t *dest, enum lock_mode *mode) |
UNIV_INTERN ibool | lock_is_table_exclusive (const dict_table_t *table, const trx_t *trx) __attribute__((nonnull)) |
UNIV_INTERN ibool | lock_has_to_wait (const lock_t *lock1, const lock_t *lock2) |
UNIV_INTERN void | lock_report_trx_id_insanity (trx_id_t trx_id, const rec_t *rec, dict_index_t *index, const ulint *offsets, trx_id_t max_trx_id) __attribute__((nonnull)) |
UNIV_INTERN void | lock_table_print (FILE *file, const lock_t *lock) |
UNIV_INTERN void | lock_rec_print (FILE *file, const lock_t *lock) |
UNIV_INTERN ibool | lock_print_info_summary (FILE *file, ibool nowait) __attribute__((nonnull |
UNIV_INTERN void | lock_print_info_all_transactions (FILE *file) |
UNIV_INTERN ulint | lock_number_of_rows_locked (const trx_lock_t *trx_lock) __attribute__((nonnull |
UNIV_INTERN ulint | lock_get_type (const lock_t *lock) |
UNIV_INTERN trx_id_t | lock_get_trx_id (const lock_t *lock) |
UNIV_INTERN const char * | lock_get_mode_str (const lock_t *lock) |
UNIV_INTERN const char * | lock_get_type_str (const lock_t *lock) |
UNIV_INTERN table_id_t | lock_get_table_id (const lock_t *lock) |
UNIV_INTERN const char * | lock_get_table_name (const lock_t *lock) |
UNIV_INTERN const dict_index_t * | lock_rec_get_index (const lock_t *lock) |
UNIV_INTERN const char * | lock_rec_get_index_name (const lock_t *lock) |
UNIV_INTERN ulint | lock_rec_get_space_id (const lock_t *lock) |
UNIV_INTERN ulint | lock_rec_get_page_no (const lock_t *lock) |
UNIV_INTERN ibool | lock_table_has_locks (const dict_table_t *table) |
UNIV_INTERN os_thread_ret_t DECLARE_THREAD() | lock_wait_timeout_thread (void *arg) |
UNIV_INTERN void | lock_wait_release_thread_if_suspended (que_thr_t *thr) |
UNIV_INTERN void | lock_wait_suspend_thread (que_thr_t *thr) |
UNIV_INTERN void | lock_unlock_table_autoinc (trx_t *trx) |
UNIV_INTERN dberr_t | lock_trx_handle_wait (trx_t *trx) __attribute__((nonnull)) |
UNIV_INTERN ulint | lock_table_get_n_locks (const dict_table_t *table) __attribute__((nonnull)) |
Variables | |
UNIV_INTERN dberr_t | warn_unused_result |
UNIV_INTERN dberr_t | nonnull |
lock_sys_t * | lock_sys |
#define LOCK_CONV_BY_OTHER 4096 |
this bit is set when the lock is created by other transaction
Definition at line 895 of file lock0lock.h.
#define LOCK_GAP 512 |
when this bit is set, it means that the lock holds only on the gap before the record; for instance, an x-lock on the gap does not give permission to modify the record on which the bit is set; locks of this type are created when records are removed from the index chain of records
Definition at line 872 of file lock0lock.h.
#define LOCK_INSERT_INTENTION 2048 |
this bit is set when we place a waiting gap type record lock request in order to let an insert of an index record to wait until there are no conflicting locks by other transactions on the gap; note that this flag remains set when the waiting lock is granted, or if the lock is inherited to a neighboring record
Definition at line 887 of file lock0lock.h.
#define lock_is_wait_not_by_other | ( | type_mode | ) | ((type_mode & (LOCK_CONV_BY_OTHER | LOCK_WAIT)) == LOCK_WAIT) |
Checks if this is a waiting lock created by lock->trx itself.
type_mode | lock->type_mode |
Definition at line 908 of file lock0lock.h.
#define LOCK_MODE_MASK 0xFUL |
Lock modes and types mask used to extract mode from the type_mode field in a lock
Definition at line 852 of file lock0lock.h.
#define lock_mutex_enter | ( | ) |
Acquire the lock_sys->mutex.
Definition at line 960 of file lock0lock.h.
#define lock_mutex_enter_nowait | ( | ) | mutex_enter_nowait(&lock_sys->mutex) |
Test if lock_sys->mutex can be acquired without waiting.
Definition at line 954 of file lock0lock.h.
#define lock_mutex_exit | ( | ) |
Release the lock_sys->mutex.
Definition at line 965 of file lock0lock.h.
#define lock_mutex_own | ( | ) | mutex_own(&lock_sys->mutex) |
Test if lock_sys->mutex is owned.
Definition at line 957 of file lock0lock.h.
#define LOCK_ORDINARY 0 |
this flag denotes an ordinary next-key lock in contrast to LOCK_GAP or LOCK_REC_NOT_GAP
Definition at line 869 of file lock0lock.h.
#define LOCK_REC 32 |
record lock
Definition at line 857 of file lock0lock.h.
#define LOCK_REC_NOT_GAP 1024 |
this bit means that the lock is only on the index record and does NOT block inserts to the gap before the index record; this is used in the case when we retrieve a record with a unique key, and is also used in locking plain SELECTs (not part of UPDATE or DELETE) when the user has set the READ COMMITTED isolation level
Definition at line 879 of file lock0lock.h.
#define LOCK_TABLE 16 |
Lock types table lock
Definition at line 856 of file lock0lock.h.
#define LOCK_TYPE_MASK 0xF0UL |
mask used to extract lock type from the type_mode field in a lock
Definition at line 858 of file lock0lock.h.
#define LOCK_WAIT 256 |
Waiting lock flag; when set, it means that the lock has not yet been granted, it is just waiting for its turn in the wait queue
Definition at line 864 of file lock0lock.h.
#define lock_wait_mutex_enter | ( | ) |
Acquire the lock_sys->wait_mutex.
Definition at line 973 of file lock0lock.h.
#define lock_wait_mutex_exit | ( | ) |
Release the lock_sys->wait_mutex.
Definition at line 978 of file lock0lock.h.
#define lock_wait_mutex_own | ( | ) | mutex_own(&lock_sys->wait_mutex) |
Test if lock_sys->wait_mutex is owned.
Definition at line 970 of file lock0lock.h.
UNIV_INTERN bool lock_clust_rec_cons_read_sees | ( | const rec_t * | rec, |
dict_index_t * | index, | ||
const ulint * | offsets, | ||
read_view_t * | view | ||
) |
Checks that a record is seen in a consistent read.
Checks that a record is seen in a consistent read.
rec | in: user record which should be read or passed over by a read cursor |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
view | in: consistent read view |
Definition at line 526 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_clust_rec_modify_check_and_lock | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
que_thr_t * | thr | ||
) |
Checks if locks of other transactions prevent an immediate modify (update, delete mark, or delete unmark) of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record x-lock to the lock queue.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: record which should be modified |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
thr | in: query thread |
UNIV_INTERN dberr_t lock_clust_rec_read_check_and_lock | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
enum lock_mode | mode, | ||
ulint | gap_mode, | ||
que_thr_t * | thr | ||
) |
Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record.
Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: user record or page supremum record which should be read or passed over by a read cursor |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
mode | in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE |
gap_mode | in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP |
thr | in: query thread |
Definition at line 6320 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_clust_rec_read_check_and_lock_alt | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
enum lock_mode | mode, | ||
ulint | gap_mode, | ||
que_thr_t * | thr | ||
) |
Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record. This is an alternative version of lock_clust_rec_read_check_and_lock() that does not require the parameter "offsets".
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: user record or page supremum record which should be read or passed over by a read cursor |
index | in: clustered index |
mode | in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE |
gap_mode | in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP |
thr | in: query thread |
UNIV_INLINE ulint lock_get_min_heap_no | ( | const buf_block_t * | block | ) |
Gets the heap_no of the smallest user record on a page.
UNIV_INTERN const char* lock_get_mode_str | ( | const lock_t * | lock | ) |
Gets the mode of a lock in a human readable string. The string should not be free()'d or modified.
Gets the mode of a lock in a human readable string. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6537 of file lock0lock.cc.
UNIV_INTERN ulint lock_get_size | ( | void | ) |
Gets the size of a lock struct.
Definition at line 653 of file lock0lock.cc.
UNIV_INTERN dict_table_t* lock_get_src_table | ( | trx_t * | trx, |
dict_table_t * | dest, | ||
enum lock_mode * | mode | ||
) |
Gets the source table of an ALTER TABLE transaction. The table must be covered by an IX or IS table lock.
Gets the source table of an ALTER TABLE transaction. The table must be covered by an IX or IS table lock.
trx | in: transaction |
dest | in: destination of ALTER TABLE |
mode | out: lock mode of the source table |
Definition at line 696 of file lock0lock.cc.
UNIV_INTERN table_id_t lock_get_table_id | ( | const lock_t * | lock | ) |
Gets the id of the table on which the lock is.
Gets the id of the table on which the lock is.
lock | in: lock |
Definition at line 6625 of file lock0lock.cc.
UNIV_INTERN const char* lock_get_table_name | ( | const lock_t * | lock | ) |
Gets the name of the table on which the lock is. The string should not be free()'d or modified.
Gets the name of the table on which the lock is. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6642 of file lock0lock.cc.
Gets the id of the transaction owning a lock.
Gets the id of the transaction owning a lock.
lock | in: lock |
Definition at line 6524 of file lock0lock.cc.
UNIV_INTERN ulint lock_get_type | ( | const lock_t * | lock | ) |
Gets the type of a lock. Non-inline version for using outside of the lock module.
Gets the type of a lock. Non-inline version for using outside of the lock module.
lock | in: lock |
Definition at line 6512 of file lock0lock.cc.
UNIV_INTERN const char* lock_get_type_str | ( | const lock_t * | lock | ) |
Gets the type of a lock in a human readable string. The string should not be free()'d or modified.
Gets the type of a lock in a human readable string. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6584 of file lock0lock.cc.
Checks if a lock request lock1 has to wait for request lock2.
Checks if a lock request lock1 has to wait for request lock2.
lock1 | in: waiting lock |
lock2 | in: another lock; NOTE that it is assumed that this has a lock bit set on the same record as in lock1 if the locks are record locks |
Definition at line 1034 of file lock0lock.cc.
UNIV_INTERN ibool lock_is_table_exclusive | ( | const dict_table_t * | table, |
const trx_t * | trx | ||
) |
Determine if the given table is exclusively "owned" by the given transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC on the table.
table | in: table |
trx | in: transaction |
Definition at line 779 of file lock0lock.cc.
UNIV_INTERN void lock_move_rec_list_end | ( | const buf_block_t * | new_block, |
const buf_block_t * | block, | ||
const rec_t * | rec | ||
) |
Moves the explicit locks on user records to another page if a record list end is moved to another page. in: record on page: this is the first record moved
Moves the explicit locks on user records to another page if a record list end is moved to another page.
new_block | in: index page to move to |
block | in: index page |
rec | in: record on page: this is the first record moved |
Definition at line 2886 of file lock0lock.cc.
UNIV_INTERN void lock_move_rec_list_start | ( | const buf_block_t * | new_block, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
const rec_t * | old_end | ||
) |
Moves the explicit locks on user records to another page if a record list start is moved to another page. in: old previous-to-last record on new_page before the records were copied
Moves the explicit locks on user records to another page if a record list start is moved to another page.
new_block | in: index page to move to |
block | in: index page |
rec | in: record on page: this is the first record NOT copied |
old_end | in: old previous-to-last record on new_page before the records were copied |
Definition at line 2975 of file lock0lock.cc.
UNIV_INTERN void lock_move_reorganize_page | ( | const buf_block_t * | block, |
const buf_block_t * | oblock | ||
) |
Updates the lock table when we have reorganized a page. NOTE: we copy also the locks set on the infimum of the page; the infimum may carry locks if an update of a record is occurring on the page, and its locks were temporarily stored on the infimum. in: copy of the old, not reorganized page
Updates the lock table when we have reorganized a page. NOTE: we copy also the locks set on the infimum of the page; the infimum may carry locks if an update of a record is occurring on the page, and its locks were temporarily stored on the infimum.
block | in: old index page, now reorganized |
oblock | in: copy of the old, not reorganized page |
Definition at line 2740 of file lock0lock.cc.
UNIV_INTERN ulint lock_number_of_rows_locked | ( | const trx_lock_t * | trx_lock | ) |
Return approximate number or record locks (bits set in the bitmap) for this transaction. Since delete-marked records may be removed, the record count will not be precise. The caller must be holding lock_sys->mutex.
trx_lock | in: transaction locks |
UNIV_INTERN void lock_print_info_all_transactions | ( | FILE * | file | ) |
Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock mutex on behalf of the caller. (This should be fixed in the future). in: file where to print
Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock mutex on behalf of the caller. (This should be fixed in the future).
file | in: file where to print |
Definition at line 5223 of file lock0lock.cc.
UNIV_INTERN ibool lock_print_info_summary | ( | FILE * | file, |
ibool | nowait | ||
) |
Prints info of locks for all transactions.
file | in: file where to print |
nowait | in: whether to wait for the lock mutex |
UNIV_INTERN lock_t* lock_rec_expl_exist_on_page | ( | ulint | space, |
ulint | page_no | ||
) |
Determines if there are explicit record locks on a page.
space | in: space id |
page_no | in: page number |
Definition at line 1232 of file lock0lock.cc.
UNIV_INTERN ulint lock_rec_find_set_bit | ( | const lock_t * | lock | ) |
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, if none found.
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, if none found.
lock | in: record lock with at least one bit set |
Definition at line 1108 of file lock0lock.cc.
UNIV_INLINE ulint lock_rec_fold | ( | ulint | space, |
ulint | page_no | ||
) | const |
Calculates the fold value of a page file address: used in inserting or searching for a lock in the hash table.
space | in: space |
page_no | in: page number |
UNIV_INTERN const dict_index_t* lock_rec_get_index | ( | const lock_t * | lock | ) |
For a record lock, gets the index on which the lock is.
For a record lock, gets the index on which the lock is.
lock | in: lock |
Definition at line 6658 of file lock0lock.cc.
UNIV_INTERN const char* lock_rec_get_index_name | ( | const lock_t * | lock | ) |
For a record lock, gets the name of the index on which the lock is. The string should not be free()'d or modified.
For a record lock, gets the name of the index on which the lock is. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6675 of file lock0lock.cc.
UNIV_INTERN ulint lock_rec_get_page_no | ( | const lock_t * | lock | ) |
For a record lock, gets the page number on which the lock is.
For a record lock, gets the page number on which the lock is.
lock | in: lock |
Definition at line 6705 of file lock0lock.cc.
UNIV_INTERN ulint lock_rec_get_space_id | ( | const lock_t * | lock | ) |
For a record lock, gets the tablespace number on which the lock is.
For a record lock, gets the tablespace number on which the lock is.
lock | in: lock |
Definition at line 6691 of file lock0lock.cc.
UNIV_INLINE ulint lock_rec_hash | ( | ulint | space, |
ulint | page_no | ||
) |
Calculates the hash value of a page file address: used in inserting or searching for a lock in the hash table.
space | in: space |
UNIV_INTERN dberr_t lock_rec_insert_check_and_lock | ( | ulint | flags, |
const rec_t * | rec, | ||
buf_block_t * | block, | ||
dict_index_t * | index, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr, | ||
ibool * | inherit | ||
) |
Checks if locks of other transactions prevent an immediate insert of a record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a gap x-lock to the lock queue.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
rec | in: record after which to insert |
block | in/out: buffer block of rec |
index | in: index |
thr | in: query thread |
mtr | in/out: mini-transaction |
inherit | out: set to TRUE if the new inserted record maybe should inherit LOCK_GAP type locks from the successor record |
UNIV_INTERN void lock_rec_print | ( | FILE * | file, |
const lock_t * | lock | ||
) |
Prints info of a record lock. in: record type lock
Prints info of a record lock.
file | in: file where to print |
lock | in: record type lock |
Definition at line 5005 of file lock0lock.cc.
UNIV_INTERN void lock_rec_reset_and_inherit_gap_locks | ( | const buf_block_t * | heir_block, |
const buf_block_t * | block, | ||
ulint | heir_heap_no, | ||
ulint | heap_no | ||
) |
Resets the original locks on heir and replaces them with gap type locks inherited from rec. in: heap_no of the donating record
Resets the original locks on heir and replaces them with gap type locks inherited from rec.
heir_block | in: block containing the record which inherits |
block | in: block containing the record from which inherited; does NOT reset the locks on this record |
heir_heap_no | in: heap_no of the inheriting record |
heap_no | in: heap_no of the donating record |
Definition at line 3268 of file lock0lock.cc.
UNIV_INTERN void lock_rec_restore_from_page_infimum | ( | const buf_block_t * | block, |
const rec_t * | rec, | ||
const buf_block_t * | donator | ||
) |
Restores the state of explicit lock requests on a single record, where the state was stored on the infimum of the page. in: page (rec is not necessarily on this page) whose infimum stored the lock state; lock bits are reset on the infimum
Restores the state of explicit lock requests on a single record, where the state was stored on the infimum of the page.
block | in: buffer block containing rec |
rec | in: record whose lock state is restored |
donator | in: page (rec is not necessarily on this page) whose infimum stored the lock state; lock bits are reset on the infimum |
Definition at line 3458 of file lock0lock.cc.
UNIV_INTERN void lock_rec_store_on_page_infimum | ( | const buf_block_t * | block, |
const rec_t * | rec | ||
) |
Stores on the page infimum record the explicit locks of another record. This function is used to store the lock state of a record when it is updated and the size of the record changes in the update. The record is in such an update moved, perhaps to another page. The infimum record acts as a dummy carrier record, taking care of lock releases while the actual record is being moved. in: record whose lock state is stored on the infimum record of the same page; lock bits are reset on the record
Stores on the page infimum record the explicit locks of another record. This function is used to store the lock state of a record when it is updated and the size of the record changes in the update. The record is moved in such an update, perhaps to another page. The infimum record acts as a dummy carrier record, taking care of lock releases while the actual record is being moved.
block | in: buffer block containing rec |
rec | in: record whose lock state is stored on the infimum record of the same page; lock bits are reset on the record |
Definition at line 3433 of file lock0lock.cc.
UNIV_INTERN void lock_rec_unlock | ( | trx_t * | trx, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
enum lock_mode lock_mode | |||
) |
Removes a granted record lock of a transaction from the queue and grants locks to other transactions waiting in the queue if they now are entitled to a lock. in: LOCK_S or LOCK_X
Removes a granted record lock of a transaction from the queue and grants locks to other transactions waiting in the queue if they now are entitled to a lock.
trx | in/out: transaction that has set a record lock |
block | in: buffer block containing rec |
rec | in: record |
Definition at line 4541 of file lock0lock.cc.
UNIV_INTERN void lock_remove_all_on_table | ( | dict_table_t * | table, |
ibool | remove_also_table_sx_locks | ||
) |
Removes locks on a table to be dropped or truncated. If remove_also_table_sx_locks is TRUE then table-level S and X locks are also removed in addition to other table-level and record-level locks. No lock, that is going to be removed, is allowed to be a wait lock. in: also removes table S and X locks
Removes locks on a table to be dropped or truncated. If remove_also_table_sx_locks is TRUE then table-level S and X locks are also removed in addition to other table-level and record-level locks. No lock, that is going to be removed, is allowed to be a wait lock.
table | in: table to be dropped or truncated |
remove_also_table_sx_locks | in: also removes table S and X locks |
Definition at line 4891 of file lock0lock.cc.
UNIV_INTERN void lock_report_trx_id_insanity | ( | trx_id_t | trx_id, |
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
trx_id_t | max_trx_id | ||
) |
Reports that a transaction id is insensible, i.e., in the future.
trx_id | in: trx id |
rec | in: user record |
index | in: index |
offsets | in: rec_get_offsets(rec, index) |
max_trx_id | in: trx_sys_get_max_trx_id() |
Definition at line 466 of file lock0lock.cc.
UNIV_INTERN bool lock_sec_rec_cons_read_sees | ( | const rec_t * | rec, |
const read_view_t * | view | ||
) |
Checks that a non-clustered index record is seen in a consistent read.
NOTE that a non-clustered index page contains so little information on its modifications that also in the case false, the present version of rec may be the right, but we must check this from the clustered index record.
rec | in: user record which should be read or passed over by a read cursor |
view | in: consistent read view |
UNIV_INTERN dberr_t lock_sec_rec_modify_check_and_lock | ( | ulint | flags, |
buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr | ||
) |
Checks if locks of other transactions prevent an immediate modify (delete mark or delete unmark) of a secondary index record.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in/out: buffer block of rec |
rec | in: record which should be modified; NOTE: as this is a secondary index, we always have to modify the clustered index record first: see the comment below |
index | in: secondary index |
thr | in: query thread (can be NULL if BTR_NO_LOCKING_FLAG) |
mtr | in/out: mini-transaction |
UNIV_INTERN dberr_t lock_sec_rec_read_check_and_lock | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
enum lock_mode | mode, | ||
ulint | gap_mode, | ||
que_thr_t * | thr | ||
) |
Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record.
Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: user record or page supremum record which should be read or passed over by a read cursor |
index | in: secondary index |
offsets | in: rec_get_offsets(rec, index) |
mode | in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE |
gap_mode | in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP |
thr | in: query thread |
Definition at line 6242 of file lock0lock.cc.
UNIV_INTERN void lock_sys_close | ( | void | ) |
Closes the lock system at database shutdown.
Definition at line 628 of file lock0lock.cc.
UNIV_INTERN void lock_sys_create | ( | ulint | n_cells | ) |
Creates the lock system at database start. in: number of slots in lock hash table
Creates the lock system at database start.
n_cells | in: number of slots in lock hash table |
Definition at line 589 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_table | ( | ulint | flags, |
dict_table_t * | table, | ||
enum lock_mode | mode, | ||
que_thr_t * | thr | ||
) |
Locks the specified database table in the mode given. If the lock cannot be granted immediately, the query thread is put to wait.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
table | in/out: database table in dictionary cache |
mode | in: lock mode |
thr | in: query thread |
UNIV_INTERN ulint lock_table_get_n_locks | ( | const dict_table_t * | table | ) |
Get the number of locks on a table.
table | in: table |
Definition at line 6897 of file lock0lock.cc.
UNIV_INTERN ibool lock_table_has_locks | ( | const dict_table_t * | table | ) |
Check if there are any locks (table or rec) against table.
Check if there are any locks (table or rec) against table.
table | in: check if there are any locks held on records in this table or on the table itself |
Definition at line 6971 of file lock0lock.cc.
UNIV_INTERN void lock_table_ix_resurrect | ( | dict_table_t * | table, |
trx_t * | trx | ||
) |
Creates a table IX lock object for a resurrected transaction. in/out: transaction
Creates a table IX lock object for a resurrected transaction.
table | in/out: table |
trx | in/out: transaction |
Definition at line 4440 of file lock0lock.cc.
UNIV_INTERN void lock_table_print | ( | FILE * | file, |
const lock_t * | lock | ||
) |
Prints info of a table lock. in: table type lock
Prints info of a table lock.
file | in: file where to print |
lock | in: table type lock |
Definition at line 4966 of file lock0lock.cc.
Check whether the transaction has already been rolled back because it was selected as a deadlock victim, or if it has to wait then cancel the wait lock.
trx | in/out: trx lock state |
Definition at line 6866 of file lock0lock.cc.
UNIV_INTERN void lock_trx_release_locks | ( | trx_t * | trx | ) |
Releases a transaction's locks, and releases possible other transactions waiting because of these locks. Change the state of the transaction to TRX_STATE_COMMITTED_IN_MEMORY. in/out: transaction
Releases a transaction's locks, and releases possible other transactions waiting because of these locks. Change the state of the transaction to TRX_STATE_COMMITTED_IN_MEMORY.
trx | in/out: transaction |
Definition at line 6797 of file lock0lock.cc.
UNIV_INTERN void lock_unlock_table_autoinc | ( | trx_t * | trx | ) |
Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd). in/out: transaction
Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd).
trx | in/out: transaction |
Definition at line 6766 of file lock0lock.cc.
UNIV_INTERN void lock_update_copy_and_discard | ( | const buf_block_t * | new_block, |
const buf_block_t * | block | ||
) |
Updates the lock table when a page is copied to another and the original page is removed from the chain of leaf pages, except if page is the root! in: index page; NOT the root!
Updates the lock table when a page is copied to another and the original page is removed from the chain of leaf pages, except if page is the root!
new_block | in: index page to which copied |
block | in: index page; NOT the root! |
Definition at line 3173 of file lock0lock.cc.
UNIV_INTERN void lock_update_delete | ( | const buf_block_t * | block, |
const rec_t * | rec | ||
) |
Updates the lock table when a record is removed. in: the record to be removed
Updates the lock table when a record is removed.
block | in: buffer block containing rec |
rec | in: the record to be removed |
Definition at line 3388 of file lock0lock.cc.
UNIV_INTERN void lock_update_discard | ( | const buf_block_t * | heir_block, |
ulint | heir_heap_no, | ||
const buf_block_t * | block | ||
) |
Updates the lock table when a page is discarded. in: index page which will be discarded
Updates the lock table when a page is discarded.
heir_block | in: index page which will inherit the locks |
heir_heap_no | in: heap_no of the record which will inherit the locks |
block | in: index page which will be discarded |
Definition at line 3294 of file lock0lock.cc.
UNIV_INTERN void lock_update_insert | ( | const buf_block_t * | block, |
const rec_t * | rec | ||
) |
Updates the lock table when a new user record is inserted. in: the inserted record
Updates the lock table when a new user record is inserted.
block | in: buffer block containing rec |
rec | in: the inserted record |
Definition at line 3357 of file lock0lock.cc.
UNIV_INTERN void lock_update_merge_left | ( | const buf_block_t * | left_block, |
const rec_t * | orig_pred, | ||
const buf_block_t * | right_block | ||
) |
Updates the lock table when a page is merged to the left. in: merged index page which will be discarded
Updates the lock table when a page is merged to the left.
left_block | in: left page to which merged |
orig_pred | in: original predecessor of supremum on the left page before merge |
right_block | in: merged index page which will be discarded |
Definition at line 3218 of file lock0lock.cc.
UNIV_INTERN void lock_update_merge_right | ( | const buf_block_t * | right_block, |
const rec_t * | orig_succ, | ||
const buf_block_t * | left_block | ||
) |
Updates the lock table when a page is merged to the right. in: merged index page which will be discarded
Updates the lock table when a page is merged to the right.
right_block | in: right page to which merged |
orig_succ | in: original successor of infimum on the right page before merge |
left_block | in: merged index page which will be discarded |
Definition at line 3111 of file lock0lock.cc.
UNIV_INTERN void lock_update_root_raise | ( | const buf_block_t * | block, |
const buf_block_t * | root | ||
) |
Updates the lock table when the root page is copied to another in btr_root_raise_and_insert. Note that we leave lock structs on the root page, even though they do not make sense on other than leaf pages: the reason is that in a pessimistic update the infimum record of the root page will act as a dummy carrier of the locks of the record to be updated. in: root page
Updates the lock table when the root page is copied to another in btr_root_raise_and_insert. Note that we leave lock structs on the root page, even though they do not make sense on other than leaf pages: the reason is that in a pessimistic update the infimum record of the root page will act as a dummy carrier of the locks of the record to be updated.
block | in: index page to which copied |
root | in: root page |
Definition at line 3153 of file lock0lock.cc.
UNIV_INTERN void lock_update_split_left | ( | const buf_block_t * | right_block, |
const buf_block_t * | left_block | ||
) |
Updates the lock table when a page is split to the left. in: left page
Updates the lock table when a page is split to the left.
right_block | in: right page |
left_block | in: left page |
Definition at line 3196 of file lock0lock.cc.
UNIV_INTERN void lock_update_split_right | ( | const buf_block_t * | right_block, |
const buf_block_t * | left_block | ||
) |
Updates the lock table when a page is split to the right. in: left page
Updates the lock table when a page is split to the right.
right_block | in: right page |
left_block | in: left page |
Definition at line 3083 of file lock0lock.cc.
UNIV_INTERN void lock_wait_release_thread_if_suspended | ( | que_thr_t * | thr | ) |
Releases a user OS thread waiting for a lock to be released, if the thread is already suspended. in: query thread associated with the user OS thread
Releases a user OS thread waiting for a lock to be released, if the thread is already suspended.
thr | in: query thread associated with the user OS thread |
Definition at line 395 of file lock0wait.cc.
UNIV_INTERN void lock_wait_suspend_thread | ( | que_thr_t * | thr | ) |
Puts a user OS thread to wait for a lock to be released. If an error occurs during the wait trx->error_state associated with thr is != DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK are possible errors. DB_DEADLOCK is returned if selective deadlock resolution chose this transaction as a victim. in: query thread associated with the user OS thread
Puts a user OS thread to wait for a lock to be released. If an error occurs during the wait trx->error_state associated with thr is != DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK are possible errors. DB_DEADLOCK is returned if selective deadlock resolution chose this transaction as a victim.
thr | in: query thread associated with the user OS thread |
Definition at line 195 of file lock0wait.cc.
UNIV_INTERN os_thread_ret_t DECLARE_THREAD() lock_wait_timeout_thread | ( | void * | arg | ) |
A thread which wakes up threads whose lock wait may have lasted too long.
lock_sys_t* lock_sys |
The lock system
Definition at line 414 of file lock0lock.cc.