1CREATE TABLE t1 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
2INSERT INTO t1 VALUES(0, "0");
3INSERT INTO t1 VALUES(1, "1");
4INSERT INTO t1 VALUES(2, "2");
5INSERT INTO t1 VALUES(3, "3");
6CREATE TABLE t2 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
7INSERT INTO t2 VALUES(0, "a");
8INSERT INTO t2 VALUES(1, "b");
9INSERT INTO t2 VALUES(2, "c");
10INSERT INTO t2 VALUES(3, "d");
11'T1'
12SET AUTOCOMMIT=0;
13BEGIN;
14SELECT * FROM t2;
15c1	c2
160	a
171	b
182	c
193	d
20'T2'
21SET AUTOCOMMIT=0;
22BEGIN;
23SELECT * FROM t1;
24c1	c2
250	0
261	1
272	2
283	3
29'T3'
30SET AUTOCOMMIT=0;
31SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
32BEGIN;
33SELECT * FROM t1;
34c1	c2
350	0
361	1
372	2
383	3
39SELECT * FROM t2;
40c1	c2
410	a
421	b
432	c
443	d
45'T1'
46UPDATE t2 SET c1 = c1 + 100;
47SELECT * FROM t2;
48c1	c2
49100	a
50101	b
51102	c
52103	d
53COMMIT;
54'T2'
55UPDATE t1 SET c1 = c1 + 100;
56SELECT * FROM t1;
57c1	c2
58100	0
59101	1
60102	2
61103	3
62COMMIT;
63'T3'
64SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
65SELECT * FROM t1;;
66'T2'
67SET DEBUG_SYNC='now SIGNAL waiting1';
68'Signalled T3'
69'T3'
70c1	c2
710	0
721	1
732	2
743	3
75'T3'
76SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
77SELECT * FROM t2;;
78'T2'
79SET DEBUG_SYNC='now SIGNAL waiting1';
80'Signalled T3'
81'T3'
82c1	c2
830	a
841	b
852	c
863	d
87'T1'
88SET AUTOCOMMIT=0;
89BEGIN;
90SELECT * FROM t1;
91c1	c2
92100	0
93101	1
94102	2
95103	3
96'T2'
97SET AUTOCOMMIT=0;
98BEGIN;
99SELECT * FROM t2;
100c1	c2
101100	a
102101	b
103102	c
104103	d
105UPDATE t2 SET c1 = c1 + 100;
106SELECT * FROM t2;
107c1	c2
108200	a
109201	b
110202	c
111203	d
112COMMIT;
113'T3'
114SET AUTOCOMMIT=0;
115SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
116BEGIN;
117SELECT * FROM t1;
118c1	c2
119100	0
120101	1
121102	2
122103	3
123SELECT * FROM t2;
124c1	c2
125200	a
126201	b
127202	c
128203	d
129'T1'
130UPDATE t1 SET c1 = c1 + 100;
131SELECT * FROM t1;
132c1	c2
133200	0
134201	1
135202	2
136203	3
137COMMIT;
138'T3'
139SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
140SELECT * FROM t1;;
141'T2'
142SET DEBUG_SYNC='now SIGNAL waiting1';
143'Signalled T3'
144'T3'
145c1	c2
146100	0
147101	1
148102	2
149103	3
150'T3'
151SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
152SELECT * FROM t2;;
153'T2'
154SET DEBUG_SYNC='now SIGNAL waiting1';
155'Signalled T3'
156'T3'
157c1	c2
158200	a
159201	b
160202	c
161203	d
162DROP TABLE t1;
163DROP TABLE t2;
164#
165# Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
166#
167# connection con1
168CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
169INSERT INTO t1 values (1, 0), (2, 0);
170SELECT * FROM t1 ORDER BY col1;
171col1	col2
1721	0
1732	0
174START TRANSACTION;
175UPDATE t1 SET col2 = 100;
176SET DEBUG_SYNC = 'after_trx_committed_in_memory SIGNAL s1 WAIT_FOR s2';
177COMMIT;;
178# connection default
179SET DEBUG_SYNC = 'now WAIT_FOR s1';
180UPDATE t1 SET col2 = col2 + 10 where col1 = 1;
181COMMIT;
182SELECT * FROM t1 ORDER BY col1;
183col1	col2
1841	110
1852	100
186SET DEBUG_SYNC = 'now SIGNAL s2';
187# connection con1
188# reap COMMIT for con1
189# connection default
190DROP TABLE t1;
191SET DEBUG_SYNC= 'RESET';
192