Commit 65835065 authored by Marko Mäkelä's avatar Marko Mäkelä

Rename lock_pool_t to lock_list

Also, replace reverse iteration with forward iteration.

lock_table_has(): Remove a redundant condition.
parent 3ce8a0fc
/*****************************************************************************
Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -388,17 +389,10 @@ lock_table_has(
const dict_table_t* table, /*!< in: table */
lock_mode in_mode)/*!< in: lock mode */
{
if (trx->lock.table_locks.empty()) {
return(NULL);
}
typedef lock_pool_t::const_reverse_iterator iterator;
iterator end = trx->lock.table_locks.rend();
/* Look for stronger locks the same trx already has on the table */
for (iterator it = trx->lock.table_locks.rbegin(); it != end; ++it) {
for (lock_list::const_iterator it = trx->lock.table_locks.begin(),
end = trx->lock.table_locks.end(); it != end; ++it) {
const lock_t* lock = *it;
......
......@@ -642,7 +642,7 @@ The tranasction must be in the mysql_trx_list. */
# define assert_trx_nonlocking_or_in_list(trx) ((void)0)
#endif /* UNIV_DEBUG */
typedef std::vector<ib_lock_t*, ut_allocator<ib_lock_t*> > lock_pool_t;
typedef std::vector<ib_lock_t*, ut_allocator<ib_lock_t*> > lock_list;
/*******************************************************************//**
Latching protocol for trx_lock_t::que_state. trx_lock_t::que_state
......@@ -726,7 +726,7 @@ struct trx_lock_t {
and lock_sys->mutex; removals are
protected by lock_sys->mutex */
lock_pool_t table_locks; /*!< All table locks requested by this
lock_list table_locks; /*!< All table locks requested by this
transaction, including AUTOINC locks */
bool cancel; /*!< true if the transaction is being
......
......@@ -4493,24 +4493,15 @@ lock_trx_table_locks_remove(
ut_ad(trx_mutex_own(trx));
}
typedef lock_pool_t::reverse_iterator iterator;
iterator end = trx->lock.table_locks.rend();
for (iterator it = trx->lock.table_locks.rbegin(); it != end; ++it) {
for (lock_list::iterator it = trx->lock.table_locks.begin(),
end = trx->lock.table_locks.end(); it != end; ++it) {
const lock_t* lock = *it;
if (lock == NULL) {
continue;
}
ut_a(trx == lock->trx);
ut_a(lock_get_type_low(lock) & LOCK_TABLE);
ut_a(lock->un_member.tab_lock.table != NULL);
ut_ad(!lock || trx == lock->trx);
ut_ad(!lock || lock_get_type_low(lock) & LOCK_TABLE);
ut_ad(!lock || lock->un_member.tab_lock.table);
if (lock == lock_to_remove) {
*it = NULL;
if (!trx->lock.cancel) {
......@@ -5370,11 +5361,8 @@ lock_trx_table_locks_find(
trx_mutex_enter(trx);
typedef lock_pool_t::const_reverse_iterator iterator;
iterator end = trx->lock.table_locks.rend();
for (iterator it = trx->lock.table_locks.rbegin(); it != end; ++it) {
for (lock_list::const_iterator it = trx->lock.table_locks.begin(),
end = trx->lock.table_locks.end(); it != end; ++it) {
const lock_t* lock = *it;
......@@ -7108,10 +7096,8 @@ lock_trx_has_sys_table_locks(
lock_mutex_enter();
typedef lock_pool_t::const_reverse_iterator iterator;
iterator end = trx->lock.table_locks.rend();
iterator it = trx->lock.table_locks.rbegin();
const lock_list::const_iterator end = trx->lock.table_locks.end();
lock_list::const_iterator it = trx->lock.table_locks.begin();
/* Find a valid mode. Note: ib_vector_size() can be 0. */
......
......@@ -190,7 +190,7 @@ struct TrxFactory {
the constructors of the trx_t members. */
new(&trx->mod_tables) trx_mod_tables_t();
new(&trx->lock.table_locks) lock_pool_t();
new(&trx->lock.table_locks) lock_list();
trx_init(trx);
......@@ -243,7 +243,7 @@ struct TrxFactory {
ut_ad(trx->read_view == NULL);
trx->lock.table_locks.~lock_pool_t();
trx->lock.table_locks.~lock_list();
}
/** Enforce any invariants here, this is called before the transaction
......
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