6
6
connect (reader,localhost,root,,);
7
7
connect (writer,localhost,root,,);
10
create table t1(n int);
11
insert into t1 values (1);
14
send update t1 set n = 4;
17
select count(*) = 1 from information_schema.processlist
18
where state = "Table lock" and info = "update t1 set n = 4";
19
--source include/wait_condition.inc
28
# Test problem when using locks with multi-updates
29
# It should not block when multi-update is reading on a read-locked table
33
create table t1 (a int, b int);
34
create table t2 (c int, d int);
35
insert into t1 values(1,1);
36
insert into t1 values(2,2);
37
insert into t2 values(1,2);
40
update t1,t2 set c=a where b=d;
49
# Test problem when using locks on many tables and droping a table that
50
# is to-be-locked by another thread
54
create table t1 (a int);
55
create table t2 (a int);
56
lock table t1 write, t2 write;
58
send insert t1 select * from t2;
61
select count(*) = 1 from information_schema.processlist
62
where state = "Table lock" and info = "insert t1 select * from t2";
63
--source include/wait_condition.inc
72
# Same test as above, but with the dropped table locked twice
76
create table t1 (a int);
77
create table t2 (a int);
78
lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
80
send insert t1 select * from t2;
83
select count(*) = 1 from information_schema.processlist
84
where state = "Table lock" and info = "insert t1 select * from t2";
85
--source include/wait_condition.inc
94
--echo End of 4.1 tests
97
# BUG#9998 - MySQL client hangs on USE "database"
99
create table t1(a int);
100
lock tables t1 write;
102
show columns from t1;
108
# Test if CREATE TABLE with LOCK TABLE deadlocks.
111
CREATE TABLE t1 (c1 int);
114
# This waits until t1 is unlocked.
116
send FLUSH TABLES WITH READ LOCK;
120
select count(*) = 1 from information_schema.processlist
121
where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
122
--source include/wait_condition.inc
123
# This must not block.
124
CREATE TABLE t2 (c1 int);
135
# Test if CREATE TABLE SELECT with LOCK TABLE deadlocks.
138
CREATE TABLE t1 (c1 int);
141
# This waits until t1 is unlocked.
143
send FLUSH TABLES WITH READ LOCK;
145
# This must not block.
148
select count(*) = 1 from information_schema.processlist
149
where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
150
--source include/wait_condition.inc
152
CREATE TABLE t2 AS SELECT * FROM t1;
164
10
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
198
44
--error ER_DB_DROP_EXISTS
199
45
DROP DATABASE mysqltest_1;
202
# Bug #17264: MySQL Server freeze
205
# Disable warnings to allow test to run also without InnoDB
207
create table t1 (f1 int not null auto_increment, primary key(f1)) engine=innodb;
209
lock tables t1 write;
211
send alter table t1 auto_increment=0;
214
select count(*) = 1 from information_schema.processlist
215
where state = "Table lock" and info = "alter table t1 auto_increment=0";
216
--source include/wait_condition.inc
217
send alter table t1 auto_increment=0;
220
select count(*) = 2 from information_schema.processlist
221
where state = "Table lock" and info = "alter table t1 auto_increment=0";
222
--source include/wait_condition.inc
231
--echo End of 5.0 tests
234
## Bug #21281 "Pending write lock is incorrectly removed when its
235
## statement being KILLed"
237
#create table t1 (i int);
241
#--send update t1 set i= 10;
243
#let $wait_condition=
244
# select count(*) = 1 from information_schema.processlist
245
# where state = "Table lock" and info = "update t1 set i= 10";
246
#--source include/wait_condition.inc
247
#--send select * from t1;
249
#let $wait_condition=
250
# select count(*) = 1 from information_schema.processlist
251
# where state = "Table lock" and info = "select * from t1";
252
#--source include/wait_condition.inc
253
#let $ID= `select id from information_schema.processlist where state = "Table lock" and info = "update t1 set i= 10"`;
254
#--replace_result $ID ID
255
#eval kill query $ID;
259
#--error ER_QUERY_INTERRUPTED
267
# Bug#32395 Alter table under a impending global read lock causes a server crash
271
# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK
275
drop table if exists t1;
277
create table t1 (i int);
278
connect (flush,localhost,root,,test,,);
280
--echo connection: default
281
lock tables t1 write;
283
--echo connection: flush
284
--send flush tables with read lock;
286
--echo connection: default
288
select count(*) = 1 from information_schema.processlist
289
where state = "Flushing tables";
290
--source include/wait_condition.inc
291
alter table t1 add column j int;
292
connect (insert,localhost,root,,test,,);
294
--echo connection: insert
296
select count(*) = 1 from information_schema.processlist
297
where state = "Flushing tables";
298
--source include/wait_condition.inc
299
--send insert into t1 values (1,2);
300
--echo connection: default
303
select count(*) = 1 from information_schema.processlist
304
where state = "Waiting for release of readlock";
305
--source include/wait_condition.inc
308
--echo connection: flush
311
select count(*) = 1 from information_schema.processlist
312
where state = "Waiting for release of readlock";
313
--source include/wait_condition.inc
320
select count(*) = 1 from t1;
321
--source include/wait_condition.inc
328
# Test that FLUSH TABLES under LOCK TABLES protects write locked tables
329
# from a impending FLUSH TABLES WITH READ LOCK
333
drop table if exists t1;
335
create table t1 (i int);
336
connect (flush,localhost,root,,test,,);
338
--echo connection: default
339
lock tables t1 write;
341
--echo connection: flush
342
--send flush tables with read lock;
344
--echo connection: default
346
select count(*) = 1 from information_schema.processlist
347
where state = "Flushing tables";
348
--source include/wait_condition.inc
351
select count(*) = 1 from information_schema.processlist
352
where state = "Flushing tables";
353
--source include/wait_condition.inc
356
select count(*) = 0 from information_schema.processlist
357
where state = "Flushing tables";
358
--source include/wait_condition.inc
366
# Bug#30331: Table_locks_waited shows inaccurate values
370
drop table if exists t1,t2;
372
create table t1 (a int);
375
let $tlwa= `show status like 'Table_locks_waited'`;
376
connect (waiter,localhost,root,,);
378
send insert into t1 values(1);
381
select count(*) = 1 from information_schema.processlist
382
where state = "Table lock" and info = "insert into t1 values(1)";
383
--source include/wait_condition.inc
384
let $tlwb= `show status like 'Table_locks_waited'`;
390
eval SET @tlwa= SUBSTRING_INDEX('$tlwa', ' ', -1);
391
eval SET @tlwb= SUBSTRING_INDEX('$tlwb', ' ', -1);
393
select @tlwa < @tlwb;
395
47
--echo End of 5.1 tests
398
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
403
drop table if exists t1;
405
create table t1 (i int);
406
connect (flush,localhost,root,,test,,);
408
--echo connection: default
409
lock tables t1 write;
411
--echo connection: flush
412
--send flush tables with read lock;
414
--echo connection: default
416
select count(*) = 1 from information_schema.processlist
417
where state = "Flushing tables";
418
--source include/wait_condition.inc
421
select count(*) = 1 from information_schema.processlist
422
where state = "Flushing tables";
423
--source include/wait_condition.inc
426
select count(*) = 0 from information_schema.processlist
427
where state = "Flushing tables";
428
--source include/wait_condition.inc