summaryrefslogtreecommitdiff
path: root/sql/sql_cursor.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-06-08 12:08:46 +0400
committerKonstantin Osipov <kostja@sun.com>2010-06-08 12:08:46 +0400
commitd4f1abaad2dfd2da0e37977dc5a7e08afa2ad269 (patch)
tree978ecf18fe2aed14f3a694a73e5a80f1c7835be3 /sql/sql_cursor.cc
parent29f9fb7a0a7df0136293aed63cd596bd45ff5b55 (diff)
downloadmariadb-git-d4f1abaad2dfd2da0e37977dc5a7e08afa2ad269.tar.gz
WL#4441 "LOCK_open: Remove requirement of mutex protecting
thd->open_tables" thd->open_tables list is not normally accessed concurrently except for one case: when the connection has open SQL HANDLER tables, and we want to perform a DDL on the table, we want to abort waits on MyISAM thr_lock of those connections that prevent the DDL from proceeding, and iterate over thd->open_tables list to find out the tables on which the thread is waiting. In 5.5 we mostly use deadlock detection and soft deadlock prevention, as opposed to "hard" deadlock prevention of 5.1, which would abort any transaction that may cause a deadlock. The only remaining case when neither deadlock detection nor deadlock prevention is implemented in 5.5 is HANDLER SQL, where we use old good thr_lock_abort() technique form 5.1. Thus, replace use of LOCK_open to protect thd->open_tables with thd->LOCK_ha_data (a lock protecting various session private data). This is a port of the work done for 5.5.4 for review and inclusion into 5.5.5. sql/sql_base.cc: Use thd->LOCK_ha_data (systematically) to set thd->open_tables. sql/sql_class.h: Implement THD::set_open_tables(). sql/sql_cursor.cc: Use thd->LOCK_ha_data (systematically) to set thd->open_tables. sql/sql_handler.cc: Use thd->LOCK_ha_data (systematically) to set thd->open_tables. Acquisition of LOCK_open is moved inside close_thread_table(). sql/sql_table.cc: Acquisition of LOCK_open is moved inside close_thread_tables().
Diffstat (limited to 'sql/sql_cursor.cc')
-rw-r--r--sql/sql_cursor.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 59bf0764ada..ca724ec262f 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -357,7 +357,7 @@ void
Sensitive_cursor::reset_thd(THD *thd)
{
thd->derived_tables= 0;
- thd->open_tables= 0;
+ thd->set_open_tables(NULL);
thd->lock= 0;
thd->free_list= 0;
thd->change_list.empty();
@@ -436,7 +436,7 @@ Sensitive_cursor::fetch(ulong num_rows)
thd->lock == 0);
thd->derived_tables= derived_tables;
- thd->open_tables= open_tables;
+ thd->set_open_tables(open_tables);
thd->lock= lock;
thd->set_query_id(query_id);
change_list.move_elements_to(&thd->change_list);
@@ -519,14 +519,14 @@ Sensitive_cursor::close()
TABLE *tmp_derived_tables= thd->derived_tables;
MYSQL_LOCK *tmp_lock= thd->lock;
- thd->open_tables= open_tables;
+ thd->set_open_tables(open_tables);
thd->derived_tables= derived_tables;
thd->lock= lock;
/* Is expected to at least close tables and empty thd->change_list */
stmt_arena->cleanup_stmt();
- thd->open_tables= tmp_derived_tables;
+ thd->set_open_tables(tmp_derived_tables);
thd->derived_tables= tmp_derived_tables;
thd->lock= tmp_lock;
}