~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/t/delayed.test

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# delayed works differently in embedded server
 
2
--source include/not_embedded.inc
 
3
#
 
4
# test of DELAYED insert and timestamps
 
5
# (Can't be tested with purify :( )
 
6
#
 
7
 
 
8
--disable_warnings
 
9
drop table if exists t1;
 
10
--enable_warnings
 
11
create table t1 (a char(10), tmsp timestamp);
 
12
insert into t1 set a = 1;
 
13
insert delayed into t1 set a = 2;
 
14
insert into t1 set a = 3, tmsp=NULL;
 
15
insert delayed into t1 set a = 4;
 
16
insert delayed into t1 set a = 5, tmsp = 19711006010203;
 
17
insert delayed into t1 (a, tmsp) values (6, 19711006010203);
 
18
insert delayed into t1 (a, tmsp) values (7, NULL);
 
19
# Wait until the rows are flushed to the table files.
 
20
FLUSH TABLE t1;
 
21
insert into t1 set a = 8,tmsp=19711006010203;
 
22
select * from t1 where tmsp=0;
 
23
select * from t1 where tmsp=19711006010203;
 
24
drop table t1;
 
25
 
 
26
#
 
27
# Test bug when inserting NULL into an auto_increment field with
 
28
# INSERT DELAYED
 
29
#
 
30
 
 
31
create table t1 (a int not null auto_increment primary key, b char(10));
 
32
insert delayed into t1 values (1,"b");
 
33
insert delayed into t1 values (null,"c");
 
34
insert delayed into t1 values (3,"d"),(null,"e");
 
35
--error 1136
 
36
insert delayed into t1 values (3,"this will give an","error");
 
37
# Wait until the rows are flushed to the table files.
 
38
FLUSH TABLE t1;
 
39
show status like 'not_flushed_delayed_rows';
 
40
select * from t1;
 
41
drop table t1;
 
42
 
 
43
# End of 4.1 tests
 
44
 
 
45
#
 
46
# Bug #12226: Crash when a delayed insert fails due to a duplicate key
 
47
#
 
48
create table t1 (a int not null primary key);
 
49
insert into t1 values (1);
 
50
insert delayed into t1 values (1);
 
51
select * from t1;
 
52
drop table t1;
 
53
 
 
54
#
 
55
# Bug #20195: INSERT DELAYED with auto_increment is assigned wrong values
 
56
#
 
57
CREATE TABLE t1 ( a int(10) NOT NULL auto_increment, PRIMARY KEY (a));
 
58
 
 
59
# Make one delayed insert to start the separate thread
 
60
insert delayed into t1 values(null);
 
61
 
 
62
# Do some normal inserts
 
63
insert into t1 values(null);
 
64
insert into t1 values(null);
 
65
 
 
66
# Discarded, since the delayed-counter is 2, which is already used
 
67
insert delayed into t1 values(null);
 
68
 
 
69
# Discarded, since the delayed-counter is 3, which is already used
 
70
insert delayed into t1 values(null);
 
71
 
 
72
# Works, since the delayed-counter is 4, which is unused
 
73
insert delayed into t1 values(null);
 
74
 
 
75
# Do some more inserts
 
76
insert into t1 values(null);
 
77
insert into t1 values(null);
 
78
insert into t1 values(null);
 
79
 
 
80
# Delete one of the above to make a hole
 
81
delete from t1 where a=6;
 
82
 
 
83
# Discarded, since the delayed-counter is 5, which is already used
 
84
insert delayed into t1 values(null);
 
85
 
 
86
# Works, since the delayed-counter is 6, which is unused (the row we deleted)
 
87
insert delayed into t1 values(null);
 
88
 
 
89
# Discarded, since the delayed-counter is 7, which is already used
 
90
insert delayed into t1 values(null);
 
91
 
 
92
# Works, since the delayed-counter is 8, which is unused
 
93
insert delayed into t1 values(null);
 
94
 
 
95
# Wait until the rows are flushed to the table files.
 
96
FLUSH TABLE t1;
 
97
# Check what we have now
 
98
select * from t1 order by a;
 
99
 
 
100
DROP TABLE t1;
 
101
 
 
102
#
 
103
# Bug#20627 - INSERT DELAYED does not honour auto_increment_* variables
 
104
#
 
105
SET @bug20627_old_auto_increment_offset=
 
106
                @@auto_increment_offset;
 
107
SET @bug20627_old_auto_increment_increment=
 
108
                @@auto_increment_increment;
 
109
SET @bug20627_old_session_auto_increment_offset=
 
110
                @@session.auto_increment_offset;
 
111
SET @bug20627_old_session_auto_increment_increment=
 
112
                @@session.auto_increment_increment;
 
113
SET @@auto_increment_offset= 2;
 
114
SET @@auto_increment_increment= 3;
 
115
SET @@session.auto_increment_offset= 4;
 
116
SET @@session.auto_increment_increment= 5;
 
117
#
 
118
# Normal insert as reference.
 
119
CREATE TABLE t1 (
 
120
  c1 INT NOT NULL AUTO_INCREMENT,
 
121
  PRIMARY KEY (c1)
 
122
  );
 
123
INSERT INTO t1 VALUES (NULL),(NULL),(NULL);
 
124
# Check what we have now
 
125
SELECT * FROM t1;
 
126
DROP TABLE t1;
 
127
#
 
128
# Delayed insert.
 
129
CREATE TABLE t1 (
 
130
  c1 INT NOT NULL AUTO_INCREMENT,
 
131
  PRIMARY KEY (c1)
 
132
  );
 
133
INSERT DELAYED INTO t1 VALUES (NULL),(NULL),(NULL);
 
134
# Wait until the rows are flushed to the table files.
 
135
FLUSH TABLE t1;
 
136
# Check what we have now
 
137
SELECT * FROM t1;
 
138
DROP TABLE t1;
 
139
#
 
140
# Cleanup
 
141
SET             @@auto_increment_offset=
 
142
    @bug20627_old_auto_increment_offset;
 
143
SET             @@auto_increment_increment=
 
144
    @bug20627_old_auto_increment_increment;
 
145
SET             @@session.auto_increment_offset=
 
146
    @bug20627_old_session_auto_increment_offset;
 
147
SET             @@session.auto_increment_increment=
 
148
    @bug20627_old_session_auto_increment_increment;
 
149
 
 
150
#
 
151
# Bug#20830 - INSERT DELAYED does not honour SET INSERT_ID
 
152
#
 
153
SET @bug20830_old_auto_increment_offset=
 
154
                @@auto_increment_offset;
 
155
SET @bug20830_old_auto_increment_increment=
 
156
                @@auto_increment_increment;
 
157
SET @bug20830_old_session_auto_increment_offset=
 
158
                @@session.auto_increment_offset;
 
159
SET @bug20830_old_session_auto_increment_increment=
 
160
                @@session.auto_increment_increment;
 
161
SET @@auto_increment_offset= 2;
 
162
SET @@auto_increment_increment= 3;
 
163
SET @@session.auto_increment_offset= 4;
 
164
SET @@session.auto_increment_increment= 5;
 
165
#
 
166
# Normal insert as reference.
 
167
CREATE TABLE t1 (
 
168
  c1 INT(11) NOT NULL AUTO_INCREMENT,
 
169
  c2 INT(11) DEFAULT NULL,
 
170
  PRIMARY KEY (c1)
 
171
  );
 
172
SET insert_id= 14;
 
173
INSERT INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13);
 
174
INSERT INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23);
 
175
# Restart sequence at a different value.
 
176
INSERT INTO t1 VALUES(  69, 31), (NULL, 32), (NULL, 33);
 
177
INSERT INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43);
 
178
# Restart sequence at a different value.
 
179
SET insert_id= 114;
 
180
INSERT INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53);
 
181
INSERT INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63);
 
182
# Set one value below the maximum value.
 
183
INSERT INTO t1 VALUES(  49, 71), (NULL, 72), (NULL, 73);
 
184
INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83);
 
185
# Create a duplicate value.
 
186
SET insert_id= 114;
 
187
--error ER_DUP_ENTRY
 
188
INSERT INTO t1 VALUES(NULL, 91);
 
189
INSERT INTO t1 VALUES           (NULL, 92), (NULL, 93);
 
190
# Check what we have now
 
191
SELECT * FROM t1;
 
192
SELECT COUNT(*) FROM t1;
 
193
SELECT SUM(c1) FROM t1;
 
194
DROP TABLE t1;
 
195
#
 
196
# Delayed insert.
 
197
CREATE TABLE t1 (
 
198
  c1 INT(11) NOT NULL AUTO_INCREMENT,
 
199
  c2 INT(11) DEFAULT NULL,
 
200
  PRIMARY KEY (c1)
 
201
  );
 
202
SET insert_id= 14;
 
203
INSERT DELAYED INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13);
 
204
INSERT DELAYED INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23);
 
205
# Restart sequence at a different value.
 
206
INSERT DELAYED INTO t1 VALUES(  69, 31), (NULL, 32), (NULL, 33);
 
207
INSERT DELAYED INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43);
 
208
# Restart sequence at a different value.
 
209
SET insert_id= 114;
 
210
INSERT DELAYED INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53);
 
211
INSERT DELAYED INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63);
 
212
# Set one value below the maximum value.
 
213
INSERT DELAYED INTO t1 VALUES(  49, 71), (NULL, 72), (NULL, 73);
 
214
INSERT DELAYED INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83);
 
215
# Create a duplicate value.
 
216
SET insert_id= 114;
 
217
INSERT DELAYED INTO t1 VALUES(NULL, 91);
 
218
INSERT DELAYED INTO t1 VALUES           (NULL, 92), (NULL, 93);
 
219
# Wait until the rows are flushed to the table files.
 
220
FLUSH TABLE t1;
 
221
# Check what we have now
 
222
SELECT * FROM t1;
 
223
SELECT COUNT(*) FROM t1;
 
224
SELECT SUM(c1) FROM t1;
 
225
DROP TABLE t1;
 
226
#
 
227
# Cleanup
 
228
SET             @@auto_increment_offset=
 
229
    @bug20830_old_auto_increment_offset;
 
230
SET             @@auto_increment_increment=
 
231
    @bug20830_old_auto_increment_increment;
 
232
SET             @@session.auto_increment_offset=
 
233
    @bug20830_old_session_auto_increment_offset;
 
234
SET             @@session.auto_increment_increment=
 
235
    @bug20830_old_session_auto_increment_increment;
 
236
 
 
237
#
 
238
# BUG#26238 - inserted delayed always inserts 0 for BIT columns
 
239
#
 
240
CREATE TABLE t1(a BIT);
 
241
INSERT DELAYED INTO t1 VALUES(1);
 
242
FLUSH TABLE t1;
 
243
SELECT HEX(a) FROM t1;
 
244
DROP TABLE t1;
 
245
 
 
246
#
 
247
# Bug #32676: insert delayed crash with wrong column and function specified
 
248
#
 
249
CREATE TABLE t1 (a INT);
 
250
--error 1305
 
251
INSERT DELAYED INTO t1 SET b= b();
 
252
DROP TABLE t1;
 
253
 
 
254
--echo End of 5.0 tests
 
255
 
 
256
#
 
257
# Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client
 
258
#
 
259
--disable_warnings
 
260
DROP TABLE IF EXISTS t1,t2;
 
261
--enable_warnings
 
262
SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
 
263
CREATE TABLE `t1` (
 
264
  `id` int(11) PRIMARY KEY auto_increment,
 
265
  `f1` varchar(10) NOT NULL UNIQUE
 
266
);
 
267
INSERT DELAYED INTO t1 VALUES(0,"test1");
 
268
sleep 1;
 
269
SELECT * FROM t1;
 
270
SET SQL_MODE='PIPES_AS_CONCAT';
 
271
INSERT DELAYED INTO t1 VALUES(0,'a' || 'b');
 
272
sleep 1;
 
273
SELECT * FROM t1;
 
274
SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES';
 
275
--error 1365
 
276
INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3");
 
277
CREATE TABLE t2 (
 
278
  `id` int(11) PRIMARY KEY auto_increment,
 
279
  `f1` date
 
280
);
 
281
SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
 
282
--error ER_TRUNCATED_WRONG_VALUE
 
283
INSERT DELAYED INTO t2 VALUES (0,'0000-00-00');
 
284
--error ER_TRUNCATED_WRONG_VALUE
 
285
INSERT DELAYED INTO t2 VALUES (0,'2007-00-00');
 
286
DROP TABLE t1,t2;
 
287
 
 
288
#
 
289
# Bug#40536: SELECT is blocked by INSERT DELAYED waiting on upgrading lock,
 
290
#            even with low_priority_updates
 
291
#
 
292
 
 
293
set @old_delayed_updates = @@global.low_priority_updates;
 
294
set global low_priority_updates = 1;
 
295
select @@global.low_priority_updates;
 
296
 
 
297
--disable_warnings
 
298
drop table if exists t1;
 
299
--enable_warnings
 
300
create table t1 (a int, b int);
 
301
insert into t1 values (1,1);
 
302
lock table t1 read;
 
303
connect (update,localhost,root,,);
 
304
connection update;
 
305
--echo connection: update
 
306
--send insert delayed into t1 values (2,2);
 
307
connection default;
 
308
let $wait_condition=
 
309
  select count(*) = 1 from information_schema.processlist
 
310
  where command = "Delayed insert" and state = "Waiting for table level lock";
 
311
--source include/wait_condition.inc
 
312
connect (select,localhost,root,,);
 
313
--echo connection: select
 
314
select * from t1;
 
315
connection default;
 
316
--echo connection: default
 
317
select * from t1;
 
318
connection default;
 
319
disconnect update;
 
320
disconnect select;
 
321
unlock tables;
 
322
let $wait_condition=
 
323
  select count(*) = 1 from information_schema.processlist
 
324
  where command = "Delayed insert" and state = "Waiting for INSERT";
 
325
--source include/wait_condition.inc
 
326
select * from t1;
 
327
drop table t1;
 
328
 
 
329
set global low_priority_updates = @old_delayed_updates;
 
330
 
 
331
 
 
332
--echo #
 
333
--echo # Bug #47682 strange behaviour of INSERT DELAYED
 
334
--echo #
 
335
 
 
336
--disable_warnings
 
337
DROP TABLE IF EXISTS t1, t2;
 
338
--enable_warnings
 
339
 
 
340
CREATE TABLE t1 (f1 integer);
 
341
CREATE TABLE t2 (f1 integer);
 
342
 
 
343
FLUSH TABLES WITH READ LOCK;
 
344
LOCK TABLES t1 READ;
 
345
 
 
346
# ER_CANT_UPDATE_WITH_READLOCK with normal execution
 
347
# ER_TABLE_NOT_LOCKED when executed as prepared statement
 
348
--error ER_CANT_UPDATE_WITH_READLOCK, ER_TABLE_NOT_LOCKED
 
349
INSERT DELAYED INTO t2 VALUES (1);
 
350
 
 
351
UNLOCK TABLES;
 
352
DROP TABLE t1, t2;
 
353
 
 
354
 
 
355
--echo End of 5.1 tests
 
356
 
 
357
 
 
358
 
 
359
--echo #
 
360
--echo # Bug #47274 assert in open_table on CREATE TABLE <already existing>
 
361
--echo #
 
362
 
 
363
--disable_warnings
 
364
DROP TABLE IF EXISTS t1;
 
365
DROP TABLE IF EXISTS t2;
 
366
--enable_warnings
 
367
 
 
368
CREATE TABLE t1 ( f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
 
369
 
 
370
--echo # The following CREATE TABLEs before gave an assert.
 
371
 
 
372
INSERT DELAYED t1 VALUES (4);
 
373
--error ER_TABLE_EXISTS_ERROR
 
374
CREATE TABLE t1 AS SELECT 1 AS f1;
 
375
 
 
376
REPLACE DELAYED t1 VALUES (5);
 
377
--error ER_TABLE_EXISTS_ERROR
 
378
CREATE TABLE t1 AS SELECT 1 AS f1;
 
379
 
 
380
INSERT DELAYED t1 VALUES (6);
 
381
--error ER_TABLE_EXISTS_ERROR
 
382
CREATE TABLE t1 (f1 INTEGER);
 
383
 
 
384
CREATE TABLE t2 (f1 INTEGER);
 
385
INSERT DELAYED t1 VALUES (7);
 
386
--error ER_TABLE_EXISTS_ERROR
 
387
CREATE TABLE t1 LIKE t2;
 
388
 
 
389
DROP TABLE t2;
 
390
DROP TABLE t1;
 
391
 
 
392
 
 
393
--echo #
 
394
--echo # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
 
395
--echo #
 
396
 
 
397
--echo # This test is not supposed to work under --ps-protocol since
 
398
--echo # INSERT DELAYED doesn't work under LOCK TABLES with this protocol.
 
399
--disable_ps_protocol
 
400
 
 
401
--disable_warnings
 
402
DROP TABLE IF EXISTS t1, t2;
 
403
--enable_warnings
 
404
 
 
405
CREATE TABLE t1 (a INT);
 
406
CREATE TABLE t2 (a INT);
 
407
CREATE TABLE t3 (a INT);
 
408
 
 
409
--echo # Test 1: Using LOCK TABLE
 
410
 
 
411
--echo # Connection con1
 
412
connect (con1, localhost, root);
 
413
LOCK TABLE t1 WRITE;
 
414
 
 
415
--echo # Connection default
 
416
connection default;
 
417
LOCK TABLE t2 WRITE;
 
418
--echo # Sending:
 
419
--send INSERT DELAYED INTO t1 VALUES (1)
 
420
 
 
421
--echo # Connection con1
 
422
connection con1;
 
423
--echo # Wait until INSERT DELAYED is blocked on table 't1'.
 
424
let $wait_condition=
 
425
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
426
  WHERE state = "Waiting for table metadata lock"
 
427
  AND info = "INSERT DELAYED INTO t1 VALUES (1)";
 
428
--source include/wait_condition.inc
 
429
--error ER_LOCK_DEADLOCK
 
430
INSERT DELAYED INTO t2 VALUES (1);
 
431
UNLOCK TABLES;
 
432
 
 
433
--echo # Connection default
 
434
connection default;
 
435
--echo # Reaping: INSERT DELAYED INTO t1 VALUES (1)
 
436
--reap
 
437
UNLOCK TABLES;
 
438
 
 
439
--echo # Test 2: Using ALTER TABLE
 
440
 
 
441
START TRANSACTION;
 
442
SELECT * FROM t1 WHERE a=0;
 
443
 
 
444
--echo # Connection con1
 
445
connection con1;
 
446
--echo # Sending:
 
447
--send ALTER TABLE t1 COMMENT 'test'
 
448
 
 
449
--echo # Connection default
 
450
connection default;
 
451
--echo # Wait until ALTER TABLE is blocked on table 't1'.
 
452
let $wait_condition=
 
453
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
454
  WHERE state = "Waiting for table metadata lock"
 
455
  AND info = "ALTER TABLE t1 COMMENT 'test'";
 
456
--source include/wait_condition.inc
 
457
--error ER_LOCK_DEADLOCK
 
458
INSERT DELAYED INTO t1 VALUES (3);
 
459
COMMIT;
 
460
 
 
461
--echo # Connection con1
 
462
connection con1;
 
463
--echo # Reaping: ALTER TABLE t1 COMMENT 'test'
 
464
--reap
 
465
 
 
466
--echo # Test 3: Using RENAME TABLE
 
467
 
 
468
--echo # Connection default
 
469
connection default;
 
470
START TRANSACTION;
 
471
INSERT INTO t2 VALUES (1);
 
472
 
 
473
--echo # Connection con1
 
474
connection con1;
 
475
--echo # Sending:
 
476
--send RENAME TABLE t1 to t5, t2 to t4
 
477
 
 
478
--echo # Connection default
 
479
connection default;
 
480
--echo # Wait until RENAME TABLE is blocked on table 't1'.
 
481
let $wait_condition=
 
482
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
483
  WHERE state = "Waiting for table metadata lock"
 
484
  AND info = "RENAME TABLE t1 to t5, t2 to t4";
 
485
--source include/wait_condition.inc
 
486
--error ER_LOCK_DEADLOCK
 
487
INSERT DELAYED INTO t1 VALUES (4);
 
488
COMMIT;
 
489
 
 
490
--echo # Connection con1
 
491
connection con1;
 
492
--echo # Reaping: RENAME TABLE t1 to t5, t2 to t4
 
493
--reap
 
494
 
 
495
--echo # Connection default
 
496
connection default;
 
497
--echo # Reverting the renames
 
498
RENAME TABLE t5 to t1, t4 to t2;
 
499
 
 
500
--echo # Test 4: Two INSERT DELAYED on the same table
 
501
 
 
502
START TRANSACTION;
 
503
INSERT INTO t2 VALUES (1);
 
504
 
 
505
--echo # Connection con2
 
506
connect (con2, localhost, root);
 
507
--send LOCK TABLE t1 WRITE, t2 WRITE
 
508
 
 
509
--echo # Connection con1
 
510
connection con1;
 
511
--echo # Wait until LOCK TABLE is blocked on table 't2'.
 
512
let $wait_condition=
 
513
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
514
  WHERE state = "Waiting for table metadata lock"
 
515
  AND info = "LOCK TABLE t1 WRITE, t2 WRITE";
 
516
--source include/wait_condition.inc
 
517
--send INSERT DELAYED INTO t1 VALUES (5)
 
518
 
 
519
--echo # Connection default
 
520
connection default;
 
521
--echo # Wait until INSERT DELAYED is blocked on table 't1'.
 
522
let $wait_condition=
 
523
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
524
  WHERE state = "Waiting for table metadata lock"
 
525
  AND info = "INSERT DELAYED INTO t1 VALUES (5)";
 
526
--source include/wait_condition.inc
 
527
--error ER_LOCK_DEADLOCK
 
528
INSERT DELAYED INTO t1 VALUES (6);
 
529
COMMIT;
 
530
 
 
531
--echo # Connection con2
 
532
connection con2;
 
533
--echo # Reaping: LOCK TABLE t1 WRITE, t2 WRITE
 
534
--reap
 
535
UNLOCK TABLES;
 
536
 
 
537
--echo # Connection con1
 
538
connection con1;
 
539
--echo # Reaping: INSERT DELAYED INTO t1 VALUES (5)
 
540
--reap
 
541
 
 
542
--echo # Connection default
 
543
connection default;
 
544
 
 
545
--echo # Test 5: LOCK TABLES + INSERT DELAYED in one connection.
 
546
--echo # This test has triggered some asserts in metadata locking
 
547
--echo # subsystem at some point in time..
 
548
LOCK TABLE t1 WRITE;
 
549
INSERT DELAYED INTO t2 VALUES (7);
 
550
UNLOCK TABLES;
 
551
SET AUTOCOMMIT= 0;
 
552
LOCK TABLE t1 WRITE;
 
553
INSERT DELAYED INTO t2 VALUES (8);
 
554
UNLOCK TABLES;
 
555
SET AUTOCOMMIT= 1;
 
556
 
 
557
--echo # Connection con2
 
558
connection con2;
 
559
disconnect con2;
 
560
--source include/wait_until_disconnected.inc
 
561
--echo # Connection con1
 
562
connection con1;
 
563
disconnect con1;
 
564
--source include/wait_until_disconnected.inc
 
565
 
 
566
--echo # Connection default
 
567
connection default;
 
568
DROP TABLE t1, t2, t3;
 
569
--enable_ps_protocol
 
570
 
 
571
 
 
572
--echo #
 
573
--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables".
 
574
--echo #
 
575
connect (con1,localhost,root,,);
 
576
connection default;
 
577
--disable_warnings
 
578
drop table if exists t1, t2, tm;
 
579
--enable_warnings
 
580
create table t1(a int);
 
581
create table t2(a int);
 
582
create table tm(a int) engine=merge union=(t1, t2);
 
583
begin;
 
584
select * from t1;
 
585
 
 
586
--echo # Connection 'con1'.
 
587
connection con1;
 
588
--echo # Sending:
 
589
--send alter table t1 comment 'test'
 
590
 
 
591
--echo # Connection 'default'.
 
592
connection default;
 
593
--echo # Wait until ALTER TABLE blocks and starts waiting
 
594
--echo # for connection 'default'. It should wait with a
 
595
--echo # pending SNW lock on 't1'.
 
596
let $wait_condition=
 
597
  select count(*) = 1 from information_schema.processlist
 
598
  where state = "Waiting for table metadata lock" and
 
599
        info = "alter table t1 comment 'test'";
 
600
--source include/wait_condition.inc
 
601
--echo # Attempt to perform delayed insert into 'tm' should not lead
 
602
--echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should
 
603
--echo # be emitted.
 
604
--error ER_DELAYED_NOT_SUPPORTED
 
605
insert delayed into tm values (1);
 
606
--echo # Unblock ALTER TABLE.
 
607
commit;
 
608
 
 
609
--echo # Connection 'con1'.
 
610
connection con1;
 
611
--echo # Reaping ALTER TABLE:
 
612
--reap
 
613
 
 
614
disconnect con1;
 
615
--source include/wait_until_disconnected.inc
 
616
--echo # Connection 'default'.
 
617
connection default;
 
618
drop tables tm, t1, t2;
 
619
 
 
620
 
 
621
--echo #
 
622
--echo # Bug#13259227 ASSERTION TABLES->TABLE->POS_IN_TABLE_LIST
 
623
--echo #              == TABLES FAILED IN SQL_BASE.CC:4668
 
624
--echo #
 
625
 
 
626
--disable_warnings
 
627
DROP TABLE IF EXISTS t1;
 
628
--enable_warnings
 
629
 
 
630
CREATE TEMPORARY TABLE t1(a int);
 
631
--error ER_NO_SUCH_TABLE
 
632
INSERT DELAYED t1 VALUES (1); 
 
633
 
 
634
DROP TEMPORARY TABLE t1;
 
635
 
 
636
--echo #
 
637
--echo # Bug#13985071: DEPRECATE INSERT DELAYED
 
638
--echo #
 
639
 
 
640
SET GLOBAL delayed_insert_limit = 100;
 
641
SET GLOBAL delayed_insert_timeout = 300;
 
642
SET GLOBAL delayed_queue_size = 1000;
 
643
SET GLOBAL max_delayed_threads = 20;
 
644
SET GLOBAL max_insert_delayed_threads = 20;