1
by brian
clean slate |
1 |
# include/unsafe_binlog.inc |
2 |
#
|
|
3 |
# The variable |
|
4 |
# $engine_type -- storage engine to be tested |
|
5 |
# has to be set before sourcing this script. |
|
6 |
#
|
|
7 |
# Notes: |
|
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. |
|
13 |
#
|
|
14 |
# Last update: |
|
15 |
# 2006-08-02 ML test refactored |
|
16 |
# old name was innodb_unsafe_binlog.test |
|
17 |
# main code went into include/unsafe_binlog.inc |
|
18 |
#
|
|
19 |
||
20 |
#
|
|
21 |
# Test cases for bug#15650 |
|
22 |
# DELETE with LEFT JOIN crashes server with innodb_locks_unsafe_for_binlog |
|
23 |
#
|
|
24 |
||
25 |
--disable_warnings |
|
26 |
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; |
|
27 |
--enable_warnings |
|
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, ''); |
|
36 |
commit; |
|
37 |
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) |
|
38 |
where mm.id is null lock in share mode; |
|
39 |
drop table t1,t2; |
|
40 |
||
41 |
#
|
|
42 |
# Test case for unlock row bug where unlock releases all locks granted for |
|
43 |
# a row. Only the latest lock should be released. |
|
44 |
#
|
|
45 |
||
46 |
connect (a,localhost,root,,); |
|
47 |
connect (b,localhost,root,,); |
|
48 |
connection a; |
|
49 |
eval create table t1(a int not null, b int, primary key(a)) engine = $engine_type; |
|
50 |
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); |
|
51 |
commit; |
|
52 |
set autocommit = 0; |
|
53 |
select * from t1 lock in share mode; |
|
54 |
update t1 set b = 5 where b = 1; |
|
55 |
connection b; |
|
56 |
set autocommit = 0; |
|
57 |
#
|
|
58 |
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update |
|
59 |
#
|
|
60 |
--error ER_LOCK_WAIT_TIMEOUT |
|
61 |
select * from t1 where a = 2 and b = 2 for update; |
|
62 |
connection a; |
|
63 |
commit; |
|
64 |
connection b; |
|
65 |
commit; |
|
66 |
drop table t1; |
|
67 |
connection default; |
|
68 |
disconnect a; |
|
69 |
disconnect b; |
|
70 |
||
71 |
#
|
|
72 |
# unlock row test |
|
73 |
#
|
|
74 |
||
75 |
connect (a,localhost,root,,); |
|
76 |
connect (b,localhost,root,,); |
|
77 |
connection a; |
|
78 |
eval create table t1(a int not null, b int, primary key(a)) engine = $engine_type; |
|
79 |
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); |
|
80 |
commit; |
|
81 |
set autocommit = 0; |
|
82 |
update t1 set b = 5 where b = 1; |
|
83 |
connection b; |
|
84 |
set autocommit = 0; |
|
85 |
#
|
|
86 |
# X-lock to record (7,3) should be released in a update |
|
87 |
#
|
|
88 |
select * from t1 where a = 7 and b = 3 for update; |
|
89 |
commit; |
|
90 |
connection a; |
|
91 |
commit; |
|
92 |
drop table t1; |
|
93 |
connection default; |
|
94 |
disconnect a; |
|
95 |
disconnect b; |
|
96 |
||
97 |
||
98 |
#
|
|
99 |
# Consistent read should be used in following selects |
|
100 |
#
|
|
101 |
# 1) INSERT INTO ... SELECT |
|
102 |
# 2) UPDATE ... = ( SELECT ...) |
|
103 |
# 3) CREATE ... SELECT |
|
104 |
||
105 |
connect (a,localhost,root,,); |
|
106 |
connect (b,localhost,root,,); |
|
107 |
connection a; |
|
108 |
eval create table t1(a int not null, b int, primary key(a)) engine = $engine_type; |
|
109 |
insert into t1 values (1,2),(5,3),(4,2); |
|
110 |
eval create table t2(d int not null, e int, primary key(d)) engine = $engine_type; |
|
111 |
insert into t2 values (8,6),(12,1),(3,1); |
|
112 |
commit; |
|
113 |
set autocommit = 0; |
|
114 |
select * from t2 for update; |
|
115 |
connection b; |
|
116 |
set autocommit = 0; |
|
117 |
insert into t1 select * from t2; |
|
118 |
update t1 set b = (select e from t2 where a = d); |
|
1890.2.11
by Stewart Smith
use explicit COMMIT in innobase unsafe_binlog test |
119 |
COMMIT; |
1
by brian
clean slate |
120 |
eval create table t3(d int not null, e int, primary key(d)) engine = $engine_type |
121 |
select * from t2; |
|
122 |
commit; |
|
123 |
connection a; |
|
124 |
commit; |
|
125 |
connection default; |
|
126 |
disconnect a; |
|
127 |
disconnect b; |
|
128 |
drop table t1, t2, t3; |
|
129 |
||
130 |
#
|
|
131 |
# Consistent read should not be used if |
|
132 |
#
|
|
133 |
# (a) isolation level is serializable OR |
|
134 |
# (b) select ... lock in share mode OR |
|
135 |
# (c) select ... for update |
|
136 |
#
|
|
137 |
# in following queries: |
|
138 |
#
|
|
139 |
# 1) INSERT INTO ... SELECT |
|
140 |
# 2) UPDATE ... = ( SELECT ...) |
|
141 |
# 3) CREATE ... SELECT |
|
142 |
||
143 |
connect (a,localhost,root,,); |
|
144 |
connect (b,localhost,root,,); |
|
145 |
connect (c,localhost,root,,); |
|
146 |
connect (d,localhost,root,,); |
|
147 |
eval SET SESSION STORAGE_ENGINE = $engine_type; |
|
148 |
connect (e,localhost,root,,); |
|
149 |
connect (f,localhost,root,,); |
|
150 |
connect (g,localhost,root,,); |
|
151 |
eval SET SESSION STORAGE_ENGINE = $engine_type; |
|
152 |
connect (h,localhost,root,,); |
|
153 |
connect (i,localhost,root,,); |
|
154 |
connect (j,localhost,root,,); |
|
155 |
eval SET SESSION STORAGE_ENGINE = $engine_type; |
|
156 |
connection a; |
|
157 |
eval create table t1(a int not null, b int, primary key(a)) engine = $engine_type; |
|
158 |
insert into t1 values (1,2),(5,3),(4,2); |
|
159 |
eval create table t2(a int not null, b int, primary key(a)) engine = $engine_type; |
|
160 |
insert into t2 values (8,6),(12,1),(3,1); |
|
161 |
eval create table t3(d int not null, b int, primary key(d)) engine = $engine_type; |
|
162 |
insert into t3 values (8,6),(12,1),(3,1); |
|
163 |
eval create table t5(a int not null, b int, primary key(a)) engine = $engine_type; |
|
164 |
insert into t5 values (1,2),(5,3),(4,2); |
|
165 |
eval create table t6(d int not null, e int, primary key(d)) engine = $engine_type; |
|
166 |
insert into t6 values (8,6),(12,1),(3,1); |
|
167 |
eval create table t8(a int not null, b int, primary key(a)) engine = $engine_type; |
|
168 |
insert into t8 values (1,2),(5,3),(4,2); |
|
169 |
eval create table t9(d int not null, e int, primary key(d)) engine = $engine_type; |
|
170 |
insert into t9 values (8,6),(12,1),(3,1); |
|
171 |
commit; |
|
172 |
set autocommit = 0; |
|
173 |
select * from t2 for update; |
|
174 |
connection b; |
|
175 |
set autocommit = 0; |
|
176 |
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; |
|
177 |
--send |
|
178 |
insert into t1 select * from t2; |
|
179 |
connection c; |
|
180 |
set autocommit = 0; |
|
181 |
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; |
|
182 |
--send |
|
183 |
update t3 set b = (select b from t2 where a = d); |
|
184 |
connection d; |
|
185 |
set autocommit = 0; |
|
186 |
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; |
|
187 |
--send |
|
188 |
create table t4(a int not null, b int, primary key(a)) select * from t2; |
|
189 |
connection e; |
|
190 |
set autocommit = 0; |
|
191 |
--send |
|
192 |
insert into t5 (select * from t2 lock in share mode); |
|
193 |
connection f; |
|
194 |
set autocommit = 0; |
|
195 |
--send |
|
196 |
update t6 set e = (select b from t2 where a = d lock in share mode); |
|
197 |
connection g; |
|
198 |
set autocommit = 0; |
|
199 |
--send |
|
200 |
create table t7(a int not null, b int, primary key(a)) select * from t2 lock in share mode; |
|
201 |
connection h; |
|
202 |
set autocommit = 0; |
|
203 |
--send |
|
204 |
insert into t8 (select * from t2 for update); |
|
205 |
connection i; |
|
206 |
set autocommit = 0; |
|
207 |
--send |
|
208 |
update t9 set e = (select b from t2 where a = d for update); |
|
209 |
connection j; |
|
210 |
set autocommit = 0; |
|
211 |
--send |
|
212 |
create table t10(a int not null, b int, primary key(a)) select * from t2 for update; |
|
213 |
||
214 |
connection b; |
|
215 |
--error ER_LOCK_WAIT_TIMEOUT |
|
216 |
reap; |
|
217 |
||
218 |
connection c; |
|
219 |
--error ER_LOCK_WAIT_TIMEOUT |
|
220 |
reap; |
|
221 |
||
222 |
connection d; |
|
223 |
--error ER_LOCK_WAIT_TIMEOUT |
|
224 |
reap; |
|
225 |
||
226 |
connection e; |
|
227 |
--error ER_LOCK_WAIT_TIMEOUT |
|
228 |
reap; |
|
229 |
||
230 |
connection f; |
|
231 |
--error ER_LOCK_WAIT_TIMEOUT |
|
232 |
reap; |
|
233 |
||
234 |
connection g; |
|
235 |
--error ER_LOCK_WAIT_TIMEOUT |
|
236 |
reap; |
|
237 |
||
238 |
connection h; |
|
239 |
--error ER_LOCK_WAIT_TIMEOUT |
|
240 |
reap; |
|
241 |
||
242 |
connection i; |
|
243 |
--error ER_LOCK_WAIT_TIMEOUT |
|
244 |
reap; |
|
245 |
||
246 |
connection j; |
|
247 |
--error ER_LOCK_WAIT_TIMEOUT |
|
248 |
reap; |
|
249 |
||
250 |
connection a; |
|
251 |
commit; |
|
252 |
||
253 |
connection default; |
|
254 |
disconnect a; |
|
255 |
disconnect b; |
|
256 |
disconnect c; |
|
257 |
disconnect d; |
|
258 |
disconnect e; |
|
259 |
disconnect f; |
|
260 |
disconnect g; |
|
261 |
disconnect h; |
|
262 |
disconnect i; |
|
263 |
disconnect j; |
|
264 |
drop table t1, t2, t3, t5, t6, t8, t9; |