diff options
author | Magne Mahre <magne.mahre@sun.com> | 2009-11-30 12:30:28 +0100 |
---|---|---|
committer | Magne Mahre <magne.mahre@sun.com> | 2009-11-30 12:30:28 +0100 |
commit | 732e5a263444178370ab0b4c6410e138d09218e7 (patch) | |
tree | 5f8524ad9eae7fd02c7b2600942ca9015985815a /sql/handler.cc | |
parent | cefd968dddcbd333fad186daeebeb17ef907d154 (diff) | |
download | mariadb-git-732e5a263444178370ab0b4c6410e138d09218e7.tar.gz |
Bug #20837 Apparent change of isolation level during transaction
SET TRANSACTION ISOLATION LEVEL is used to temporarily set
the trans.iso.level for the next transaction. After the
transaction, the iso.level is (re-)set to value of the
session variable 'tx_isolation'.
The bug is caused by setting the thd->variables.tx_isolation
field to the value of the session variable upon each
statement commit. It should only be set at the end of the
full transaction.
The fix has been to remove the setting of the variable in
ha_autocommit_or_rollback if we're in a transaction, as it
will be correctly set in either ha_rollback or
ha_commit_one_phase.
If, on the other hand, we're in autocommit mode, tx_isolation
will be explicitly set here.
mysql-test/t/innodb_mysql.test:
"SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED" sets
the trans.isolation for the next transaction. We test
that @@tx_isolation keeps this value during the transaction,
and is only reset back to the session value at the end
of the transaction.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 216228ed509..f6cdaca05bd 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1369,8 +1369,14 @@ int ha_autocommit_or_rollback(THD *thd, int error) if (thd->transaction_rollback_request && !thd->in_sub_stmt) (void) ha_rollback(thd); } - - thd->variables.tx_isolation=thd->session_tx_isolation; + } + else if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + { + /* + If we're in autocommit mode, reset tx_isolation + to the default value + */ + thd->variables.tx_isolation= thd->session_tx_isolation; } #endif DBUG_RETURN(error); |