MySQL 8.0.39
Source Code Documentation
|
The transaction lock system. More...
#include <set>
#include "btr0btr.h"
#include "dict0boot.h"
#include "dict0mem.h"
#include "ha_prototypes.h"
#include "lock0lock.h"
#include "lock0prdt.h"
#include "lock0priv.h"
#include "srv0mon.h"
#include "trx0purge.h"
#include "trx0sys.h"
#include "usr0sess.h"
#include "ut0vec.h"
Macros | |
#define | LOCK_MODULE_IMPLEMENTATION |
Functions | |
static rtr_mbr_t * | prdt_get_mbr_from_prdt (const lock_prdt_t *prdt) |
Get a minimum bounding box from a Predicate. More... | |
lock_prdt_t * | lock_get_prdt_from_lock (const lock_t *lock) |
Get a predicate from a lock. More... | |
static rtr_mbr_t * | lock_prdt_get_mbr_from_lock (const lock_t *lock) |
Get a minimum bounding box directly from a lock. More... | |
void | lock_prdt_set_prdt (lock_t *lock, const lock_prdt_t *prdt) |
Append a predicate to the lock. More... | |
static bool | lock_prdt_consistent (lock_prdt_t *prdt1, lock_prdt_t *prdt2, ulint op, const dd::Spatial_reference_system *srs) |
Check whether two predicate locks are compatible with each other. More... | |
bool | lock_prdt_has_to_wait (const trx_t *trx, ulint type_mode, lock_prdt_t *prdt, const lock_t *lock2) |
Checks if a predicate lock request for a new lock has to wait for another lock. More... | |
static lock_t * | lock_prdt_has_lock (ulint precise_mode, ulint type_mode, const buf_block_t *block, lock_prdt_t *prdt, const trx_t *trx) |
Checks if a transaction has a GRANTED stronger or equal predicate lock on the page. More... | |
static const lock_t * | lock_prdt_other_has_conflicting (ulint mode, const buf_block_t *block, lock_prdt_t *prdt, const trx_t *trx) |
Checks if some other transaction has a conflicting predicate lock request in the queue, so that we have to wait. More... | |
static void | lock_prdt_enlarge_mbr (const lock_t *lock, rtr_mbr_t *mbr) |
Reset the Minimum Bounding Rectangle (to a large area) More... | |
static void | lock_prdt_enlarge_prdt (lock_t *lock, lock_prdt_t *prdt) |
Reset the predicates to a "covering" (larger) predicates. More... | |
static bool | lock_prdt_is_same (lock_prdt_t *prdt1, lock_prdt_t *prdt2, const dd::Spatial_reference_system *srs) |
Check two predicates' MBRs are the same. More... | |
static lock_t * | lock_prdt_find_on_page (ulint type_mode, const buf_block_t *block, lock_prdt_t *prdt, const trx_t *trx) |
Looks for a similar predicate lock struct by the same trx on the same page. More... | |
static lock_t * | lock_prdt_add_to_queue (ulint type_mode, const buf_block_t *block, dict_index_t *index, trx_t *trx, lock_prdt_t *prdt) |
Adds a predicate lock request in the predicate lock queue. More... | |
dberr_t | lock_prdt_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, lock_prdt_t *prdt) |
Checks if locks of other transactions prevent an immediate insert of a predicate record. More... | |
void | lock_prdt_update_parent (buf_block_t *left_block, buf_block_t *right_block, lock_prdt_t *left_prdt, lock_prdt_t *right_prdt, const page_id_t &page_id) |
Adjust locks from an ancestor page of Rtree on the appropriate level . More... | |
static void | lock_prdt_update_split_low (buf_block_t *block, buf_block_t *new_block, lock_prdt_t *prdt, lock_prdt_t *new_prdt, ulint type_mode) |
Update predicate lock when page splits. More... | |
void | lock_prdt_update_split (buf_block_t *block, buf_block_t *new_block, lock_prdt_t *prdt, lock_prdt_t *new_prdt) |
Update predicate lock when page splits. More... | |
void | lock_init_prdt_from_mbr (lock_prdt_t *prdt, rtr_mbr_t *mbr, ulint mode, mem_heap_t *heap) |
Initiate a Predicate Lock from a MBR. More... | |
dberr_t | lock_prdt_lock (buf_block_t *block, lock_prdt_t *prdt, dict_index_t *index, lock_mode mode, ulint type_mode, que_thr_t *thr) |
Acquire a predicate lock on a block. More... | |
dberr_t | lock_place_prdt_page_lock (const page_id_t &page_id, dict_index_t *index, que_thr_t *thr) |
Acquire a "Page" lock on a block. More... | |
bool | lock_test_prdt_page_lock (const trx_t *trx, const page_id_t &page_id) |
Check whether there are no R-tree Page locks on a page by other transactions. More... | |
void | lock_prdt_rec_move (const buf_block_t *receiver, const buf_block_t *donator) |
Moves the locks of a page to another page and resets the lock bits of the donating records. More... | |
void | lock_prdt_page_free_from_discard (const buf_block_t *block, hash_table_t *lock_hash) |
Removes predicate lock objects set on an index page which is discarded. More... | |
The transaction lock system.
Created 9/7/2013 Jimmy Yang
#define LOCK_MODULE_IMPLEMENTATION |
lock_prdt_t * lock_get_prdt_from_lock | ( | const lock_t * | lock | ) |
Get a predicate from a lock.
Get predicate lock's minimum bounding box.
lock | in: the lock |
void lock_init_prdt_from_mbr | ( | lock_prdt_t * | prdt, |
rtr_mbr_t * | mbr, | ||
ulint | mode, | ||
mem_heap_t * | heap | ||
) |
Initiate a Predicate Lock from a MBR.
Initiate a Predicate lock from a MBR.
prdt | in/out: predicate to initialized |
mbr | in: Minimum Bounding Rectangle |
mode | in: Search mode |
heap | in: heap for allocating memory |
dberr_t lock_place_prdt_page_lock | ( | const page_id_t & | page_id, |
dict_index_t * | index, | ||
que_thr_t * | thr | ||
) |
Acquire a "Page" lock on a block.
[in] | page_id | id of the page to lock |
[in] | index | secondary index |
[in] | thr | query thread |
|
static |
Adds a predicate lock request in the predicate lock queue.
type_mode | in: lock mode, wait, predicate etc. flags; type is ignored and replaced by LOCK_REC |
block | in: buffer block containing the record |
index | in: index of record |
trx | in/out: transaction |
prdt | in: Minimum Bounding Rectangle the new lock will be on |
|
static |
Check whether two predicate locks are compatible with each other.
[in] | prdt1 | first predicate lock |
[in] | prdt2 | second predicate lock |
[in] | op | predicate comparison operator |
[in] | srs | Spatial reference system of R-tree |
Reset the Minimum Bounding Rectangle (to a large area)
lock | in/out: lock to modify |
mbr | in: Minimum Bounding Rectangle |
|
static |
Reset the predicates to a "covering" (larger) predicates.
lock | in/out: lock to modify |
prdt | in: predicate |
|
static |
Looks for a similar predicate lock struct by the same trx on the same page.
This can be used to save space when a new record lock should be set on a page: no new struct is needed, if a suitable old one is found.
type_mode | in: lock type_mode field |
block | in: buffer block |
prdt | in: MBR with the lock |
trx | in: transaction |
Get a minimum bounding box directly from a lock.
lock | in: the lock |
|
inlinestatic |
Checks if a transaction has a GRANTED stronger or equal predicate lock on the page.
precise_mode | in: LOCK_S or LOCK_X |
type_mode | in: LOCK_PREDICATE etc. |
block | in: buffer block containing the record |
prdt | in: The predicate to be attached to the new lock |
trx | in: transaction |
bool lock_prdt_has_to_wait | ( | const trx_t * | trx, |
ulint | type_mode, | ||
lock_prdt_t * | prdt, | ||
const lock_t * | lock2 | ||
) |
Checks if a predicate lock request for a new lock has to wait for another lock.
Checks if a predicate lock request for a new lock has to wait for request lock2.
trx | in: trx of new lock |
type_mode | in: precise mode of the new lock to set: LOCK_S or LOCK_X, possibly ORed to LOCK_PREDICATE or LOCK_PRDT_PAGE, LOCK_INSERT_INTENTION |
prdt | in: lock predicate to check |
lock2 | in: another record lock; NOTE that it is assumed that this has a lock bit set on the same record as in the new lock we are setting |
dberr_t lock_prdt_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, | ||
lock_prdt_t * | prdt | ||
) |
Checks if locks of other transactions prevent an immediate insert of a predicate record.
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 |
prdt | in: Predicates with Minimum Bound Rectangle |
|
static |
Check two predicates' MBRs are the same.
prdt1 | in: MBR with the lock |
prdt2 | in: MBR with the lock |
srs | in: SRS of R-tree |
dberr_t lock_prdt_lock | ( | buf_block_t * | block, |
lock_prdt_t * | prdt, | ||
dict_index_t * | index, | ||
lock_mode | mode, | ||
ulint | type_mode, | ||
que_thr_t * | thr | ||
) |
Acquire a predicate lock on a block.
block | in/out: buffer block of rec |
prdt | in: Predicate for the lock |
index | in: secondary 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 |
type_mode | in: LOCK_PREDICATE or LOCK_PRDT_PAGE |
thr | in: query thread (can be NULL if BTR_NO_LOCKING_FLAG) |
|
static |
Checks if some other transaction has a conflicting predicate lock request in the queue, so that we have to wait.
mode | in: LOCK_S or LOCK_X, possibly ORed to LOCK_PREDICATE or LOCK_PRDT_PAGE, LOCK_INSERT_INTENTION |
block | in: buffer block containing the record |
prdt | in: Predicates (currently) the Minimum Bounding Rectangle) the new lock will be on |
trx | in: our transaction |
void lock_prdt_page_free_from_discard | ( | const buf_block_t * | block, |
hash_table_t * | lock_hash | ||
) |
Removes predicate lock objects set on an index page which is discarded.
[in] | block | page to be discarded |
[in] | lock_hash | lock hash |
void lock_prdt_rec_move | ( | const buf_block_t * | receiver, |
const buf_block_t * | donator | ||
) |
Moves the locks of a page to another page and resets the lock bits of the donating records.
Moves the locks of a record to another record and resets the lock bits of the donating record.
receiver | in: buffer block containing the receiving record |
donator | in: buffer block containing the donating record |
void lock_prdt_set_prdt | ( | lock_t * | lock, |
const lock_prdt_t * | prdt | ||
) |
Append a predicate to the lock.
[in] | lock | Lock |
[in] | prdt | Predicate |
void lock_prdt_update_parent | ( | buf_block_t * | left_block, |
buf_block_t * | right_block, | ||
lock_prdt_t * | left_prdt, | ||
lock_prdt_t * | right_prdt, | ||
const page_id_t & | page_id | ||
) |
Adjust locks from an ancestor page of Rtree on the appropriate level .
Check whether any predicate lock in parent needs to propagate to child page after split.
[in,out] | left_block | page to be split |
[in,out] | right_block | the new half page |
[in] | left_prdt | MBR on the old page |
[in] | right_prdt | MBR on the new page |
[in] | page_id | the parent's page id |
void lock_prdt_update_split | ( | buf_block_t * | block, |
buf_block_t * | new_block, | ||
lock_prdt_t * | prdt, | ||
lock_prdt_t * | new_prdt | ||
) |
Update predicate lock when page splits.
[in,out] | block | page to be split |
[in,out] | new_block | the new half page |
[in] | prdt | MBR on the old page |
[in] | new_prdt | MBR on the new page |
|
static |
Update predicate lock when page splits.
[in,out] | block | page to be split |
[in,out] | new_block | the new half page |
[in] | prdt | MBR on the old page |
[in] | new_prdt | MBR on the new page |
[in] | type_mode | LOCK_PREDICATE or LOCK_PRDT_PAGE |
Check whether there are no R-tree Page locks on a page by other transactions.
[in] | trx | trx to test the lock |
[in] | page_id | id of the page |
true | if there is no lock |
false | if some transaction other than trx holds a page lock |
|
inlinestatic |
Get a minimum bounding box from a Predicate.
prdt | in: the lock predicate |