1 # include/unsafe_binlog.inc
4 # $engine_type -- storage engine to be tested
5 # has to be set before sourcing this script.
8 # 1. This test uses at least in case of InnoDB options
9 # innodb_locks_unsafe_for_binlog = true
10 # innodb_lock_timeout = 5
11 # 2. The comments/expectations refer to InnoDB.
12 # They might be not valid for other storage engines.
15 # 2006-08-02 ML test refactored
16 # old name was innodb_unsafe_binlog.test
17 # main code went into include/unsafe_binlog.inc
21 # Test cases for bug#15650
22 # DELETE with LEFT JOIN crashes server with innodb_locks_unsafe_for_binlog
26 drop
table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
28 eval create
table t1 (
id int not null, f_id
int not null, f
int not null,
29 primary key(f_id,
id)) engine = $engine_type;
30 eval create
table t2 (
id int not null,s_id
int not null,s varchar(200),
31 primary key(
id)) engine = $engine_type;
32 INSERT INTO t1 VALUES (8, 1, 3);
33 INSERT INTO t1 VALUES (1, 2, 1);
34 INSERT INTO t2 VALUES (1, 0, '');
35 INSERT INTO t2 VALUES (8, 1, '');
37 DELETE ml.* FROM t1 AS ml LEFT
JOIN t2 AS mm ON (mm.
id=ml.
id)
39 select ml.* from t1 as ml left join t2 as mm on (mm.
id=ml.
id)
40 where mm.
id is null lock in share
mode;
44 # Test case for unlock row bug where unlock releases all locks granted for
45 # a row. Only the latest lock should be released.
48 connect (a,localhost,root,,);
49 connect (b,localhost,root,,);
51 eval create
table t1(a
int not null, b
int, primary key(a)) engine = $engine_type;
52 insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
55 select * from t1 lock in share mode;
56 update t1 set b = 5 where b = 1;
60 # S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
62 --error ER_LOCK_WAIT_TIMEOUT
63 select * from t1 where a = 2 and b = 2
for update;
77 connect (a,localhost,root,,);
78 connect (b,localhost,root,,);
80 eval create
table t1(a
int not null, b
int, primary key(a)) engine = $engine_type;
81 insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
84 update t1 set b = 5 where b = 1;
88 # X-lock to record (7,3) should be released in a update
90 select * from t1 where a = 7 and b = 3
for update;
101 # Consistent read should be used in following selects
103 # 1) INSERT INTO ... SELECT
104 # 2) UPDATE ... = ( SELECT ...)
105 # 3) CREATE ... SELECT
107 connect (a,localhost,root,,);
108 connect (b,localhost,root,,);
110 eval create
table t1(a
int not null, b
int, primary key(a)) engine = $engine_type;
111 insert into t1 values (1,2),(5,3),(4,2);
112 eval create
table t2(d
int not null, e
int, primary key(d)) engine = $engine_type;
113 insert into t2 values (8,6),(12,1),(3,1);
116 select * from t2 for update;
119 insert into t1 select * from t2;
120 update t1 set b = (select e from t2 where a = d);
121 eval create
table t3(d
int not null, e
int, primary key(d)) engine = $engine_type
129 drop
table t1, t2, t3;
132 # Consistent read should not be used if
134 # (a) isolation level is serializable OR
135 # (b) select ... lock in share mode OR
136 # (c) select ... for update
138 # in following queries:
140 # 1) INSERT INTO ... SELECT
141 # 2) UPDATE ... = ( SELECT ...)
142 # 3) CREATE ... SELECT
144 connect (a,localhost,root,,);
145 connect (b,localhost,root,,);
146 connect (c,localhost,root,,);
147 connect (d,localhost,root,,);
148 eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
149 connect (e,localhost,root,,);
150 connect (f,localhost,root,,);
151 connect (g,localhost,root,,);
152 eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
153 connect (h,localhost,root,,);
154 connect (
i,localhost,root,,);
155 connect (j,localhost,root,,);
156 eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
158 eval create
table t1(a
int not null, b
int, primary key(a)) engine = $engine_type;
159 insert into t1 values (1,2),(5,3),(4,2);
160 eval create
table t2(a
int not null, b
int, primary key(a)) engine = $engine_type;
161 insert into t2 values (8,6),(12,1),(3,1);
162 eval create
table t3(d
int not null, b
int, primary key(d)) engine = $engine_type;
163 insert into t3 values (8,6),(12,1),(3,1);
164 eval create
table t5(a
int not null, b
int, primary key(a)) engine = $engine_type;
165 insert into t5 values (1,2),(5,3),(4,2);
166 eval create
table t6(d
int not null, e
int, primary key(d)) engine = $engine_type;
167 insert into t6 values (8,6),(12,1),(3,1);
168 eval create
table t8(a
int not null, b
int, primary key(a)) engine = $engine_type;
169 insert into t8 values (1,2),(5,3),(4,2);
170 eval create
table t9(d
int not null, e
int, primary key(d)) engine = $engine_type;
171 insert into t9 values (8,6),(12,1),(3,1);
174 select * from t2 for update;
177 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
179 insert into t1 select * from t2;
182 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
184 update t3 set b = (select b from t2 where a = d);
187 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
189 create
table t4(a
int not null, b
int, primary key(a)) select * from t2;
193 insert into t5 (select * from t2 lock in share mode);
197 update t6 set e = (select b from t2 where a = d lock in share mode);
201 create
table t7(a
int not null, b
int, primary key(a)) select * from t2 lock in share mode;
205 insert into t8 (select * from t2 for update);
209 update t9 set e = (select b from t2 where a = d for update);
213 create
table t10(a
int not null, b
int, primary key(a)) select * from t2 for update;
216 --error ER_LOCK_WAIT_TIMEOUT
220 --error ER_LOCK_WAIT_TIMEOUT
224 --error ER_LOCK_WAIT_TIMEOUT
228 --error ER_LOCK_WAIT_TIMEOUT
232 --error ER_LOCK_WAIT_TIMEOUT
236 --error ER_LOCK_WAIT_TIMEOUT
240 --error ER_LOCK_WAIT_TIMEOUT
244 --error ER_LOCK_WAIT_TIMEOUT
248 --error ER_CANT_UPDATE_TABLE_IN_CREATE_TABLE_SELECT
265 drop
table t1, t2, t3, t5, t6, t8, t9;