diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-04-01 14:07:02 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-04-01 14:07:02 +0400 |
commit | 334e7c9bccbc6892efbb35f5930f80ccf1d770a8 (patch) | |
tree | 7ddc38e5c776a4f82c9a9731f8d6d3a79103eef0 /sql/sql_class.h | |
parent | cbc5157feb9801310e458f7ed10983ad478c881e (diff) | |
download | mariadb-git-bb-mdev7895.tar.gz |
MDEV-7895 - HANDLER READ doesn't upgrade metadata lock from S to SRbb-mdev7895
Change code for HANDLER READ statements to upgrade S metadata lock to
SR metadata lock for the duration of read. This allows us properly
isolate HANDLER READ from LOCK TABLES WRITE and makes metadata locking
for these statements consistent with locking for other DML.
HANDLER-related tests had to be adjusted to take into account that
HANDLER READ will wait for and acquire SR lock.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 73637f8d8eb..6b64f710176 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1535,6 +1535,41 @@ private: /** + Internal error handler to process an error from MDL_context::upgrade_lock() + and mysql_lock_tables(). Used by implementations of HANDLER READ and + LOCK TABLES LOCAL. +*/ + +class MDL_deadlock_and_lock_abort_error_handler: public Internal_error_handler +{ +public: + /** + Handle an error from MDL_context::upgrade_lock() and mysql_lock_tables(). + Ignore ER_LOCK_ABORTED and ER_LOCK_DEADLOCK errors. + */ + virtual + bool handle_condition(THD *thd, + uint sql_errno, + const char *sqlstate, + Sql_condition::enum_warning_level level, + const char* msg, + Sql_condition **cond_hdl) + { + *cond_hdl= NULL; + if (sql_errno == ER_LOCK_ABORTED || sql_errno == ER_LOCK_DEADLOCK) + m_need_reopen= true; + + return m_need_reopen; + } + + bool need_reopen() const { return m_need_reopen; }; + void init() { m_need_reopen= false; }; +private: + bool m_need_reopen; +}; + + +/** Tables that were locked with LOCK TABLES statement. Encapsulates a list of TABLE_LIST instances for tables |