MySQL 9.1.0
Source Code Documentation
lock0prdt.h File Reference

The predicate lock system. More...

#include "lock0lock.h"
#include "univ.i"

Go to the source code of this file.

Classes

struct  lock_prdt
 

Typedefs

typedef struct lock_prdt lock_prdt_t
 

Functions

void lock_prdt_lock (buf_block_t *block, lock_prdt_t *prdt, dict_index_t *index, que_thr_t *thr)
 Acquires LOCK_S | LOCK_PREDICATE 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...
 
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...
 
lock_prdt_tlock_get_prdt_from_lock (const lock_t *lock)
 Get predicate lock's minimum bounding box. 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 request lock2. 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_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...
 
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_set_prdt (lock_t *lock, const lock_prdt_t *prdt)
 Append a predicate to the lock. More...
 
void lock_prdt_rec_move (const buf_block_t *receiver, const buf_block_t *donator)
 Moves the locks of a record to another record and resets the lock bits of the donating record. More...
 
bool lock_other_has_prdt_page_lock (const trx_t *trx, const page_id_t &page_id)
 Check whether there are R-tree Page locks on a page by other transactions. More...
 
void lock_prdt_page_free_from_discard (const buf_block_t *block, struct Locks_hashtable &lock_hash)
 Removes predicate lock objects set on an index page which is discarded. More...
 

Detailed Description

The predicate lock system.

Created 9/7/2013 Jimmy Yang

Typedef Documentation

◆ lock_prdt_t

typedef struct lock_prdt lock_prdt_t

Function Documentation

◆ lock_get_prdt_from_lock()

lock_prdt_t * lock_get_prdt_from_lock ( const lock_t lock)

Get predicate lock's minimum bounding box.

Returns
the minimum bounding box in: the lock

Get predicate lock's minimum bounding box.

Returns
the predicate
Parameters
lockin: the lock

◆ lock_init_prdt_from_mbr()

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.

in: heap for allocating memory

Initiate a Predicate lock from a MBR.

Parameters
prdtin/out: predicate to initialized
mbrin: Minimum Bounding Rectangle
modein: Search mode
heapin: heap for allocating memory

◆ lock_other_has_prdt_page_lock()

bool lock_other_has_prdt_page_lock ( const trx_t trx,
const page_id_t page_id 
)

Check whether there are R-tree Page locks on a page by other transactions.

Parameters
[in]trxtrx to test the lock
[in]page_idid of the page
Return values
falseif there is no lock
trueif some transaction other than trx holds a page lock

◆ lock_place_prdt_page_lock()

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.

Parameters
[in]page_idid of the page to lock
[in]indexsecondary index
[in]thrquery thread
Returns
DB_SUCCESS

◆ lock_prdt_has_to_wait()

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 request lock2.

Returns
true if new lock has to wait for lock2 to be removed 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

Checks if a predicate lock request for a new lock has to wait for request lock2.

Returns
true if new lock has to wait for lock2 to be released
Parameters
trxin: trx of new lock
type_modein: 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
prdtin: lock predicate to check
lock2in: 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

◆ lock_prdt_insert_check_and_lock()

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.

Returns
DB_SUCCESS, DB_LOCK_WAIT, or DB_DEADLOCK in: Minimum Bound Rectangle
DB_SUCCESS, DB_LOCK_WAIT, or DB_DEADLOCK
Parameters
flagsin: if BTR_NO_LOCKING_FLAG bit is set, does nothing
recin: record after which to insert
blockin/out: buffer block of rec
indexin: index
thrin: query thread
mtrin/out: mini-transaction
prdtin: Predicates with Minimum Bound Rectangle

◆ lock_prdt_lock()

void lock_prdt_lock ( buf_block_t block,
lock_prdt_t prdt,
dict_index_t index,
que_thr_t thr 
)

Acquires LOCK_S | LOCK_PREDICATE on a block.

Always succeeds, because it never has to wait, because their only purpose is to block conflicting LOCK_X | LOCK_PREDICATE | LOCK_INSERT_INTENTION into the locked area. (In other words they are conceptually similar to gap locks in regular indexes, which also never have to wait for similar reasons)

Parameters
[in]blockBuffer block containing the rec
[in]prdtPredicate for the lock
[in]indexSecondary index containing the block
[in]thrThe query thread requesting the lock

◆ lock_prdt_page_free_from_discard()

void lock_prdt_page_free_from_discard ( const buf_block_t block,
Locks_hashtable lock_hash 
)

Removes predicate lock objects set on an index page which is discarded.

Parameters
[in]blockpage to be discarded
[in]lock_hashlock hash

◆ lock_prdt_rec_move()

void lock_prdt_rec_move ( const buf_block_t receiver,
const buf_block_t donator 
)

Moves the locks of a record to another record and resets the lock bits of the donating record.

in: buffer block containing the donating record

Moves the locks of a record to another record and resets the lock bits of the donating record.

Parameters
receiverin: buffer block containing the receiving record
donatorin: buffer block containing the donating record

◆ lock_prdt_set_prdt()

void lock_prdt_set_prdt ( lock_t lock,
const lock_prdt_t prdt 
)

Append a predicate to the lock.

Parameters
[in]lockLock
[in]prdtPredicate

◆ lock_prdt_update_parent()

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.

Parameters
[in,out]left_blockpage to be split
[in,out]right_blockthe new half page
[in]left_prdtMBR on the old page
[in]right_prdtMBR on the new page
[in]page_idthe parent's page id

◆ lock_prdt_update_split()

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.

Parameters
[in,out]blockpage to be split
[in,out]new_blockthe new half page
[in]prdtMBR on the old page
[in]new_prdtMBR on the new page