summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2006-02-20 12:28:58 +0100
committerunknown <ingo@mysql.com>2006-02-20 12:28:58 +0100
commit8c9ac3ecb42366c59321dc94c41331bcce122f58 (patch)
tree690a9aaf84966bcc7a1c128ab4ec136619f0ea24 /sql/lock.cc
parentcfbb86034d284c8c24a63725735f17cf00304b3b (diff)
parent4646cc587f86596a8e8f432332fe59ecdb598a5a (diff)
downloadmariadb-git-8c9ac3ecb42366c59321dc94c41331bcce122f58.tar.gz
Merge mysql.com:/home/mydev/mysql-4.0-bug5390
into mysql.com:/home/mydev/mysql-4.1-bug5390 sql/lock.cc: Auto merged
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 2db0538c139..fe59039dde3 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -141,7 +141,12 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags)
}
thd->proc_info="Table lock";
thd->locked=1;
- if (thr_multi_lock(sql_lock->locks,sql_lock->lock_count))
+ /* Copy the lock data array. thr_multi_lock() reorders its contens. */
+ memcpy(sql_lock->locks + sql_lock->lock_count, sql_lock->locks,
+ sql_lock->lock_count * sizeof(*sql_lock->locks));
+ /* Lock on the copied half of the lock data array. */
+ if (thr_multi_lock(sql_lock->locks + sql_lock->lock_count,
+ sql_lock->lock_count))
{
thd->some_tables_deleted=1; // Try again
sql_lock->lock_count=0; // Locks are alread freed
@@ -603,13 +608,20 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
}
}
+ /*
+ Allocating twice the number of pointers for lock data for use in
+ thr_mulit_lock(). This function reorders the lock data, but cannot
+ update the table values. So the second part of the array is copied
+ from the first part immediately before calling thr_multi_lock().
+ */
if (!(sql_lock= (MYSQL_LOCK*)
- my_malloc(sizeof(*sql_lock)+
- sizeof(THR_LOCK_DATA*)*tables+sizeof(table_ptr)*lock_count,
+ my_malloc(sizeof(*sql_lock) +
+ sizeof(THR_LOCK_DATA*) * tables * 2 +
+ sizeof(table_ptr) * lock_count,
MYF(0))))
DBUG_RETURN(0);
locks= locks_buf= sql_lock->locks= (THR_LOCK_DATA**) (sql_lock + 1);
- to= table_buf= sql_lock->table= (TABLE**) (locks + tables);
+ to= table_buf= sql_lock->table= (TABLE**) (locks + tables * 2);
sql_lock->table_count=lock_count;
sql_lock->lock_count=tables;