summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2014-12-02 14:54:30 +0400
committerSergey Vojtovich <svoj@mariadb.org>2014-12-05 11:01:49 +0400
commitb4ec230917a50cbc1e406f5175189c8359bcb9a0 (patch)
tree1bc8664e0eccdab6c5e57a86ee76d02a200eb92c /sql/lock.cc
parent9bc5cec0f115d7d0c277a49b91b96109560280f4 (diff)
downloadmariadb-git-b4ec230917a50cbc1e406f5175189c8359bcb9a0.tar.gz
MDEV-7004 - Merge scalability fixes from 10.0-power
Preallocate locks on THD mem_root to avoid expensive malloc.
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index a0796db7367..c9aa49a4057 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -68,10 +68,6 @@
table_handler->external_lock(thd, F_UNLCK) for each table that was locked,
excluding one that caused failure. That means handler must cleanup itself
in case external_lock() fails.
-
- @todo
- Change to use my_malloc() ONLY when using LOCK TABLES command or when
- we are forced to use mysql_lock_merge.
*/
#include <my_global.h>
@@ -266,19 +262,24 @@ void reset_lock_data(MYSQL_LOCK *sql_lock, bool unlock)
MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags)
{
MYSQL_LOCK *sql_lock;
+ uint gld_flags= GET_LOCK_STORE_LOCKS;
DBUG_ENTER("mysql_lock_tables(tables)");
if (lock_tables_check(thd, tables, count, flags))
DBUG_RETURN(NULL);
- if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS)))
+ if (!(thd->variables.option_bits & OPTION_TABLE_LOCK))
+ gld_flags|= GET_LOCK_ON_THD;
+
+ if (! (sql_lock= get_lock_data(thd, tables, count, gld_flags)))
DBUG_RETURN(NULL);
if (mysql_lock_tables(thd, sql_lock, flags))
{
/* Clear the lock type of all lock data to avoid reusage. */
reset_lock_data(sql_lock, 1);
- my_free(sql_lock);
+ if (!(gld_flags & GET_LOCK_ON_THD))
+ my_free(sql_lock);
sql_lock= 0;
}
DBUG_RETURN(sql_lock);
@@ -382,6 +383,13 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
}
+void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
+{
+ mysql_unlock_tables(thd, sql_lock,
+ thd->variables.option_bits & OPTION_TABLE_LOCK);
+}
+
+
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock, bool free_lock)
{
DBUG_ENTER("mysql_unlock_tables");