diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-07-27 14:25:53 +0400 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-07-27 14:25:53 +0400 |
commit | ec2c3bf2c1c27e4401c767a6cdcb3172453ff42c (patch) | |
tree | daa2c75e6ac3ede954eb788e81dd95c711da1569 /sql/sys_vars.cc | |
parent | c67cf159e928fe63582a4233d130dada0f866cb7 (diff) | |
download | mariadb-git-ec2c3bf2c1c27e4401c767a6cdcb3172453ff42c.tar.gz |
A pre-requisite patch for the fix for Bug#52044.
This patch also fixes Bug#55452 "SET PASSWORD is
replicated twice in RBR mode".
The goal of this patch is to remove the release of
metadata locks from close_thread_tables().
This is necessary to not mistakenly release
the locks in the course of a multi-step
operation that involves multiple close_thread_tables()
or close_tables_for_reopen().
On the same token, move statement commit outside
close_thread_tables().
Other cleanups:
Cleanup COM_FIELD_LIST.
Don't call close_thread_tables() in COM_SHUTDOWN -- there
are no open tables there that can be closed (we leave
the locked tables mode in THD destructor, and this
close_thread_tables() won't leave it anyway).
Make open_and_lock_tables() and open_and_lock_tables_derived()
call close_thread_tables() upon failure.
Remove the calls to close_thread_tables() that are now
unnecessary.
Simplify the back off condition in Open_table_context.
Streamline metadata lock handling in LOCK TABLES
implementation.
Add asserts to ensure correct life cycle of
statement transaction in a session.
Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r-- | sql/sys_vars.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 6e95961ebb0..9e212fb95e9 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2203,14 +2203,21 @@ static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type) thd->variables.option_bits & OPTION_NOT_AUTOCOMMIT) { // activating autocommit - if (trans_commit(thd)) + if (trans_commit_stmt(thd) || trans_commit(thd)) { thd->variables.option_bits&= ~OPTION_AUTOCOMMIT; return true; } - close_thread_tables(thd); - thd->mdl_context.release_transactional_locks(); - + /* + Don't close thread tables or release metadata locks: if we do so, we + risk releasing locks/closing tables of expressions used to assign + other variables, as in: + set @var=my_stored_function1(), @@autocommit=1, @var2=(select max(a) + from my_table), ... + The locks will be released at statement end anyway, as SET + statement that assigns autocommit is marked to commit + transaction implicitly at the end (@sa stmt_causes_implicitcommit()). + */ thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG | OPTION_NOT_AUTOCOMMIT); thd->transaction.all.modified_non_trans_table= false; |