mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user