~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
--disable_warnings
2
drop table if exists t1,t2;
3
--enable_warnings
4
5
# Test to see if select will get the lock ahead of low priority update
6
7
connect (locker,localhost,root,,);
8
connect (reader,localhost,root,,);
9
connect (writer,localhost,root,,);
10
11
connection locker;
12
create table t1(n int);
13
insert into t1 values (1);
14
lock tables t1 write;
15
connection writer;
16
send update low_priority t1 set n = 4;
17
connection reader;
18
let $wait_condition=
19
  select count(*) = 1 from information_schema.processlist
20
  where state = "Table lock" and info = "update low_priority t1 set n = 4";
21
--source include/wait_condition.inc
22
send select n from t1;
23
connection locker;
24
let $wait_condition=
25
  select count(*) = 1 from information_schema.processlist
26
  where state = "Table lock" and info = "select n from t1";
27
--source include/wait_condition.inc
28
unlock tables;
29
connection writer;
30
reap;
31
connection reader;
32
reap;
33
drop table t1;
34
35
connection locker;
36
create table t1(n int);
37
insert into t1 values (1);
38
lock tables t1 read;
39
connection writer;
40
send update low_priority t1 set n = 4;
41
connection reader;
42
let $wait_condition=
43
  select count(*) = 1 from information_schema.processlist
44
  where state = "Table lock" and info = "update low_priority t1 set n = 4";
45
--source include/wait_condition.inc
46
select n from t1;
47
connection locker;
48
unlock tables;
49
connection writer;
50
reap;
51
drop table t1;
52
53
#
54
# Test problem when using locks with multi-updates
55
# It should not block when multi-update is reading on a read-locked table
56
#
57
58
connection locker;
59
create table t1 (a int, b int);
60
create table t2 (c int, d int);
61
insert into t1 values(1,1);
62
insert into t1 values(2,2);
63
insert into t2 values(1,2);
64
lock table t1 read;
65
connection writer;
66
update t1,t2 set c=a where b=d;
67
connection reader;
68
select c from t2;
69
connection locker;
70
unlock tables;
71
drop table t1;
72
drop table t2;
73
74
#
75
# Test problem when using locks on many tables and droping a table that
76
# is to-be-locked by another thread
77
#
78
#
79
connection locker;
80
create table t1 (a int);
81
create table t2 (a int);
82
lock table t1 write, t2 write;
83
connection reader;
84
send insert t1 select * from t2;
85
connection locker;
86
let $wait_condition=
87
  select count(*) = 1 from information_schema.processlist
88
  where state = "Table lock" and info = "insert t1 select * from t2";
89
--source include/wait_condition.inc
90
drop table t2;
91
connection reader;
92
--error 1146
93
reap;
94
connection locker;
95
drop table t1;
96
97
#
98
# Same test as above, but with the dropped table locked twice
99
#
100
101
connection locker;
102
create table t1 (a int);
103
create table t2 (a int);
104
lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
105
connection reader;
106
send insert t1 select * from t2;
107
connection locker;
108
let $wait_condition=
109
  select count(*) = 1 from information_schema.processlist
110
  where state = "Table lock" and info = "insert t1 select * from t2";
111
--source include/wait_condition.inc
112
drop table t2;
113
connection reader;
114
--error 1146
115
reap;
116
connection locker;
117
drop table t1;
118
119
120
--echo End of 4.1 tests
121
122
#
123
# BUG#9998 - MySQL client hangs on USE "database"
124
#
125
create table t1(a int);
126
lock tables t1 write;
127
connection reader;
128
show columns from t1;
129
connection locker;
130
unlock tables;
131
drop table t1;
132
133
#
134
# Test if CREATE TABLE with LOCK TABLE deadlocks.
135
#
136
connection writer;
137
CREATE TABLE t1 (c1 int);
138
LOCK TABLE t1 WRITE;
139
#
140
# This waits until t1 is unlocked.
141
connection locker;
142
send FLUSH TABLES WITH READ LOCK;
143
#
144
connection writer;
145
let $wait_condition=
146
  select count(*) = 1 from information_schema.processlist
147
  where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
148
--source include/wait_condition.inc
149
# This must not block.
150
CREATE TABLE t2 (c1 int);
151
UNLOCK TABLES;
152
#
153
# This awakes now.
154
connection locker;
155
reap;
156
UNLOCK TABLES;
157
#
158
connection default;
159
DROP TABLE t1, t2;
160
#
161
# Test if CREATE TABLE SELECT with LOCK TABLE deadlocks.
162
#
163
connection writer;
164
CREATE TABLE t1 (c1 int);
165
LOCK TABLE t1 WRITE;
166
#
167
# This waits until t1 is unlocked.
168
connection locker;
169
send FLUSH TABLES WITH READ LOCK;
170
#
171
# This must not block.
172
connection writer;
173
let $wait_condition=
174
  select count(*) = 1 from information_schema.processlist
175
  where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
176
--source include/wait_condition.inc
177
--error 1100
178
CREATE TABLE t2 AS SELECT * FROM t1;
179
UNLOCK TABLES;
180
#
181
# This awakes now.
182
connection locker;
183
reap;
184
UNLOCK TABLES;
185
#
186
connection default;
187
DROP TABLE t1;
188
189
#
190
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
191
#
192
connect (con1,localhost,root,,);
193
connect (con2,localhost,root,,);
194
#
195
connection con1;
196
CREATE DATABASE mysqltest_1;
197
FLUSH TABLES WITH READ LOCK;
198
#
199
# With bug in place: acquire LOCK_mysql_create_table and
200
# wait in wait_if_global_read_lock().
201
connection con2;
202
send DROP DATABASE mysqltest_1;
203
#
204
# With bug in place: try to acquire LOCK_mysql_create_table...
205
# When fixed: Reject dropping db because of the read lock.
206
connection con1;
207
let $wait_condition=
208
  select count(*) = 1 from information_schema.processlist
209
  where state = "Waiting for release of readlock"
210
  and info = "DROP DATABASE mysqltest_1";
211
--source include/wait_condition.inc
212
--error ER_CANT_UPDATE_WITH_READLOCK
213
DROP DATABASE mysqltest_1;
214
UNLOCK TABLES;
215
#
216
connection con2;
217
reap;
218
#
219
connection default;
220
disconnect con1;
221
disconnect con2;
222
# This must have been dropped by connection 2 already,
223
# which waited until the global read lock was released.
224
--error ER_DB_DROP_EXISTS
225
DROP DATABASE mysqltest_1;
226
227
#
228
# Bug #17264: MySQL Server freeze
229
#
230
connection locker;
231
# Disable warnings to allow test to run also without InnoDB
232
--disable_warnings
772 by Brian Aker
Committing fix lock_multi
233
create table t1 (f1 int not null auto_increment, primary key(f1)) engine=innodb;
1 by brian
clean slate
234
--enable_warnings
235
lock tables t1 write;
236
connection writer;
237
send alter table t1 auto_increment=0;
238
connection reader;
239
let $wait_condition=
240
  select count(*) = 1 from information_schema.processlist
241
  where state = "Table lock" and info = "alter table t1 auto_increment=0";
242
--source include/wait_condition.inc
243
send alter table t1 auto_increment=0;
244
connection locker;
245
let $wait_condition=
246
  select count(*) = 2 from information_schema.processlist
247
  where state = "Table lock" and info = "alter table t1 auto_increment=0";
248
--source include/wait_condition.inc
249
unlock tables;
250
connection writer;
251
reap;
252
connection reader;
253
reap;
254
connection locker;
255
drop table t1;
256
#
257
--echo End of 5.0 tests
772 by Brian Aker
Committing fix lock_multi
258
# See bug 314871
259
##
260
## Bug #21281 "Pending write lock is incorrectly removed when its
261
##             statement being KILLed"
262
##
263
#create table t1 (i int);
264
#connection locker;
265
#lock table t1 read;
266
#connection writer;
267
#--send update t1 set i= 10;
268
#connection reader;
269
#let $wait_condition=
270
#  select count(*) = 1 from information_schema.processlist
271
#  where state = "Table lock" and info = "update t1 set i= 10";
272
#--source include/wait_condition.inc
273
#--send select * from t1;
274
#connection default;
275
#let $wait_condition=
276
#  select count(*) = 1 from information_schema.processlist
277
#  where state = "Table lock" and info = "select * from t1";
278
#--source include/wait_condition.inc
279
#let $ID= `select id from information_schema.processlist where state = "Table lock" and info = "update t1 set i= 10"`;
280
#--replace_result $ID ID
281
#eval kill query $ID;
282
#connection reader;
283
#--reap
284
#connection writer;
285
#--error ER_QUERY_INTERRUPTED 
286
#--reap
287
#connection locker;
288
#unlock tables;
289
#connection default;
290
#drop table t1;
1 by brian
clean slate
291
292
#
293
# Bug#32395 Alter table under a impending global read lock causes a server crash
294
#
295
296
#
297
# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK
298
#
299
300
--disable_warnings
301
drop table if exists t1;
302
--enable_warnings
303
create table t1 (i int);
304
connect (flush,localhost,root,,test,,);
305
connection default;
306
--echo connection: default
307
lock tables t1 write;
308
connection flush;
309
--echo connection: flush
310
--send flush tables with read lock;
311
connection default;
312
--echo connection: default
313
let $wait_condition=
314
  select count(*) = 1 from information_schema.processlist
315
  where state = "Flushing tables";
316
--source include/wait_condition.inc
317
alter table t1 add column j int;
318
connect (insert,localhost,root,,test,,);
319
connection insert;
320
--echo connection: insert
321
let $wait_condition=
322
  select count(*) = 1 from information_schema.processlist
323
  where state = "Flushing tables";
324
--source include/wait_condition.inc
325
--send insert into t1 values (1,2);
326
--echo connection: default
327
connection default;
328
let $wait_condition=
329
  select count(*) = 1 from information_schema.processlist
330
  where state = "Waiting for release of readlock";
331
--source include/wait_condition.inc
332
unlock tables;
333
connection flush;
334
--echo connection: flush
335
--reap
336
let $wait_condition=
337
  select count(*) = 1 from information_schema.processlist
338
  where state = "Waiting for release of readlock";
339
--source include/wait_condition.inc
340
select * from t1;
341
unlock tables;
342
connection insert;
343
--reap
344
connection default;
345
let $wait_condition=
346
  select count(*) = 1 from t1;
347
--source include/wait_condition.inc
348
select * from t1;
349
drop table t1;
350
disconnect flush;
351
disconnect insert;
352
353
#
354
# Test that FLUSH TABLES under LOCK TABLES protects write locked tables
355
# from a impending FLUSH TABLES WITH READ LOCK
356
#
357
358
--disable_warnings
359
drop table if exists t1;
360
--enable_warnings
361
create table t1 (i int);
362
connect (flush,localhost,root,,test,,);
363
connection default;
364
--echo connection: default
365
lock tables t1 write;
366
connection flush;
367
--echo connection: flush
368
--send flush tables with read lock;
369
connection default;
370
--echo connection: default
371
let $wait_condition=
372
  select count(*) = 1 from information_schema.processlist
373
  where state = "Flushing tables";
374
--source include/wait_condition.inc
375
flush tables;
376
let $wait_condition=
377
  select count(*) = 1 from information_schema.processlist
378
  where state = "Flushing tables";
379
--source include/wait_condition.inc
380
unlock tables;
381
let $wait_condition=
382
  select count(*) = 0 from information_schema.processlist
383
  where state = "Flushing tables";
384
--source include/wait_condition.inc
385
connection flush;
386
--reap
387
connection default;
388
disconnect flush;
389
drop table t1;
390
391
#
392
# Bug#30331: Table_locks_waited shows inaccurate values
393
#
394
395
--disable_warnings
396
drop table if exists t1,t2;
397
--enable_warnings
398
create table t1 (a int);
399
flush status;
400
lock tables t1 read;
401
let $tlwa= `show status like 'Table_locks_waited'`;
402
connect (waiter,localhost,root,,);
403
connection waiter;
404
send insert into t1 values(1);
405
connection default;
406
let $wait_condition=
407
  select count(*) = 1 from information_schema.processlist
408
  where state = "Table lock" and info = "insert into t1 values(1)";
409
--source include/wait_condition.inc
410
let $tlwb= `show status like 'Table_locks_waited'`;
411
unlock tables;
412
drop table t1;
413
disconnect waiter;
414
connection default;
415
--disable_query_log
416
eval SET @tlwa= SUBSTRING_INDEX('$tlwa', '	', -1);
417
eval SET @tlwb= SUBSTRING_INDEX('$tlwb', '	', -1);
418
--enable_query_log
419
select @tlwa < @tlwb;
420
421
--echo End of 5.1 tests
422
423
#
424
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
425
# WITH READ LOCK
426
#
427
428
--disable_warnings
429
drop table if exists t1;
430
--enable_warnings
431
create table t1 (i int);
432
connect (flush,localhost,root,,test,,);
433
connection default;
434
--echo connection: default
435
lock tables t1 write;
436
connection flush;
437
--echo connection: flush
438
--send flush tables with read lock;
439
connection default;
440
--echo connection: default
441
let $wait_condition=
442
  select count(*) = 1 from information_schema.processlist
443
  where state = "Flushing tables";
444
--source include/wait_condition.inc
445
flush tables;
446
let $wait_condition=
447
  select count(*) = 1 from information_schema.processlist
448
  where state = "Flushing tables";
449
--source include/wait_condition.inc
450
drop table t1;
451
let $wait_condition=
452
  select count(*) = 0 from information_schema.processlist
453
  where state = "Flushing tables";
454
--source include/wait_condition.inc
455
connection flush;
456
--reap
457
connection default;
458
disconnect flush;