mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge bodhi.(none):/opt/local/work/mysql-5.0-runtime
into bodhi.(none):/opt/local/work/mysql-5.1-runtime
This commit is contained in:
30
sql/lock.cc
30
sql/lock.cc
@ -244,7 +244,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
||||
|
||||
thd->proc_info="System lock";
|
||||
DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info));
|
||||
if (lock_external(thd, tables, count))
|
||||
if (sql_lock->table_count && lock_external(thd, sql_lock->table,
|
||||
sql_lock->table_count))
|
||||
{
|
||||
/* Clear the lock type of all lock data to avoid reusage. */
|
||||
reset_lock_data(sql_lock);
|
||||
@ -340,6 +341,7 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
|
||||
((*tables)->reginfo.lock_type >= TL_READ &&
|
||||
(*tables)->reginfo.lock_type <= TL_READ_NO_INSERT))
|
||||
lock_type=F_RDLCK;
|
||||
|
||||
if ((error=(*tables)->file->ha_external_lock(thd,lock_type)))
|
||||
{
|
||||
print_lock_error(error, (*tables)->file->table_type());
|
||||
@ -447,10 +449,28 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Try to find the table in the list of locked tables.
|
||||
In case of success, unlock the table and remove it from this list.
|
||||
|
||||
void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table)
|
||||
@note This function has a legacy side effect: the table is
|
||||
unlocked even if it is not found in the locked list.
|
||||
It's not clear if this side effect is intentional or still
|
||||
desirable. It might lead to unmatched calls to
|
||||
unlock_external(). Moreover, a discrepancy can be left
|
||||
unnoticed by the storage engine, because in
|
||||
unlock_external() we call handler::external_lock(F_UNLCK) only
|
||||
if table->current_lock is not F_UNLCK.
|
||||
|
||||
@param always_unlock specify explicitly if the legacy side
|
||||
effect is desired.
|
||||
*/
|
||||
|
||||
void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table,
|
||||
bool always_unlock)
|
||||
{
|
||||
mysql_unlock_some_tables(thd, &table,1);
|
||||
if (always_unlock == TRUE)
|
||||
mysql_unlock_some_tables(thd, &table, /* table count */ 1);
|
||||
if (locked)
|
||||
{
|
||||
reg1 uint i;
|
||||
@ -464,6 +484,10 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table)
|
||||
|
||||
DBUG_ASSERT(table->lock_position == i);
|
||||
|
||||
/* Unlock if not yet unlocked */
|
||||
if (always_unlock == FALSE)
|
||||
mysql_unlock_some_tables(thd, &table, /* table count */ 1);
|
||||
|
||||
/* Decrement table_count in advance, making below expressions easier */
|
||||
old_tables= --locked->table_count;
|
||||
|
||||
|
Reference in New Issue
Block a user