summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.(none)>2007-07-31 20:00:05 +0400
committerunknown <kostja@bodhi.(none)>2007-07-31 20:00:05 +0400
commit4c11e05ad22bcb804c0f152adf958b44818930f2 (patch)
tree5faf4ce2462af28bd89525ed7337997852e9c831 /sql/lock.cc
parent1ac6e95483bdf86f98afb70723c66ac4e9797920 (diff)
parenteb6c85e7552dcf63f2b2ed065051f571425d8426 (diff)
downloadmariadb-git-4c11e05ad22bcb804c0f152adf958b44818930f2.tar.gz
Merge bodhi.(none):/opt/local/work/mysql-5.0-runtime
into bodhi.(none):/opt/local/work/mysql-5.1-runtime sql/mysql_priv.h: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged mysql-test/include/mix1.inc: Manual merge. mysql-test/r/innodb_mysql.result: Manual merge. sql/handler.h: Manual merge. sql/lock.cc: Manual merge. sql/opt_range.cc: Manual merge. sql/sql_base.cc: Manual merge. sql/sql_table.cc: Manual merge.
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index acb34c0d66a..c401cbda05c 100644
--- a/sql/lock.cc
+++ b/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.
+
+ @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)
+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;