~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
233
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
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
258
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;
291
292
#
293
# Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one
294
#
295
--disable_warnings
296
drop table if exists t1;
297
--enable_warnings
298
create table t1 (a int) ENGINE=MEMORY;
299
--echo --> client 2
300
connection locker;
301
--error 1031
302
handler t1 open;
303
--echo --> client 1
304
connection default;
305
drop table t1;
306
307
#
308
# Bug#32395 Alter table under a impending global read lock causes a server crash
309
#
310
311
#
312
# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK
313
#
314
315
--disable_warnings
316
drop table if exists t1;
317
--enable_warnings
318
create table t1 (i int);
319
connect (flush,localhost,root,,test,,);
320
connection default;
321
--echo connection: default
322
lock tables t1 write;
323
connection flush;
324
--echo connection: flush
325
--send flush tables with read lock;
326
connection default;
327
--echo connection: default
328
let $wait_condition=
329
  select count(*) = 1 from information_schema.processlist
330
  where state = "Flushing tables";
331
--source include/wait_condition.inc
332
alter table t1 add column j int;
333
connect (insert,localhost,root,,test,,);
334
connection insert;
335
--echo connection: insert
336
let $wait_condition=
337
  select count(*) = 1 from information_schema.processlist
338
  where state = "Flushing tables";
339
--source include/wait_condition.inc
340
--send insert into t1 values (1,2);
341
--echo connection: default
342
connection default;
343
let $wait_condition=
344
  select count(*) = 1 from information_schema.processlist
345
  where state = "Waiting for release of readlock";
346
--source include/wait_condition.inc
347
unlock tables;
348
connection flush;
349
--echo connection: flush
350
--reap
351
let $wait_condition=
352
  select count(*) = 1 from information_schema.processlist
353
  where state = "Waiting for release of readlock";
354
--source include/wait_condition.inc
355
select * from t1;
356
unlock tables;
357
connection insert;
358
--reap
359
connection default;
360
let $wait_condition=
361
  select count(*) = 1 from t1;
362
--source include/wait_condition.inc
363
select * from t1;
364
drop table t1;
365
disconnect flush;
366
disconnect insert;
367
368
#
369
# Test that FLUSH TABLES under LOCK TABLES protects write locked tables
370
# from a impending FLUSH TABLES WITH READ LOCK
371
#
372
373
--disable_warnings
374
drop table if exists t1;
375
--enable_warnings
376
create table t1 (i int);
377
connect (flush,localhost,root,,test,,);
378
connection default;
379
--echo connection: default
380
lock tables t1 write;
381
connection flush;
382
--echo connection: flush
383
--send flush tables with read lock;
384
connection default;
385
--echo connection: default
386
let $wait_condition=
387
  select count(*) = 1 from information_schema.processlist
388
  where state = "Flushing tables";
389
--source include/wait_condition.inc
390
flush tables;
391
let $wait_condition=
392
  select count(*) = 1 from information_schema.processlist
393
  where state = "Flushing tables";
394
--source include/wait_condition.inc
395
unlock tables;
396
let $wait_condition=
397
  select count(*) = 0 from information_schema.processlist
398
  where state = "Flushing tables";
399
--source include/wait_condition.inc
400
connection flush;
401
--reap
402
connection default;
403
disconnect flush;
404
drop table t1;
405
406
#
407
# Bug#30331: Table_locks_waited shows inaccurate values
408
#
409
410
--disable_warnings
411
drop table if exists t1,t2;
412
--enable_warnings
413
create table t1 (a int);
414
flush status;
415
lock tables t1 read;
416
let $tlwa= `show status like 'Table_locks_waited'`;
417
connect (waiter,localhost,root,,);
418
connection waiter;
419
send insert into t1 values(1);
420
connection default;
421
let $wait_condition=
422
  select count(*) = 1 from information_schema.processlist
423
  where state = "Table lock" and info = "insert into t1 values(1)";
424
--source include/wait_condition.inc
425
let $tlwb= `show status like 'Table_locks_waited'`;
426
unlock tables;
427
drop table t1;
428
disconnect waiter;
429
connection default;
430
--disable_query_log
431
eval SET @tlwa= SUBSTRING_INDEX('$tlwa', '	', -1);
432
eval SET @tlwb= SUBSTRING_INDEX('$tlwb', '	', -1);
433
--enable_query_log
434
select @tlwa < @tlwb;
435
436
--echo End of 5.1 tests
437
438
#
439
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
440
# WITH READ LOCK
441
#
442
443
--disable_warnings
444
drop table if exists t1;
445
--enable_warnings
446
create table t1 (i int);
447
connect (flush,localhost,root,,test,,);
448
connection default;
449
--echo connection: default
450
lock tables t1 write;
451
connection flush;
452
--echo connection: flush
453
--send flush tables with read lock;
454
connection default;
455
--echo connection: default
456
let $wait_condition=
457
  select count(*) = 1 from information_schema.processlist
458
  where state = "Flushing tables";
459
--source include/wait_condition.inc
460
flush tables;
461
let $wait_condition=
462
  select count(*) = 1 from information_schema.processlist
463
  where state = "Flushing tables";
464
--source include/wait_condition.inc
465
drop table t1;
466
let $wait_condition=
467
  select count(*) = 0 from information_schema.processlist
468
  where state = "Flushing tables";
469
--source include/wait_condition.inc
470
connection flush;
471
--reap
472
connection default;
473
disconnect flush;