2
drop table if exists t1,t2;
5
# Test to see if select will get the lock ahead of low priority update
7
connect (locker,localhost,root,,);
8
connect (reader,localhost,root,,);
9
connect (writer,localhost,root,,);
12
create table t1(n int);
13
insert into t1 values (1);
16
send update low_priority t1 set n = 4;
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;
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
36
create table t1(n int);
37
insert into t1 values (1);
40
send update low_priority t1 set n = 4;
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
54
# Test problem when using locks with multi-updates
55
# It should not block when multi-update is reading on a read-locked table
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);
66
update t1,t2 set c=a where b=d;
75
# Test problem when using locks on many tables and droping a table that
76
# is to-be-locked by another thread
80
create table t1 (a int);
81
create table t2 (a int);
82
lock table t1 write, t2 write;
84
send insert t1 select * from t2;
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
98
# Same test as above, but with the dropped table locked twice
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;
106
send insert t1 select * from t2;
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
120
--echo End of 4.1 tests
123
# BUG#9998 - MySQL client hangs on USE "database"
125
create table t1(a int);
126
lock tables t1 write;
128
show columns from t1;
134
# Test if CREATE TABLE with LOCK TABLE deadlocks.
137
CREATE TABLE t1 (c1 int);
140
# This waits until t1 is unlocked.
142
send FLUSH TABLES WITH READ LOCK;
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);
161
# Test if CREATE TABLE SELECT with LOCK TABLE deadlocks.
164
CREATE TABLE t1 (c1 int);
167
# This waits until t1 is unlocked.
169
send FLUSH TABLES WITH READ LOCK;
171
# This must not block.
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
178
CREATE TABLE t2 AS SELECT * FROM t1;
190
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
192
connect (con1,localhost,root,,);
193
connect (con2,localhost,root,,);
196
CREATE DATABASE mysqltest_1;
197
FLUSH TABLES WITH READ LOCK;
199
# With bug in place: acquire LOCK_mysql_create_table and
200
# wait in wait_if_global_read_lock().
202
send DROP DATABASE mysqltest_1;
204
# With bug in place: try to acquire LOCK_mysql_create_table...
205
# When fixed: Reject dropping db because of the read lock.
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;
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;
228
# Bug #17264: MySQL Server freeze
231
# Disable warnings to allow test to run also without InnoDB
233
create table t1 (f1 int(12) not null auto_increment, primary key(f1)) engine=innodb;
235
lock tables t1 write;
237
send alter table t1 auto_increment=0;
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;
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
257
--echo End of 5.0 tests
260
# Bug #21281 "Pending write lock is incorrectly removed when its
261
# statement being KILLed"
263
create table t1 (i int);
267
--send update t1 set i= 10;
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;
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
285
--error ER_QUERY_INTERRUPTED
293
# Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one
296
drop table if exists t1;
298
create table t1 (a int) ENGINE=MEMORY;
308
# Bug#32395 Alter table under a impending global read lock causes a server crash
312
# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK
316
drop table if exists t1;
318
create table t1 (i int);
319
connect (flush,localhost,root,,test,,);
321
--echo connection: default
322
lock tables t1 write;
324
--echo connection: flush
325
--send flush tables with read lock;
327
--echo connection: default
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,,);
335
--echo connection: insert
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
344
select count(*) = 1 from information_schema.processlist
345
where state = "Waiting for release of readlock";
346
--source include/wait_condition.inc
349
--echo connection: flush
352
select count(*) = 1 from information_schema.processlist
353
where state = "Waiting for release of readlock";
354
--source include/wait_condition.inc
361
select count(*) = 1 from t1;
362
--source include/wait_condition.inc
369
# Test that FLUSH TABLES under LOCK TABLES protects write locked tables
370
# from a impending FLUSH TABLES WITH READ LOCK
374
drop table if exists t1;
376
create table t1 (i int);
377
connect (flush,localhost,root,,test,,);
379
--echo connection: default
380
lock tables t1 write;
382
--echo connection: flush
383
--send flush tables with read lock;
385
--echo connection: default
387
select count(*) = 1 from information_schema.processlist
388
where state = "Flushing tables";
389
--source include/wait_condition.inc
392
select count(*) = 1 from information_schema.processlist
393
where state = "Flushing tables";
394
--source include/wait_condition.inc
397
select count(*) = 0 from information_schema.processlist
398
where state = "Flushing tables";
399
--source include/wait_condition.inc
407
# Bug#30331: Table_locks_waited shows inaccurate values
411
drop table if exists t1,t2;
413
create table t1 (a int);
416
let $tlwa= `show status like 'Table_locks_waited'`;
417
connect (waiter,localhost,root,,);
419
send insert into t1 values(1);
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'`;
431
eval SET @tlwa= SUBSTRING_INDEX('$tlwa', ' ', -1);
432
eval SET @tlwb= SUBSTRING_INDEX('$tlwb', ' ', -1);
434
select @tlwa < @tlwb;
436
--echo End of 5.1 tests
439
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
444
drop table if exists t1;
446
create table t1 (i int);
447
connect (flush,localhost,root,,test,,);
449
--echo connection: default
450
lock tables t1 write;
452
--echo connection: flush
453
--send flush tables with read lock;
455
--echo connection: default
457
select count(*) = 1 from information_schema.processlist
458
where state = "Flushing tables";
459
--source include/wait_condition.inc
462
select count(*) = 1 from information_schema.processlist
463
where state = "Flushing tables";
464
--source include/wait_condition.inc
467
select count(*) = 0 from information_schema.processlist
468
where state = "Flushing tables";
469
--source include/wait_condition.inc