Commit 68b28193 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Remove many C-style lock_get_ accessors

Let us prefer member functions to the old C-style accessor functions.
Also, prefer bitwise AND operations for checking multiple flags.
parent cbb0a60c
......@@ -516,15 +516,6 @@ lock_number_of_tables_locked(
const trx_lock_t* trx_lock) /*!< in: transaction locks */
MY_ATTRIBUTE((warn_unused_result));
/*******************************************************************//**
Gets the type of a lock. Non-inline version for using outside of the
lock module.
@return LOCK_TABLE or LOCK_REC */
ulint
lock_get_type(
/*==========*/
const lock_t* lock); /*!< in: lock */
/*******************************************************************//**
Gets the id of the table on which the lock is.
@return id of the table */
......
......@@ -541,15 +541,6 @@ lock_rec_get_first(
const buf_block_t* block, /*!< in: block containing the record */
ulint heap_no);/*!< in: heap number of the record */
/*********************************************************************//**
Gets the mode of a lock.
@return mode */
UNIV_INLINE
enum lock_mode
lock_get_mode(
/*==========*/
const lock_t* lock); /*!< in: lock */
/*********************************************************************//**
Calculates if lock mode 1 is compatible with lock mode 2.
@return nonzero if mode1 compatible with mode2 */
......@@ -570,15 +561,6 @@ lock_mode_stronger_or_eq(
enum lock_mode mode1, /*!< in: lock mode */
enum lock_mode mode2); /*!< in: lock mode */
/*********************************************************************//**
Gets the wait flag of a lock.
@return LOCK_WAIT if waiting, 0 if not */
UNIV_INLINE
ulint
lock_get_wait(
/*==========*/
const lock_t* lock); /*!< in: lock */
/*********************************************************************//**
Checks if a transaction has the specified table lock, or stronger. This
function should only be called by the thread that owns the transaction.
......
......@@ -104,7 +104,7 @@ lock_rec_get_next_on_page(
/*======================*/
lock_t* lock) /*!< in: a record lock */
{
return((lock_t*) lock_rec_get_next_on_page_const(lock));
return const_cast<lock_t*>(lock_rec_get_next_on_page_const(lock));
}
/*********************************************************************//**
......@@ -120,7 +120,6 @@ lock_rec_get_next(
lock_sys.mutex_assert_locked();
do {
ut_ad(!lock->is_table());
lock = lock_rec_get_next_on_page(lock);
} while (lock && !lock_rec_get_nth_bit(lock, heap_no));
......@@ -202,20 +201,6 @@ lock_rec_get_next_on_page_const(
return lock;
}
/*********************************************************************//**
Gets the mode of a lock.
@return mode */
UNIV_INLINE
enum lock_mode
lock_get_mode(
/*==========*/
const lock_t* lock) /*!< in: lock */
{
ut_ad(lock);
return(static_cast<enum lock_mode>(lock->type_mode & LOCK_MODE_MASK));
}
/*********************************************************************//**
Calculates if lock mode 1 is compatible with lock mode 2.
@return nonzero if mode1 compatible with mode2 */
......@@ -248,20 +233,6 @@ lock_mode_stronger_or_eq(
return(lock_strength_matrix[mode1][mode2]);
}
/*********************************************************************//**
Gets the wait flag of a lock.
@return LOCK_WAIT if waiting, 0 if not */
UNIV_INLINE
ulint
lock_get_wait(
/*==========*/
const lock_t* lock) /*!< in: lock */
{
ut_ad(lock);
return(lock->type_mode & LOCK_WAIT);
}
/*********************************************************************//**
Checks if a transaction has the specified table lock, or stronger. This
function should only be called by the thread that owns the transaction.
......@@ -285,22 +256,16 @@ lock_table_has(
continue;
}
lock_mode mode = lock_get_mode(lock);
ut_ad(trx == lock->trx);
ut_ad(lock->is_table());
ut_ad(lock->un_member.tab_lock.table);
if (table == lock->un_member.tab_lock.table
&& lock_mode_stronger_or_eq(mode, in_mode)) {
ut_ad(!lock_get_wait(lock));
&& lock_mode_stronger_or_eq(lock->mode(), in_mode)) {
ut_ad(!lock->is_waiting());
return(lock);
}
}
return(NULL);
}
/* vim: set filetype=c: */
......@@ -82,7 +82,7 @@ lock_queue_iterator_get_prev(
: UT_LIST_GET_PREV(un_member.tab_lock.locks, iter->current_lock);
if (prev_lock)
iter->current_lock = prev_lock;
iter->current_lock= prev_lock;
return prev_lock;
}
This diff is collapsed.
......@@ -175,7 +175,7 @@ lock_prdt_has_to_wait(
if (trx != lock2->trx
&& !lock_mode_compatible(static_cast<lock_mode>(
LOCK_MODE_MASK & type_mode),
lock_get_mode(lock2))) {
lock2->mode())) {
/* If it is a page lock, then return true (conflict) */
if (type_mode & LOCK_PRDT_PAGE) {
......@@ -249,17 +249,15 @@ lock_prdt_has_lock(
ut_ad(lock->type_mode & (LOCK_PREDICATE | LOCK_PRDT_PAGE));
if (lock->trx == trx
&& !(lock->type_mode & LOCK_INSERT_INTENTION)
&& !lock_get_wait(lock)
&& !(lock->type_mode & (LOCK_INSERT_INTENTION | LOCK_WAIT))
&& lock_mode_stronger_or_eq(
lock_get_mode(lock),
lock->mode(),
static_cast<lock_mode>(
precise_mode & LOCK_MODE_MASK))) {
if (lock->type_mode & LOCK_PRDT_PAGE) {
return(lock);
}
ut_ad(lock->type_mode & LOCK_PREDICATE);
lock_prdt_t* cur_prdt = lock_get_prdt_from_lock(
lock);
......@@ -459,9 +457,9 @@ lock_prdt_add_to_queue(
for (lock_t* lock = lock_sys.get_first(*lock_hash_get(type_mode), id);
lock; lock = lock_rec_get_next_on_page(lock)) {
if (lock_get_wait(lock)
&& lock_rec_get_nth_bit(lock, PRDT_HEAPNO)
&& lock->type_mode & (LOCK_PREDICATE | LOCK_PRDT_PAGE)) {
if (lock->is_waiting()
&& lock->type_mode & (LOCK_PREDICATE | LOCK_PRDT_PAGE)
&& lock_rec_get_nth_bit(lock, PRDT_HEAPNO)) {
goto create;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment