~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/lock_multi.test

  • Committer: Brian Aker
  • Date: 2009-06-05 23:10:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1055.
  • Revision ID: brian@gaz-20090605231006-01nyw7pfpj2z2v8p
Remove guts in parser for LOCK TABLE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
connect (reader,localhost,root,,);
7
7
connect (writer,localhost,root,,);
8
8
 
9
 
connection locker;
10
 
create table t1(n int);
11
 
insert into t1 values (1);
12
 
lock tables t1 read;
13
 
connection writer;
14
 
send update t1 set n = 4;
15
 
connection reader;
16
 
let $wait_condition=
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
20
 
select n from t1;
21
 
connection locker;
22
 
unlock tables;
23
 
connection writer;
24
 
reap;
25
 
drop table t1;
26
 
 
27
 
#
28
 
# Test problem when using locks with multi-updates
29
 
# It should not block when multi-update is reading on a read-locked table
30
 
#
31
 
 
32
 
connection locker;
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);
38
 
lock table t1 read;
39
 
connection writer;
40
 
update t1,t2 set c=a where b=d;
41
 
connection reader;
42
 
select c from t2;
43
 
connection locker;
44
 
unlock tables;
45
 
drop table t1;
46
 
drop table t2;
47
 
 
48
 
#
49
 
# Test problem when using locks on many tables and droping a table that
50
 
# is to-be-locked by another thread
51
 
#
52
 
#
53
 
connection locker;
54
 
create table t1 (a int);
55
 
create table t2 (a int);
56
 
lock table t1 write, t2 write;
57
 
connection reader;
58
 
send insert t1 select * from t2;
59
 
connection locker;
60
 
let $wait_condition=
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
64
 
drop table t2;
65
 
connection reader;
66
 
--error 1146
67
 
reap;
68
 
connection locker;
69
 
drop table t1;
70
 
 
71
 
#
72
 
# Same test as above, but with the dropped table locked twice
73
 
#
74
 
 
75
 
connection locker;
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;
79
 
connection reader;
80
 
send insert t1 select * from t2;
81
 
connection locker;
82
 
let $wait_condition=
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
86
 
drop table t2;
87
 
connection reader;
88
 
--error 1146
89
 
reap;
90
 
connection locker;
91
 
drop table t1;
92
 
 
93
 
 
94
 
--echo End of 4.1 tests
95
 
 
96
 
#
97
 
# BUG#9998 - MySQL client hangs on USE "database"
98
 
#
99
 
create table t1(a int);
100
 
lock tables t1 write;
101
 
connection reader;
102
 
show columns from t1;
103
 
connection locker;
104
 
unlock tables;
105
 
drop table t1;
106
 
 
107
 
#
108
 
# Test if CREATE TABLE with LOCK TABLE deadlocks.
109
 
#
110
 
connection writer;
111
 
CREATE TABLE t1 (c1 int);
112
 
LOCK TABLE t1 WRITE;
113
 
#
114
 
# This waits until t1 is unlocked.
115
 
connection locker;
116
 
send FLUSH TABLES WITH READ LOCK;
117
 
#
118
 
connection writer;
119
 
let $wait_condition=
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);
125
 
UNLOCK TABLES;
126
 
#
127
 
# This awakes now.
128
 
connection locker;
129
 
reap;
130
 
UNLOCK TABLES;
131
 
#
132
 
connection default;
133
 
DROP TABLE t1, t2;
134
 
#
135
 
# Test if CREATE TABLE SELECT with LOCK TABLE deadlocks.
136
 
#
137
 
connection writer;
138
 
CREATE TABLE t1 (c1 int);
139
 
LOCK TABLE t1 WRITE;
140
 
#
141
 
# This waits until t1 is unlocked.
142
 
connection locker;
143
 
send FLUSH TABLES WITH READ LOCK;
144
 
#
145
 
# This must not block.
146
 
connection writer;
147
 
let $wait_condition=
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
151
 
--error 1100
152
 
CREATE TABLE t2 AS SELECT * FROM t1;
153
 
UNLOCK TABLES;
154
 
#
155
 
# This awakes now.
156
 
connection locker;
157
 
reap;
158
 
UNLOCK TABLES;
159
 
#
160
 
connection default;
161
 
DROP TABLE t1;
162
 
 
163
9
#
164
10
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
165
11
#
198
44
--error ER_DB_DROP_EXISTS
199
45
DROP DATABASE mysqltest_1;
200
46
 
201
 
#
202
 
# Bug #17264: MySQL Server freeze
203
 
#
204
 
connection locker;
205
 
# Disable warnings to allow test to run also without InnoDB
206
 
--disable_warnings
207
 
create table t1 (f1 int not null auto_increment, primary key(f1)) engine=innodb;
208
 
--enable_warnings
209
 
lock tables t1 write;
210
 
connection writer;
211
 
send alter table t1 auto_increment=0;
212
 
connection reader;
213
 
let $wait_condition=
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;
218
 
connection locker;
219
 
let $wait_condition=
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
223
 
unlock tables;
224
 
connection writer;
225
 
reap;
226
 
connection reader;
227
 
reap;
228
 
connection locker;
229
 
drop table t1;
230
 
#
231
 
--echo End of 5.0 tests
232
 
# See bug 314871
233
 
##
234
 
## Bug #21281 "Pending write lock is incorrectly removed when its
235
 
##             statement being KILLed"
236
 
##
237
 
#create table t1 (i int);
238
 
#connection locker;
239
 
#lock table t1 read;
240
 
#connection writer;
241
 
#--send update t1 set i= 10;
242
 
#connection reader;
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;
248
 
#connection default;
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;
256
 
#connection reader;
257
 
#--reap
258
 
#connection writer;
259
 
#--error ER_QUERY_INTERRUPTED 
260
 
#--reap
261
 
#connection locker;
262
 
#unlock tables;
263
 
#connection default;
264
 
#drop table t1;
265
 
 
266
 
#
267
 
# Bug#32395 Alter table under a impending global read lock causes a server crash
268
 
#
269
 
 
270
 
#
271
 
# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK
272
 
#
273
 
 
274
 
--disable_warnings
275
 
drop table if exists t1;
276
 
--enable_warnings
277
 
create table t1 (i int);
278
 
connect (flush,localhost,root,,test,,);
279
 
connection default;
280
 
--echo connection: default
281
 
lock tables t1 write;
282
 
connection flush;
283
 
--echo connection: flush
284
 
--send flush tables with read lock;
285
 
connection default;
286
 
--echo connection: default
287
 
let $wait_condition=
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,,);
293
 
connection insert;
294
 
--echo connection: insert
295
 
let $wait_condition=
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
301
 
connection default;
302
 
let $wait_condition=
303
 
  select count(*) = 1 from information_schema.processlist
304
 
  where state = "Waiting for release of readlock";
305
 
--source include/wait_condition.inc
306
 
unlock tables;
307
 
connection flush;
308
 
--echo connection: flush
309
 
--reap
310
 
let $wait_condition=
311
 
  select count(*) = 1 from information_schema.processlist
312
 
  where state = "Waiting for release of readlock";
313
 
--source include/wait_condition.inc
314
 
select * from t1;
315
 
unlock tables;
316
 
connection insert;
317
 
--reap
318
 
connection default;
319
 
let $wait_condition=
320
 
  select count(*) = 1 from t1;
321
 
--source include/wait_condition.inc
322
 
select * from t1;
323
 
drop table t1;
324
 
disconnect flush;
325
 
disconnect insert;
326
 
 
327
 
#
328
 
# Test that FLUSH TABLES under LOCK TABLES protects write locked tables
329
 
# from a impending FLUSH TABLES WITH READ LOCK
330
 
#
331
 
 
332
 
--disable_warnings
333
 
drop table if exists t1;
334
 
--enable_warnings
335
 
create table t1 (i int);
336
 
connect (flush,localhost,root,,test,,);
337
 
connection default;
338
 
--echo connection: default
339
 
lock tables t1 write;
340
 
connection flush;
341
 
--echo connection: flush
342
 
--send flush tables with read lock;
343
 
connection default;
344
 
--echo connection: default
345
 
let $wait_condition=
346
 
  select count(*) = 1 from information_schema.processlist
347
 
  where state = "Flushing tables";
348
 
--source include/wait_condition.inc
349
 
flush tables;
350
 
let $wait_condition=
351
 
  select count(*) = 1 from information_schema.processlist
352
 
  where state = "Flushing tables";
353
 
--source include/wait_condition.inc
354
 
unlock tables;
355
 
let $wait_condition=
356
 
  select count(*) = 0 from information_schema.processlist
357
 
  where state = "Flushing tables";
358
 
--source include/wait_condition.inc
359
 
connection flush;
360
 
--reap
361
 
connection default;
362
 
disconnect flush;
363
 
drop table t1;
364
 
 
365
 
#
366
 
# Bug#30331: Table_locks_waited shows inaccurate values
367
 
#
368
 
 
369
 
--disable_warnings
370
 
drop table if exists t1,t2;
371
 
--enable_warnings
372
 
create table t1 (a int);
373
 
flush status;
374
 
lock tables t1 read;
375
 
let $tlwa= `show status like 'Table_locks_waited'`;
376
 
connect (waiter,localhost,root,,);
377
 
connection waiter;
378
 
send insert into t1 values(1);
379
 
connection default;
380
 
let $wait_condition=
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'`;
385
 
unlock tables;
386
 
drop table t1;
387
 
disconnect waiter;
388
 
connection default;
389
 
--disable_query_log
390
 
eval SET @tlwa= SUBSTRING_INDEX('$tlwa', '      ', -1);
391
 
eval SET @tlwb= SUBSTRING_INDEX('$tlwb', '      ', -1);
392
 
--enable_query_log
393
 
select @tlwa < @tlwb;
394
 
 
395
47
--echo End of 5.1 tests
396
 
 
397
 
#
398
 
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
399
 
# WITH READ LOCK
400
 
#
401
 
 
402
 
--disable_warnings
403
 
drop table if exists t1;
404
 
--enable_warnings
405
 
create table t1 (i int);
406
 
connect (flush,localhost,root,,test,,);
407
 
connection default;
408
 
--echo connection: default
409
 
lock tables t1 write;
410
 
connection flush;
411
 
--echo connection: flush
412
 
--send flush tables with read lock;
413
 
connection default;
414
 
--echo connection: default
415
 
let $wait_condition=
416
 
  select count(*) = 1 from information_schema.processlist
417
 
  where state = "Flushing tables";
418
 
--source include/wait_condition.inc
419
 
flush tables;
420
 
let $wait_condition=
421
 
  select count(*) = 1 from information_schema.processlist
422
 
  where state = "Flushing tables";
423
 
--source include/wait_condition.inc
424
 
drop table t1;
425
 
let $wait_condition=
426
 
  select count(*) = 0 from information_schema.processlist
427
 
  where state = "Flushing tables";
428
 
--source include/wait_condition.inc
429
 
connection flush;
430
 
--reap
431
 
connection default;
432
 
disconnect flush;