1
-- source include/not_embedded.inc
3
drop table if exists t1,t2;
6
# Test to see if select will get the lock ahead of low priority update
8
connect (locker,localhost,root,,);
9
connect (reader,localhost,root,,);
10
connect (writer,localhost,root,,);
13
create table t1(n int);
14
insert into t1 values (1);
17
send update low_priority t1 set n = 4;
20
select count(*) = 1 from information_schema.processlist
21
where state = "Table lock" and info = "update low_priority t1 set n = 4";
22
--source include/wait_condition.inc
23
send select n from t1;
26
select count(*) = 1 from information_schema.processlist
27
where state = "Table lock" and info = "select n from t1";
28
--source include/wait_condition.inc
37
create table t1(n int);
38
insert into t1 values (1);
41
send update low_priority t1 set n = 4;
44
select count(*) = 1 from information_schema.processlist
45
where state = "Table lock" and info = "update low_priority t1 set n = 4";
46
--source include/wait_condition.inc
55
# Test problem when using locks with multi-updates
56
# It should not block when multi-update is reading on a read-locked table
60
create table t1 (a int, b int);
61
create table t2 (c int, d int);
62
insert into t1 values(1,1);
63
insert into t1 values(2,2);
64
insert into t2 values(1,2);
67
update t1,t2 set c=a where b=d;
76
# Test problem when using locks on many tables and droping a table that
77
# is to-be-locked by another thread
81
create table t1 (a int);
82
create table t2 (a int);
83
lock table t1 write, t2 write;
85
send insert t1 select * from t2;
88
select count(*) = 1 from information_schema.processlist
89
where state = "Table lock" and info = "insert t1 select * from t2";
90
--source include/wait_condition.inc
99
# Same test as above, but with the dropped table locked twice
103
create table t1 (a int);
104
create table t2 (a int);
105
lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
107
send insert t1 select * from t2;
110
select count(*) = 1 from information_schema.processlist
111
where state = "Table lock" and info = "insert t1 select * from t2";
112
--source include/wait_condition.inc
121
--echo End of 4.1 tests
124
# BUG#9998 - MySQL client hangs on USE "database"
126
create table t1(a int);
127
lock tables t1 write;
129
show columns from t1;
135
# Test if CREATE TABLE with LOCK TABLE deadlocks.
138
CREATE TABLE t1 (c1 int);
141
# This waits until t1 is unlocked.
143
send FLUSH TABLES WITH READ LOCK;
147
select count(*) = 1 from information_schema.processlist
148
where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
149
--source include/wait_condition.inc
150
# This must not block.
151
CREATE TABLE t2 (c1 int);
162
# Test if CREATE TABLE SELECT with LOCK TABLE deadlocks.
165
CREATE TABLE t1 (c1 int);
168
# This waits until t1 is unlocked.
170
send FLUSH TABLES WITH READ LOCK;
172
# This must not block.
175
select count(*) = 1 from information_schema.processlist
176
where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
177
--source include/wait_condition.inc
179
CREATE TABLE t2 AS SELECT * FROM t1;
191
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
193
connect (con1,localhost,root,,);
194
connect (con2,localhost,root,,);
197
CREATE DATABASE mysqltest_1;
198
FLUSH TABLES WITH READ LOCK;
200
# With bug in place: acquire LOCK_mysql_create_table and
201
# wait in wait_if_global_read_lock().
203
send DROP DATABASE mysqltest_1;
205
# With bug in place: try to acquire LOCK_mysql_create_table...
206
# When fixed: Reject dropping db because of the read lock.
209
select count(*) = 1 from information_schema.processlist
210
where state = "Waiting for release of readlock"
211
and info = "DROP DATABASE mysqltest_1";
212
--source include/wait_condition.inc
213
--error ER_CANT_UPDATE_WITH_READLOCK
214
DROP DATABASE mysqltest_1;
223
# This must have been dropped by connection 2 already,
224
# which waited until the global read lock was released.
225
--error ER_DB_DROP_EXISTS
226
DROP DATABASE mysqltest_1;
229
# Bug #17264: MySQL Server freeze
232
# Disable warnings to allow test to run also without InnoDB
234
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
236
lock tables t1 write;
238
send alter table t1 auto_increment=0;
241
select count(*) = 1 from information_schema.processlist
242
where state = "Table lock" and info = "alter table t1 auto_increment=0";
243
--source include/wait_condition.inc
244
send alter table t1 auto_increment=0;
247
select count(*) = 2 from information_schema.processlist
248
where state = "Table lock" and info = "alter table t1 auto_increment=0";
249
--source include/wait_condition.inc
258
--echo End of 5.0 tests
261
# Bug #21281 "Pending write lock is incorrectly removed when its
262
# statement being KILLed"
264
create table t1 (i int);
268
--send update t1 set i= 10;
271
select count(*) = 1 from information_schema.processlist
272
where state = "Table lock" and info = "update t1 set i= 10";
273
--source include/wait_condition.inc
274
--send select * from t1;
277
select count(*) = 1 from information_schema.processlist
278
where state = "Table lock" and info = "select * from t1";
279
--source include/wait_condition.inc
280
let $ID= `select id from information_schema.processlist where state = "Table lock" and info = "update t1 set i= 10"`;
281
--replace_result $ID ID
286
--error ER_QUERY_INTERRUPTED
294
# Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one
297
drop table if exists t1;
299
create table t1 (a int) ENGINE=MEMORY;
309
# Bug#32395 Alter table under a impending global read lock causes a server crash
313
# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK
317
drop table if exists t1;
319
create table t1 (i int);
320
connect (flush,localhost,root,,test,,);
322
--echo connection: default
323
lock tables t1 write;
325
--echo connection: flush
326
--send flush tables with read lock;
328
--echo connection: default
330
select count(*) = 1 from information_schema.processlist
331
where state = "Flushing tables";
332
--source include/wait_condition.inc
333
alter table t1 add column j int;
334
connect (insert,localhost,root,,test,,);
336
--echo connection: insert
338
select count(*) = 1 from information_schema.processlist
339
where state = "Flushing tables";
340
--source include/wait_condition.inc
341
--send insert into t1 values (1,2);
342
--echo connection: default
345
select count(*) = 1 from information_schema.processlist
346
where state = "Waiting for release of readlock";
347
--source include/wait_condition.inc
350
--echo connection: flush
353
select count(*) = 1 from information_schema.processlist
354
where state = "Waiting for release of readlock";
355
--source include/wait_condition.inc
362
select count(*) = 1 from t1;
363
--source include/wait_condition.inc
370
# Test that FLUSH TABLES under LOCK TABLES protects write locked tables
371
# from a impending FLUSH TABLES WITH READ LOCK
375
drop table if exists t1;
377
create table t1 (i int);
378
connect (flush,localhost,root,,test,,);
380
--echo connection: default
381
lock tables t1 write;
383
--echo connection: flush
384
--send flush tables with read lock;
386
--echo connection: default
388
select count(*) = 1 from information_schema.processlist
389
where state = "Flushing tables";
390
--source include/wait_condition.inc
393
select count(*) = 1 from information_schema.processlist
394
where state = "Flushing tables";
395
--source include/wait_condition.inc
398
select count(*) = 0 from information_schema.processlist
399
where state = "Flushing tables";
400
--source include/wait_condition.inc
408
# Bug#30331: Table_locks_waited shows inaccurate values
412
drop table if exists t1,t2;
414
create table t1 (a int);
417
let $tlwa= `show status like 'Table_locks_waited'`;
418
connect (waiter,localhost,root,,);
420
send insert into t1 values(1);
423
select count(*) = 1 from information_schema.processlist
424
where state = "Table lock" and info = "insert into t1 values(1)";
425
--source include/wait_condition.inc
426
let $tlwb= `show status like 'Table_locks_waited'`;
432
eval SET @tlwa= SUBSTRING_INDEX('$tlwa', ' ', -1);
433
eval SET @tlwb= SUBSTRING_INDEX('$tlwb', ' ', -1);
435
select @tlwa < @tlwb;
437
--echo End of 5.1 tests
440
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
445
drop table if exists t1;
447
create table t1 (i int);
448
connect (flush,localhost,root,,test,,);
450
--echo connection: default
451
lock tables t1 write;
453
--echo connection: flush
454
--send flush tables with read lock;
456
--echo connection: default
458
select count(*) = 1 from information_schema.processlist
459
where state = "Flushing tables";
460
--source include/wait_condition.inc
463
select count(*) = 1 from information_schema.processlist
464
where state = "Flushing tables";
465
--source include/wait_condition.inc
468
select count(*) = 0 from information_schema.processlist
469
where state = "Flushing tables";
470
--source include/wait_condition.inc