summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-12-03 18:18:29 +0300
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-12-03 18:18:29 +0300
commit25d4cfad5b30127e8b1902a63e3703a4b94f6cb9 (patch)
treea59ba68c99ea3b61f35a600aeac05ef31b735982
parent1295ec601c4504285121353e94582c325f1c24fe (diff)
parent43f7cd01723a06c47de6f64475991e3f02c00f65 (diff)
downloadmariadb-git-25d4cfad5b30127e8b1902a63e3703a4b94f6cb9.tar.gz
Automerge from mysql-5.1-bugteam to mysql-trunk-merge.
-rw-r--r--mysql-test/r/innodb_mysql.result31
-rw-r--r--mysql-test/t/innodb_mysql.test26
-rw-r--r--sql/handler.cc10
3 files changed, 65 insertions, 2 deletions
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 402ab3c1b16..2d93cbb47b3 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -2273,4 +2273,35 @@ END|
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1,t2;
+#
+# Bug #20837 Apparent change of isolation
+# level during transaction
+#
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+CREATE TABLE t1 (s1 INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2);
+COMMIT;
+SET @@autocommit = 0;
+COMMIT;
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+START TRANSACTION;
+SELECT * FROM t1;
+s1
+1
+2
+Should be READ UNCOMMITTED
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-UNCOMMITTED
+INSERT INTO t1 VALUES (-1);
+Should be READ UNCOMMITTED
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-UNCOMMITTED
+COMMIT;
+Should now be REPEATABLE READ
+SELECT @@tx_isolation;
+@@tx_isolation
+REPEATABLE-READ
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index a2a1113598d..0462536371e 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -536,4 +536,30 @@ DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug #20837 Apparent change of isolation
+--echo # level during transaction
+--echo #
+
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+CREATE TABLE t1 (s1 INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2);
+COMMIT;
+
+SET @@autocommit = 0;
+COMMIT;
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+START TRANSACTION;
+SELECT * FROM t1;
+--echo Should be READ UNCOMMITTED
+SELECT @@tx_isolation;
+INSERT INTO t1 VALUES (-1);
+--echo Should be READ UNCOMMITTED
+SELECT @@tx_isolation;
+COMMIT;
+--echo Should now be REPEATABLE READ
+SELECT @@tx_isolation;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/sql/handler.cc b/sql/handler.cc
index 397c4ce7335..e4677bb1586 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1370,8 +1370,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);