MySQL 9.1.0
Source Code Documentation
RecLock Class Reference

Create record locks. More...

#include <lock0priv.h>

Public Member Functions

 RecLock (que_thr_t *thr, dict_index_t *index, const RecID &rec_id, ulint mode)
 
 RecLock (que_thr_t *thr, dict_index_t *index, const buf_block_t *block, ulint heap_no, ulint mode)
 
 RecLock (dict_index_t *index, const RecID &rec_id, ulint mode)
 
 RecLock (dict_index_t *index, const buf_block_t *block, ulint heap_no, ulint mode)
 
dberr_t add_to_waitq (const lock_t *wait_for, const lock_prdt_t *prdt=nullptr)
 Enqueue a lock wait for a transaction. More...
 
lock_tcreate (trx_t *trx, const lock_prdt_t *prdt=nullptr)
 Create a lock for a transaction and initialise it. More...
 

Static Public Member Functions

static lock_tlock_alloc (trx_t *trx, dict_index_t *index, ulint mode, const RecID &rec_id, ulint size)
 Create the lock instance. More...
 

Private Member Functions

size_t lock_size () const
 
void prepare () const
 Do some checks and prepare for creating a new record lock. More...
 
void set_wait_state (lock_t *lock)
 Setup the requesting transaction state for lock grant. More...
 
void lock_add (lock_t *lock)
 Add the lock to the record lock hash and the transaction's lock list. More...
 
void init (const page_t *page)
 Setup the context from the requirements. More...
 

Static Private Member Functions

static size_t lock_size (ulint mode)
 Calculate the record lock physical size required for a predicate lock. More...
 
static size_t lock_size (const page_t *page)
 Calculate the record lock physical size required, non-predicate lock. More...
 
static bool is_predicate_lock (ulint mode)
 

Private Attributes

que_thr_tm_thr
 The query thread of the transaction. More...
 
trx_tm_trx
 Transaction requesting the record lock. More...
 
ulint m_mode
 Lock mode requested. More...
 
size_t m_size
 Size of the record lock in bytes. More...
 
dict_index_tm_index
 Index on which the record lock is required. More...
 
RecID m_rec_id
 The record lock tuple {space, page_no, heap_no}. More...
 

Detailed Description

Create record locks.

Constructor & Destructor Documentation

◆ RecLock() [1/4]

RecLock::RecLock ( que_thr_t thr,
dict_index_t index,
const RecID rec_id,
ulint  mode 
)
inline
Parameters
[in,out]thrTransaction query thread requesting the record lock
[in]indexIndex on which record lock requested
[in]rec_idRecord lock tuple {space, page_no, heap_no}
[in]modeThe lock mode

◆ RecLock() [2/4]

RecLock::RecLock ( que_thr_t thr,
dict_index_t index,
const buf_block_t block,
ulint  heap_no,
ulint  mode 
)
inline
Parameters
[in,out]thrTransaction query thread requesting the record lock
[in]indexIndex on which record lock requested
[in]blockBuffer page containing record
[in]heap_noHeap number within the block
[in]modeThe lock mode

◆ RecLock() [3/4]

RecLock::RecLock ( dict_index_t index,
const RecID rec_id,
ulint  mode 
)
inline
Parameters
[in]indexIndex on which record lock requested
[in]rec_idRecord lock tuple {space, page_no, heap_no}
[in]modeThe lock mode

◆ RecLock() [4/4]

RecLock::RecLock ( dict_index_t index,
const buf_block_t block,
ulint  heap_no,
ulint  mode 
)
inline
Parameters
[in]indexIndex on which record lock requested
[in]blockBuffer page containing record
[in]heap_noHeap number within block
[in]modeThe lock mode

Member Function Documentation

◆ add_to_waitq()

dberr_t RecLock::add_to_waitq ( const lock_t wait_for,
const lock_prdt_t prdt = nullptr 
)

Enqueue a lock wait for a transaction.

If it is a high priority transaction (cannot rollback) then try to jump ahead in the record lock wait queue. Also check if async rollback was request for our trx.

Parameters
[in,out]wait_forThe lock that the the joining transaction is waiting for
[in]prdtPredicate [optional]
Returns
DB_LOCK_WAIT, DB_DEADLOCK, or DB_SUCCESS_LOCKED_REC
Return values
DB_DEADLOCKmeans that async rollback was requested for our trx
DB_SUCCESS_LOCKED_RECmeans that we are High Priority transaction and we've managed to jump in front of other waiting transactions and got the lock granted, so there is no need to wait.

◆ create()

lock_t * RecLock::create ( trx_t trx,
const lock_prdt_t prdt = nullptr 
)

Create a lock for a transaction and initialise it.

Parameters
[in,out]trxTransaction requesting the new lock
[in]prdtPredicate lock (optional)
Returns
new lock instance

◆ init()

void RecLock::init ( const page_t page)
inlineprivate

Setup the context from the requirements.

If rec is the supremum record, then we reset the gap and LOCK_REC_NOT_GAP bits, as all locks on the supremum are automatically of the gap type

◆ is_predicate_lock()

static bool RecLock::is_predicate_lock ( ulint  mode)
inlinestaticprivate
Returns
true if the requested lock mode is for a predicate or page lock

◆ lock_add()

void RecLock::lock_add ( lock_t lock)
private

Add the lock to the record lock hash and the transaction's lock list.

Parameters
[in,out]lockNewly created record lock to add to the rec hash and the transaction lock list

◆ lock_alloc()

lock_t * RecLock::lock_alloc ( trx_t trx,
dict_index_t index,
ulint  mode,
const RecID rec_id,
ulint  size 
)
static

Create the lock instance.

Parameters
[in,out]trxThe transaction requesting the lock
[in,out]indexIndex on which record lock is required
[in]modeThe lock mode desired
[in]rec_idThe record id
[in]sizeSize of the lock + bitmap requested
Returns
a record lock instance

◆ lock_size() [1/3]

size_t RecLock::lock_size ( ) const
inlineprivate

◆ lock_size() [2/3]

static size_t RecLock::lock_size ( const page_t page)
inlinestaticprivate

Calculate the record lock physical size required, non-predicate lock.

Parameters
[in]pageFor non-predicate locks the buffer page
Returns
the size of the lock data structure required in bytes

◆ lock_size() [3/3]

static size_t RecLock::lock_size ( ulint  mode)
inlinestaticprivate

Calculate the record lock physical size required for a predicate lock.

Parameters
[in]modeFor predicate locks the lock mode
Returns
the size of the lock data structure required in bytes

◆ prepare()

void RecLock::prepare ( ) const
private

Do some checks and prepare for creating a new record lock.

◆ set_wait_state()

void RecLock::set_wait_state ( lock_t lock)
private

Setup the requesting transaction state for lock grant.

Parameters
[in,out]lockLock for which to change state

Member Data Documentation

◆ m_index

dict_index_t* RecLock::m_index
private

Index on which the record lock is required.

◆ m_mode

ulint RecLock::m_mode
private

Lock mode requested.

◆ m_rec_id

RecID RecLock::m_rec_id
private

The record lock tuple {space, page_no, heap_no}.

◆ m_size

size_t RecLock::m_size
private

Size of the record lock in bytes.

◆ m_thr

que_thr_t* RecLock::m_thr
private

The query thread of the transaction.

◆ m_trx

trx_t* RecLock::m_trx
private

Transaction requesting the record lock.


The documentation for this class was generated from the following files: