Skip to content

Commit 68b2819

Browse files
committed
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.
1 parent cbb0a60 commit 68b2819

File tree

6 files changed

+114
-253
lines changed

6 files changed

+114
-253
lines changed

storage/innobase/include/lock0lock.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,6 @@ lock_number_of_tables_locked(
516516
const trx_lock_t* trx_lock) /*!< in: transaction locks */
517517
MY_ATTRIBUTE((warn_unused_result));
518518

519-
/*******************************************************************//**
520-
Gets the type of a lock. Non-inline version for using outside of the
521-
lock module.
522-
@return LOCK_TABLE or LOCK_REC */
523-
ulint
524-
lock_get_type(
525-
/*==========*/
526-
const lock_t* lock); /*!< in: lock */
527-
528519
/*******************************************************************//**
529520
Gets the id of the table on which the lock is.
530521
@return id of the table */

storage/innobase/include/lock0priv.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -541,15 +541,6 @@ lock_rec_get_first(
541541
const buf_block_t* block, /*!< in: block containing the record */
542542
ulint heap_no);/*!< in: heap number of the record */
543543

544-
/*********************************************************************//**
545-
Gets the mode of a lock.
546-
@return mode */
547-
UNIV_INLINE
548-
enum lock_mode
549-
lock_get_mode(
550-
/*==========*/
551-
const lock_t* lock); /*!< in: lock */
552-
553544
/*********************************************************************//**
554545
Calculates if lock mode 1 is compatible with lock mode 2.
555546
@return nonzero if mode1 compatible with mode2 */
@@ -570,15 +561,6 @@ lock_mode_stronger_or_eq(
570561
enum lock_mode mode1, /*!< in: lock mode */
571562
enum lock_mode mode2); /*!< in: lock mode */
572563

573-
/*********************************************************************//**
574-
Gets the wait flag of a lock.
575-
@return LOCK_WAIT if waiting, 0 if not */
576-
UNIV_INLINE
577-
ulint
578-
lock_get_wait(
579-
/*==========*/
580-
const lock_t* lock); /*!< in: lock */
581-
582564
/*********************************************************************//**
583565
Checks if a transaction has the specified table lock, or stronger. This
584566
function should only be called by the thread that owns the transaction.

storage/innobase/include/lock0priv.ic

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ lock_rec_get_next_on_page(
104104
/*======================*/
105105
lock_t* lock) /*!< in: a record lock */
106106
{
107-
return((lock_t*) lock_rec_get_next_on_page_const(lock));
107+
return const_cast<lock_t*>(lock_rec_get_next_on_page_const(lock));
108108
}
109109

110110
/*********************************************************************//**
@@ -120,7 +120,6 @@ lock_rec_get_next(
120120
lock_sys.mutex_assert_locked();
121121

122122
do {
123-
ut_ad(!lock->is_table());
124123
lock = lock_rec_get_next_on_page(lock);
125124
} while (lock && !lock_rec_get_nth_bit(lock, heap_no));
126125

@@ -202,20 +201,6 @@ lock_rec_get_next_on_page_const(
202201
return lock;
203202
}
204203

205-
/*********************************************************************//**
206-
Gets the mode of a lock.
207-
@return mode */
208-
UNIV_INLINE
209-
enum lock_mode
210-
lock_get_mode(
211-
/*==========*/
212-
const lock_t* lock) /*!< in: lock */
213-
{
214-
ut_ad(lock);
215-
216-
return(static_cast<enum lock_mode>(lock->type_mode & LOCK_MODE_MASK));
217-
}
218-
219204
/*********************************************************************//**
220205
Calculates if lock mode 1 is compatible with lock mode 2.
221206
@return nonzero if mode1 compatible with mode2 */
@@ -248,20 +233,6 @@ lock_mode_stronger_or_eq(
248233
return(lock_strength_matrix[mode1][mode2]);
249234
}
250235

251-
/*********************************************************************//**
252-
Gets the wait flag of a lock.
253-
@return LOCK_WAIT if waiting, 0 if not */
254-
UNIV_INLINE
255-
ulint
256-
lock_get_wait(
257-
/*==========*/
258-
const lock_t* lock) /*!< in: lock */
259-
{
260-
ut_ad(lock);
261-
262-
return(lock->type_mode & LOCK_WAIT);
263-
}
264-
265236
/*********************************************************************//**
266237
Checks if a transaction has the specified table lock, or stronger. This
267238
function should only be called by the thread that owns the transaction.
@@ -285,22 +256,16 @@ lock_table_has(
285256
continue;
286257
}
287258

288-
lock_mode mode = lock_get_mode(lock);
289-
290259
ut_ad(trx == lock->trx);
291260
ut_ad(lock->is_table());
292261
ut_ad(lock->un_member.tab_lock.table);
293262

294263
if (table == lock->un_member.tab_lock.table
295-
&& lock_mode_stronger_or_eq(mode, in_mode)) {
296-
297-
ut_ad(!lock_get_wait(lock));
298-
264+
&& lock_mode_stronger_or_eq(lock->mode(), in_mode)) {
265+
ut_ad(!lock->is_waiting());
299266
return(lock);
300267
}
301268
}
302269

303270
return(NULL);
304271
}
305-
306-
/* vim: set filetype=c: */

storage/innobase/lock/lock0iter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ lock_queue_iterator_get_prev(
8282
: UT_LIST_GET_PREV(un_member.tab_lock.locks, iter->current_lock);
8383

8484
if (prev_lock)
85-
iter->current_lock = prev_lock;
85+
iter->current_lock= prev_lock;
8686

8787
return prev_lock;
8888
}

0 commit comments

Comments
 (0)