-
Konstantin Osipov authored
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().
d4f1abaa