Debian Codegraph @

mysql-test/suite/innodb/t/attachable_trx.test

raw
1 --source include/have_debug.inc
2
3 # Save the initial number of concurrent sessions
4 --source include/count_sessions.inc
5
6 SET @debug_saved = @@global.debug;
7
8 --echo
9 START TRANSACTION;
10
11 --echo
12 CREATE TABLE t1(a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(255)) engine = innodb;
13
14 --echo
15 INSERT INTO t1(b) VALUES ('aaa');
16 INSERT INTO t1(b) VALUES ('bbb');
17 INSERT INTO t1(b) VALUES ('ccc');
18
19 --echo
20 COMMIT;
21
22 ###########################################################################
23
24 --echo
25 --echo # 1. Start outer transaction with SERIALIZABLE isolation level.
26 --echo # Check that SELECT in inner transaction will not take locks.
27
28 --echo
29 --echo # Start transaction.
30 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
31 START TRANSACTION;
32
33 --echo # Insert a new row into t1.
34 INSERT INTO t1(b) VALUES ('ddd');
35 SELECT * FROM t1;
36
37 --echo
38 --echo # [another connection]
39 --connect (con1,localhost,root,,)
40
41 --echo
42 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
43 START TRANSACTION;
44 SET @@global.debug = '+d,use_attachable_trx';
45 SELECT * FROM t1;
46 SET @@global.debug = '-d,use_attachable_trx';
47 --disconnect con1
48
49 --echo
50 --echo # [default connection]
51 --connection default
52
53 --echo
54 ROLLBACK;
55
56 ###########################################################################
57
58 --echo
59 --echo # 2. Check that inner transaction has different visibility scope than
60 --echo # the outer transaction.
61
62 --echo # Start READ ONLY transaction.
63 SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
64 START TRANSACTION READ ONLY;
65
66 --echo # SELECT to actually start a transaction.
67 SELECT * FROM t1;
68
69 --echo
70 --echo # [another connection]
71 --connect (con1,localhost,root,,)
72
73 --echo
74 START TRANSACTION;
75 UPDATE t1 SET b = 'zzz' WHERE a = 2;
76 COMMIT;
77 --disconnect con1
78
79 --echo
80 --echo # [default connection]
81 --connection default
82
83 --echo
84 --echo # SELECT in the outer transaction doesn't see the changes.
85 SELECT * FROM t1;
86
87 --echo
88 --echo # SELECT in the inner transaction sees the changes.
89 SET @@global.debug = '+d,use_attachable_trx';
90 SELECT * FROM t1;
91 SET @@global.debug = '-d,use_attachable_trx';
92
93 --echo
94 --echo # COMMIT the outer transaction.
95 COMMIT;
96
97 --echo # SELECT in the outer transaction now sees the changes.
98 SELECT * FROM t1;
99 COMMIT;
100
101 ###########################################################################
102
103 --echo
104 --echo # 3. Check that the inner transaction does not reset a save point set in
105 --echo # the outer transaction.
106
107 --echo
108 --echo # Start transaction.
109 SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
110 START TRANSACTION;
111 SELECT * FROM t1;
112
113 --echo
114 --echo # Set save point.
115 SAVEPOINT sp1;
116
117 --echo
118 --echo # Do some changes.
119 UPDATE t1 SET b = 'xxx' WHERE a = 2;
120 SELECT * FROM t1;
121
122 --echo
123 --echo # Do anything in the inner transaction.
124 SET @@global.debug = '+d,use_attachable_trx';
125 SELECT * FROM t1;
126 SET @@global.debug = '-d,use_attachable_trx';
127
128 --echo
129 --echo # Just make sure the changes are still there.
130 SELECT * FROM t1;
131
132 --echo
133 --echo # Rollback to the save point to make sure it was not reset.
134 ROLLBACK TO SAVEPOINT sp1;
135
136 --echo
137 --echo # Check that the changes have been reverted.
138 SELECT * FROM t1;
139
140 --echo
141 --echo # Commit.
142 COMMIT;
143
144 ###########################################################################
145
146 --echo
147 --echo # Cleanup.
148 DROP TABLE t1;
149
150 --echo
151 SET @@global.debug = @debug_saved;
152
153 # Wait till we reached the initial number of concurrent sessions
154 --source include/wait_until_count_sessions.inc