~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/include/unsafe_binlog.inc

Extracted the LOAD command into its own class and implementation files.
Removed the corresponding case label from the switch statement.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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);
119
 
eval create table t3(d int not null, e int, primary key(d)) engine = $engine_type
120
 
select * from t2;
121
 
commit;
122
 
connection a;
123
 
commit;
124
 
connection default;
125
 
disconnect a;
126
 
disconnect b;
127
 
drop table t1, t2, t3;
128
 
 
129
 
#
130
 
# Consistent read should not be used if
131
 
#
132
 
# (a) isolation level is serializable OR
133
 
# (b) select ... lock in share mode OR
134
 
# (c) select ... for update
135
 
#
136
 
# in following queries:
137
 
#
138
 
# 1) INSERT INTO ... SELECT
139
 
# 2) UPDATE ... = ( SELECT ...)
140
 
# 3) CREATE ... SELECT
141
 
 
142
 
connect (a,localhost,root,,);
143
 
connect (b,localhost,root,,);
144
 
connect (c,localhost,root,,);
145
 
connect (d,localhost,root,,);
146
 
eval SET SESSION STORAGE_ENGINE = $engine_type;
147
 
connect (e,localhost,root,,);
148
 
connect (f,localhost,root,,);
149
 
connect (g,localhost,root,,);
150
 
eval SET SESSION STORAGE_ENGINE = $engine_type;
151
 
connect (h,localhost,root,,);
152
 
connect (i,localhost,root,,);
153
 
connect (j,localhost,root,,);
154
 
eval SET SESSION STORAGE_ENGINE = $engine_type;
155
 
connection a;
156
 
eval create table t1(a int not null, b int, primary key(a)) engine = $engine_type;
157
 
insert into t1 values (1,2),(5,3),(4,2);
158
 
eval create table t2(a int not null, b int, primary key(a)) engine = $engine_type;
159
 
insert into t2 values (8,6),(12,1),(3,1);
160
 
eval create table t3(d int not null, b int, primary key(d)) engine = $engine_type;
161
 
insert into t3 values (8,6),(12,1),(3,1);
162
 
eval create table t5(a int not null, b int, primary key(a)) engine = $engine_type;
163
 
insert into t5 values (1,2),(5,3),(4,2);
164
 
eval create table t6(d int not null, e int, primary key(d)) engine = $engine_type;
165
 
insert into t6 values (8,6),(12,1),(3,1);
166
 
eval create table t8(a int not null, b int, primary key(a)) engine = $engine_type;
167
 
insert into t8 values (1,2),(5,3),(4,2);
168
 
eval create table t9(d int not null, e int, primary key(d)) engine = $engine_type;
169
 
insert into t9 values (8,6),(12,1),(3,1);
170
 
commit;
171
 
set autocommit = 0;
172
 
select * from t2 for update;
173
 
connection b;
174
 
set autocommit = 0;
175
 
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
176
 
--send
177
 
insert into t1 select * from t2;
178
 
connection c;
179
 
set autocommit = 0;
180
 
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
181
 
--send
182
 
update t3 set b = (select b from t2 where a = d);
183
 
connection d;
184
 
set autocommit = 0;
185
 
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
186
 
--send
187
 
create table t4(a int not null, b int, primary key(a)) select * from t2;
188
 
connection e;
189
 
set autocommit = 0;
190
 
--send
191
 
insert into t5 (select * from t2 lock in share mode);
192
 
connection f;
193
 
set autocommit = 0;
194
 
--send
195
 
update t6 set e = (select b from t2 where a = d lock in share mode);
196
 
connection g;
197
 
set autocommit = 0;
198
 
--send
199
 
create table t7(a int not null, b int, primary key(a)) select * from t2 lock in share mode;
200
 
connection h;
201
 
set autocommit = 0;
202
 
--send
203
 
insert into t8 (select * from t2 for update);
204
 
connection i;
205
 
set autocommit = 0;
206
 
--send
207
 
update t9 set e = (select b from t2 where a = d for update);
208
 
connection j;
209
 
set autocommit = 0;
210
 
--send
211
 
create table t10(a int not null, b int, primary key(a)) select * from t2 for update;
212
 
 
213
 
connection b;
214
 
--error ER_LOCK_WAIT_TIMEOUT
215
 
reap;
216
 
 
217
 
connection c;
218
 
--error ER_LOCK_WAIT_TIMEOUT
219
 
reap;
220
 
 
221
 
connection d;
222
 
--error ER_LOCK_WAIT_TIMEOUT
223
 
reap;
224
 
 
225
 
connection e;
226
 
--error ER_LOCK_WAIT_TIMEOUT
227
 
reap;
228
 
 
229
 
connection f;
230
 
--error ER_LOCK_WAIT_TIMEOUT
231
 
reap;
232
 
 
233
 
connection g;
234
 
--error ER_LOCK_WAIT_TIMEOUT
235
 
reap;
236
 
 
237
 
connection h;
238
 
--error ER_LOCK_WAIT_TIMEOUT
239
 
reap;
240
 
 
241
 
connection i;
242
 
--error ER_LOCK_WAIT_TIMEOUT
243
 
reap;
244
 
 
245
 
connection j;
246
 
--error ER_LOCK_WAIT_TIMEOUT
247
 
reap;
248
 
 
249
 
connection a;
250
 
commit;
251
 
 
252
 
connection default;
253
 
disconnect a;
254
 
disconnect b;
255
 
disconnect c;
256
 
disconnect d;
257
 
disconnect e;
258
 
disconnect f;
259
 
disconnect g;
260
 
disconnect h;
261
 
disconnect i;
262
 
disconnect j;
263
 
drop table t1, t2, t3, t5, t6, t8, t9;