Skip to content

Commit 0cb90ed

Browse files
author
Magne Mahre
committed
Bug#20837 Apparent change of isolation level during transaction
Bug#46527 COMMIT AND CHAIN RELEASE does not make sense Bug#53343 completion_type=1, COMMIT/ROLLBACK AND CHAIN don't preserve the isolation level Bug#53346 completion_type has strange effect in a stored procedure/prepared statement Added test cases to verify the expected behaviour of : SET SESSION TRANSACTION ISOLATION LEVEL, SET TRANSACTION ISOLATION LEVEL, @@completion_type, COMMIT AND CHAIN, ROLLBACK AND CHAIN ..and some combinations of the above
2 parents 85391c9 + 5ac769b commit 0cb90ed

19 files changed

+939
-64
lines changed

mysql-test/r/commit.result

+272
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
#
2+
# Bug#20837 Apparent change of isolation level
3+
# during transaction
4+
#
5+
# Bug#53343 completion_type=1, COMMIT/ROLLBACK
6+
# AND CHAIN don't preserve the isolation
7+
# level
8+
connection default;
9+
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
10+
CREATE TABLE t1 (s1 INT) ENGINE=InnoDB;
11+
INSERT INTO t1 VALUES (1),(2);
12+
COMMIT;
13+
START TRANSACTION;
14+
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
15+
ERROR 25001: Transaction isolation level can't be changed while a transaction is in progress
16+
COMMIT;
17+
SET @@autocommit=0;
18+
COMMIT;
19+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
20+
START TRANSACTION;
21+
SELECT @@tx_isolation;
22+
@@tx_isolation
23+
REPEATABLE-READ
24+
Should be REPEATABLE READ
25+
SELECT * FROM t1;
26+
s1
27+
1
28+
2
29+
SELECT @@tx_isolation;
30+
@@tx_isolation
31+
REPEATABLE-READ
32+
Should be REPEATABLE READ
33+
INSERT INTO t1 VALUES (-1);
34+
SELECT @@tx_isolation;
35+
@@tx_isolation
36+
REPEATABLE-READ
37+
Should be REPEATABLE READ
38+
COMMIT;
39+
START TRANSACTION;
40+
SELECT * FROM t1;
41+
s1
42+
1
43+
2
44+
-1
45+
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
46+
connection con1
47+
START TRANSACTION;
48+
INSERT INTO t1 VALUES (1000);
49+
COMMIT;
50+
connection default
51+
We should not be able to read the '1000'
52+
SELECT * FROM t1;
53+
s1
54+
1
55+
2
56+
-1
57+
COMMIT;
58+
Now, the '1000' should appear.
59+
START TRANSACTION;
60+
SELECT * FROM t1;
61+
s1
62+
1
63+
2
64+
-1
65+
1000
66+
COMMIT;
67+
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
68+
connection default
69+
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
70+
START TRANSACTION;
71+
connection con1
72+
START TRANSACTION;
73+
INSERT INTO t1 VALUES (1001);
74+
COMMIT;
75+
connection default
76+
SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
77+
COUNT(*)
78+
1
79+
Should be 1
80+
COMMIT AND CHAIN;
81+
connection con1
82+
INSERT INTO t1 VALUES (1002);
83+
COMMIT;
84+
connection default
85+
SELECT COUNT(*) FROM t1 WHERE s1 = 1002;
86+
COUNT(*)
87+
1
88+
Should be 1
89+
COMMIT;
90+
SELECT * FROM t1;
91+
s1
92+
1
93+
2
94+
-1
95+
1000
96+
1001
97+
1002
98+
DELETE FROM t1 WHERE s1 >= 1000;
99+
COMMIT;
100+
connection default
101+
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
102+
START TRANSACTION;
103+
connection con1
104+
START TRANSACTION;
105+
INSERT INTO t1 VALUES (1001);
106+
COMMIT;
107+
connection default
108+
SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
109+
COUNT(*)
110+
1
111+
Should be 1
112+
ROLLBACK AND CHAIN;
113+
connection con1
114+
INSERT INTO t1 VALUES (1002);
115+
COMMIT;
116+
connection default
117+
SELECT COUNT(*) FROM t1 WHERE s1 = 1002;
118+
COUNT(*)
119+
1
120+
Should be 1
121+
COMMIT;
122+
SELECT * FROM t1;
123+
s1
124+
1
125+
2
126+
-1
127+
1001
128+
1002
129+
DELETE FROM t1 WHERE s1 >= 1000;
130+
COMMIT;
131+
SET @@completion_type=1;
132+
connection default
133+
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
134+
START TRANSACTION;
135+
connection con1
136+
START TRANSACTION;
137+
INSERT INTO t1 VALUES (1001);
138+
COMMIT;
139+
connection default
140+
SELECT * FROM t1 WHERE s1 >= 1000;
141+
s1
142+
1001
143+
Should see 1001
144+
COMMIT AND NO CHAIN;
145+
default transaction is now in REPEATABLE READ
146+
connection con1
147+
INSERT INTO t1 VALUES (1002);
148+
COMMIT;
149+
connection default
150+
SELECT * FROM t1 WHERE s1 >= 1000;
151+
s1
152+
1001
153+
1002
154+
Should see 1001 and 1002
155+
connection con1
156+
INSERT INTO t1 VALUES (1003);
157+
COMMIT;
158+
connection default
159+
SELECT * FROM t1 WHERE s1 >= 1000;
160+
s1
161+
1001
162+
1002
163+
Should see 1001 and 1002, but NOT 1003
164+
COMMIT;
165+
SELECT * FROM t1;
166+
s1
167+
1
168+
2
169+
-1
170+
1001
171+
1002
172+
1003
173+
DELETE FROM t1 WHERE s1 >= 1000;
174+
COMMIT AND NO CHAIN;
175+
SET @@completion_type=0;
176+
COMMIT;
177+
connection default
178+
SET @@completion_type=1;
179+
COMMIT AND NO CHAIN;
180+
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
181+
START TRANSACTION;
182+
connection con1
183+
START TRANSACTION;
184+
INSERT INTO t1 VALUES (1001);
185+
COMMIT;
186+
connection default
187+
SELECT * FROM t1 WHERE s1 >= 1000;
188+
s1
189+
1001
190+
Should see 1001
191+
ROLLBACK AND NO CHAIN;
192+
default transaction is now in REPEATABLE READ
193+
connection con1
194+
INSERT INTO t1 VALUES (1002);
195+
COMMIT;
196+
connection default
197+
SELECT * FROM t1 WHERE s1 >= 1000;
198+
s1
199+
1001
200+
1002
201+
Should see 1001 and 1002
202+
connection con1
203+
INSERT INTO t1 VALUES (1003);
204+
COMMIT;
205+
connection default
206+
SELECT * FROM t1 WHERE s1 >= 1000;
207+
s1
208+
1001
209+
1002
210+
Should see 1001 and 1002, but NOT 1003
211+
COMMIT;
212+
SELECT * FROM t1;
213+
s1
214+
1
215+
2
216+
-1
217+
1001
218+
1002
219+
1003
220+
DELETE FROM t1 WHERE s1 >= 1000;
221+
COMMIT AND NO CHAIN;
222+
SET @@completion_type=0;
223+
COMMIT;
224+
connection default
225+
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
226+
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
227+
START TRANSACTION;
228+
SELECT * FROM t1;
229+
s1
230+
1
231+
2
232+
-1
233+
connection con1
234+
INSERT INTO t1 VALUES (1000);
235+
COMMIT;
236+
connection default
237+
SELECT * FROM t1;
238+
s1
239+
1
240+
2
241+
-1
242+
Should get same result as above (i.e should not read '1000')
243+
COMMIT;
244+
DELETE FROM t1 WHERE s1 >= 1000;
245+
COMMIT;
246+
SET @@completion_type=1;
247+
COMMIT AND NO CHAIN;
248+
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
249+
START TRANSACTION;
250+
TRUNCATE TABLE t1;
251+
INSERT INTO t1 VALUES (1000);
252+
SELECT * FROM t1;
253+
s1
254+
1000
255+
Should read '1000'
256+
connection con1
257+
INSERT INTO t1 VALUES (1001);
258+
COMMIT;
259+
connection default
260+
SELECT * FROM t1;
261+
s1
262+
1000
263+
Should only read the '1000' as this transaction is now in REP READ
264+
COMMIT AND NO CHAIN;
265+
SET @@completion_type=0;
266+
COMMIT AND NO CHAIN;
267+
SET @autocommit=1;
268+
COMMIT;
269+
DROP TABLE t1;
270+
#
271+
# End of test cases for Bug#20837
272+
#

mysql-test/r/parser.result

+45
Original file line numberDiff line numberDiff line change
@@ -618,3 +618,48 @@ DROP TABLE t1, t2, t3;
618618
#
619619
# End of 5.1 tests
620620
#
621+
# Bug#46527 "COMMIT AND CHAIN RELEASE does not make sense"
622+
#
623+
COMMIT AND CHAIN RELEASE;
624+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1
625+
COMMIT AND NO CHAIN RELEASE;
626+
COMMIT RELEASE;
627+
COMMIT CHAIN RELEASE;
628+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1
629+
COMMIT NO CHAIN RELEASE;
630+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1
631+
COMMIT AND NO RELEASE;
632+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1
633+
COMMIT AND RELEASE;
634+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1
635+
COMMIT NO RELEASE;
636+
COMMIT CHAIN NO RELEASE;
637+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1
638+
COMMIT NO CHAIN NO RELEASE;
639+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1
640+
COMMIT AND RELEASE CHAIN;
641+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE CHAIN' at line 1
642+
COMMIT AND NO CHAIN NO RELEASE;
643+
ROLLBACK AND CHAIN RELEASE;
644+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1
645+
ROLLBACK AND NO CHAIN RELEASE;
646+
ROLLBACK RELEASE;
647+
ROLLBACK CHAIN RELEASE;
648+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1
649+
ROLLBACK NO CHAIN RELEASE;
650+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1
651+
ROLLBACK AND NO RELEASE;
652+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1
653+
ROLLBACK AND RELEASE;
654+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1
655+
ROLLBACK NO RELEASE;
656+
ROLLBACK CHAIN NO RELEASE;
657+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1
658+
ROLLBACK NO CHAIN NO RELEASE;
659+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1
660+
ROLLBACK AND RELEASE CHAIN;
661+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE CHAIN' at line 1
662+
ROLLBACK AND NO CHAIN NO RELEASE;
663+
#
664+
# End of 5.5 tests
665+
#

mysql-test/r/partition_innodb_semi_consistent.result

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set autocommit=0;
1818
update t1 set a=10 where a=5;
1919
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
2020
commit;
21+
commit;
2122
set session transaction isolation level read committed;
2223
update t1 set a=10 where a=5;
2324
select * from t1 where a=2 for update;

mysql-test/r/ps.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,11 @@ REPEATABLE-READ
695695
set transaction isolation level read committed;
696696
execute stmt;
697697
@@tx_isolation
698-
READ-COMMITTED
698+
REPEATABLE-READ
699699
set transaction isolation level serializable;
700700
execute stmt;
701701
@@tx_isolation
702-
SERIALIZABLE
702+
REPEATABLE-READ
703703
set @@tx_isolation=default;
704704
execute stmt;
705705
@@tx_isolation

0 commit comments

Comments
 (0)