1
################################################################################
5
# This is a derivate of t/innodb.test and has to be maintained by MySQL #
8
# Please, DO NOT create a toplevel testcase mix2_innodb.test, because #
9
# innodb.test does already these tests. #
11
# Variables which have to be set before calling this script: #
12
# $engine_type -- Storage engine to be tested #
13
# $other_engine_type -- storage engine <> $engine_type #
14
# $other_engine_type1 -- storage engine <> $engine_type #
15
# storage engine <> $other_engine_type, if possible #
16
# $other_non_trans_engine_type -- storage engine <> $engine_type #
17
# $other_non_trans_engine_type must be a non #
18
# transactional storage engine #
19
# $other_non_live_chks_engine_type #
20
# -- storage engine <> $engine_type, if possible #
21
# storage engine must not support live checksum #
22
# $other_live_chks_engine_type #
23
# -- storage engine <> $engine_type, if possible #
24
# storage engine must support live checksum #
25
# General Note: The $other_*_engine_type variables must point to all #
26
# time available storage engines #
27
# 2006-08 MySQL 5.1 MyISAM and MEMORY only #
28
# $test_transactions -- 0, skip transactional tests #
29
# -- 1, do not skip transactional tests #
30
# $test_foreign_keys -- 0, skip foreign key tests #
31
# -- 1, do not skip foreign key tests #
32
# $fulltext_query_unsupported -- 0, execute fulltext_query tests #
33
# -- 1, skip fulltext query tests #
34
# $no_autoinc_update -- 0, skip tests where it is expected that an update #
35
# does not update the internal auto-increment value#
36
# -- 1, do not skip these tests #
37
# $no_spatial_key -- 0, skip tests where it is expected that keys on #
38
# spatial data type are not allowed #
39
# -- 1, do not skip these tests #
41
# The comments/expectations refer to InnoDB. #
42
# They might be not valid for other storage engines. #
46
# 2006-08-15 ML - introduce several $variables #
47
# - correct some storage engine assignments #
48
# - minor improvements like correct wrong table after analyze #
49
# - let checksum testcase meet all table variants with/without #
50
# live checksum feature exiting and/or enabled #
51
# 2006-07-26 ML create script by using t/innodb.test and introduce $variables #
53
################################################################################
55
# Set the SESSION DEFAULT STORAGE ENGINE to a value <> storage engine
56
# to be tested. This must not affect any create $temp table statement, where
57
# the storage engine is assigned explicitely,
58
eval SET SESSION STORAGE_ENGINE = $other_engine_type;
61
# Small basic test with ignore
65
drop table if exists t1,t2,t3,t4;
66
drop database if exists mysqltest;
69
eval create $temp table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=$engine_type;
71
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
72
select id, code, name from t1 order by id;
74
update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
75
select id, code, name from t1 order by id;
76
update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
77
select id, code, name from t1 order by id;
83
# The 'replace_column' statements are needed because the cardinality calculated
84
# by innodb is not always the same between runs
87
eval create $temp table t1 (
88
id int NOT NULL auto_increment,
89
parent_id int DEFAULT '0' NOT NULL,
90
level int DEFAULT '0' NOT NULL,
92
KEY parent_id (parent_id),
94
) engine=$engine_type;
95
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
96
update t1 set parent_id=parent_id+100;
97
select * from t1 where parent_id=102;
98
update t1 set id=id+1000;
99
-- error ER_DUP_ENTRY,1022
100
update t1 set id=1024 where id=1009;
102
update ignore t1 set id=id+1; # This will change all rows
104
update ignore t1 set id=1023 where id=1010;
105
select * from t1 where parent_id=102;
107
explain select level from t1 where level=1;
109
explain select level,id from t1 where level=1;
111
explain select level,id,parent_id from t1 where level=1;
112
select level,id from t1 where level=1;
113
select level,id,parent_id from t1 where level=1;
114
eval alter table t1 engine=$engine_type;
123
eval create $temp table t1 (
124
gesuchnr int DEFAULT '0' NOT NULL,
125
benutzer_id int DEFAULT '0' NOT NULL,
126
PRIMARY KEY (gesuchnr,benutzer_id)
127
) engine=$engine_type;
129
replace into t1 (gesuchnr,benutzer_id) values (2,1);
130
replace into t1 (gesuchnr,benutzer_id) values (1,1);
131
replace into t1 (gesuchnr,benutzer_id) values (1,1);
136
# test delete using hidden_primary_key
139
eval create $temp table t1 (a int) engine=$engine_type;
140
insert into t1 values (1), (2);
141
eval alter table t1 ENGINE=$engine_type;
142
delete from t1 where a = 1;
147
eval create $temp table t1 (a int,b varchar(20)) engine=$engine_type;
148
insert into t1 values (1,""), (2,"testing");
149
delete from t1 where a = 1;
151
create index skr on t1 (a);
152
insert into t1 values (3,""), (4,"testing");
159
# Test of reading on secondary key with may be null
161
eval create $temp table t1 (a int,b varchar(20),key(a)) engine=$engine_type;
162
insert into t1 values (1,""), (2,"testing");
163
select * from t1 where a = 1;
166
if ($test_transactions)
172
eval create $temp table t1 (n int not null primary key) engine=$engine_type;
174
insert into t1 values (4);
176
select n, "after rollback" from t1;
177
insert into t1 values (4);
179
select n, "after commit" from t1;
181
insert into t1 values (5);
182
-- error ER_DUP_ENTRY
183
insert into t1 values (4);
185
select n, "after commit" from t1;
187
insert into t1 values (6);
188
-- error ER_DUP_ENTRY
189
insert into t1 values (4);
196
savepoint `my_savepoint`;
197
insert into t1 values (7);
199
insert into t1 values (3);
202
rollback to savepoint savept2;
204
rollback to savepoint savept3;
205
rollback to savepoint savept2;
206
release savepoint `my_savepoint`;
209
rollback to savepoint `my_savepoint`;
211
rollback to savepoint savept2;
212
insert into t1 values (8);
222
# Test for commit and FLUSH TABLES WITH READ LOCK
225
eval create $temp table t1 (n int not null primary key) engine=$engine_type;
227
insert into t1 values (4);
228
flush tables with read lock;
230
# Current code can't handle a read lock in middle of transaction
239
# Testing transactions
242
eval create $temp table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=$engine_type;
244
insert into t1 values(1,'hamdouni');
245
select id as afterbegin_id,nom as afterbegin_nom from t1;
247
select id as afterrollback_id,nom as afterrollback_nom from t1;
249
insert into t1 values(2,'mysql');
250
select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
252
select id as afterrollback_id,nom as afterrollback_nom from t1;
257
# Simple not autocommit test
260
eval create $temp table t1 (id char(8) not null primary key, val int not null) engine=$engine_type;
261
insert into t1 values ('pippo', 12);
262
-- error ER_DUP_ENTRY
263
insert into t1 values ('pippo', 12); # Gives error
265
delete from t1 where id = 'pippo';
268
insert into t1 values ('pippo', 12);
279
# Test of active transactions
282
eval create $temp table t1 (a integer) engine=$engine_type;
284
rename table t1 to t2;
285
eval create $temp table t1 (b integer) engine=$engine_type;
286
insert into t1 values (1);
289
rename table t2 to t1;
294
# The following simple tests failed at some point
297
eval create $temp table t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=$engine_type;
298
INSERT INTO t1 VALUES (1, 'Jochen');
302
eval create $temp table t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=$engine_type;
304
INSERT INTO t1 SET _userid='marc@anyware.co.uk';
307
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
312
# End of transactional tests
315
# Test when reading on part of unique key
317
eval create $temp table t1 (
318
user_id int DEFAULT '0' NOT NULL,
321
ref_email varchar(100) DEFAULT '' NOT NULL,
323
PRIMARY KEY (user_id,ref_email)
324
)engine=$engine_type;
326
INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
327
select * from t1 where user_id=10292;
328
INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
329
select * from t1 where user_id=10292;
330
select * from t1 where user_id>=10292;
331
select * from t1 where user_id>10292;
332
select * from t1 where user_id<10292;
336
# Test that keys are created in right order
339
eval create $temp table t1 (a int not null, b int not null,c int not null,
340
key(a),primary key(a,b), unique(c),key(a),unique(b)) ENGINE = $engine_type;
346
# Test of ALTER TABLE and innodb tables
349
eval create $temp table t1 (col1 int not null, col2 char(4) not null, primary key(col1)) ENGINE = $other_engine_type;
350
eval alter table t1 engine=$engine_type;
351
insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
353
update t1 set col2='7' where col1='4';
355
alter table t1 add co3 int not null;
357
update t1 set col2='9' where col1='2';
362
# INSERT INTO innodb tables
365
eval create $temp table t1 (a int not null , b int, primary key (a)) engine = $engine_type;
366
eval create $temp table t2 (a int not null , b int, primary key (a)) engine = $other_engine_type;
367
insert into t1 VALUES (1,3) , (2,3), (3,3);
369
insert into t2 select * from t1;
371
delete from t1 where b = 3;
373
insert into t1 select * from t2;
379
# Search on unique key
382
eval create $temp table t1 (
383
id int NOT NULL auto_increment,
384
ggid varchar(32) DEFAULT '' NOT NULL,
385
email varchar(64) DEFAULT '' NOT NULL,
386
passwd varchar(32) DEFAULT '' NOT NULL,
389
) ENGINE=$engine_type;
391
insert into t1 (ggid,passwd) values ('test1','xxx');
392
insert into t1 (ggid,passwd) values ('test2','yyy');
393
-- error ER_DUP_ENTRY
394
insert into t1 (ggid,passwd) values ('test2','this will fail');
395
-- error ER_DUP_ENTRY
396
insert into t1 (ggid,id) values ('this will fail',1);
398
select * from t1 where ggid='test1';
399
select * from t1 where passwd='xxx';
400
select * from t1 where id=2;
402
replace into t1 (ggid,id) values ('this will work',1);
403
replace into t1 (ggid,passwd) values ('test2','this will work');
404
-- error ER_DUP_ENTRY
405
update t1 set id=100,ggid='test2' where id=1;
407
select * from t1 where id=1;
408
select * from t1 where id=999;
412
# ORDER BY on not primary key
415
eval create $temp table t1 (
416
user_name varchar(12),
419
user_id int DEFAULT '0' NOT NULL,
424
dummy_primary_key int NOT NULL auto_increment,
425
PRIMARY KEY (dummy_primary_key)
426
) ENGINE=$engine_type;
427
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','2000-09-07 23:06:59',1);
428
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','2000-09-07 23:06:59',2);
429
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','2000-09-07 23:06:59',3);
430
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','2000-09-07 23:06:59',4);
431
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','2000-09-07 23:06:59',5);
432
select user_name, password , subscribed, user_id, quota, weight, access_date, approved, dummy_primary_key from t1 order by user_name;
436
# Testing of tables without primary keys
439
eval create $temp table t1 (
440
id int NOT NULL auto_increment,
441
parent_id int DEFAULT '0' NOT NULL,
442
level int DEFAULT '0' NOT NULL,
444
KEY parent_id (parent_id),
446
) engine=$engine_type;
447
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
448
INSERT INTO t1 values (179,5,2);
449
update t1 set parent_id=parent_id+100;
450
select * from t1 where parent_id=102;
451
update t1 set id=id+1000;
452
update t1 set id=1024 where id=1009;
454
update ignore t1 set id=id+1; # This will change all rows
456
update ignore t1 set id=1023 where id=1010;
457
select * from t1 where parent_id=102;
459
explain select level from t1 where level=1;
460
select level,id from t1 where level=1;
461
select level,id,parent_id from t1 where level=1;
462
select level,id from t1 where level=1 order by id;
463
delete from t1 where level=1;
468
# Test of index only reads
470
eval create $temp table t1 (
471
sca_code char(6) NOT NULL,
472
cat_code char(6) NOT NULL,
473
sca_desc varchar(50),
474
lan_code char(2) NOT NULL,
475
sca_pic varchar(100),
476
sca_sdesc varchar(50),
477
sca_sch_desc varchar(16),
478
PRIMARY KEY (sca_code, cat_code, lan_code),
479
INDEX sca_pic (sca_pic)
480
) engine = $engine_type ;
482
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
483
select count(*) from t1 where sca_code = 'PD';
484
select count(*) from t1 where sca_code <= 'PD';
485
select count(*) from t1 where sca_pic is null;
486
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
487
select count(*) from t1 where sca_code='PD' and sca_pic is null;
488
select count(*) from t1 where cat_code='E';
490
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
491
select count(*) from t1 where sca_code='PD' and sca_pic is null;
492
select count(*) from t1 where sca_pic >= 'n';
493
select sca_pic from t1 where sca_pic is null;
494
update t1 set sca_pic="test" where sca_pic is null;
495
delete from t1 where sca_code='pd';
499
# Test of opening table twice and timestamps
505
eval create $temp table t1 (a int not null, b timestamp not null, primary key (a)) engine=$engine_type;
506
insert into t1 (a) values(1),(2),(3);
507
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
508
select a from t1 natural join t1 as t2 where b >= @a order by a;
509
update t1 set a=5 where a=1;
514
# Test with variable length primary key
516
eval create $temp table t1 (a varchar(100) not null, primary key(a), b int not null) engine=$engine_type;
517
insert into t1 values("hello",1),("world",2);
518
select * from t1 order by b desc;
519
eval alter table t1 ENGINE=$engine_type;
525
# Test of create index with NULL columns
527
eval create $temp table t1 (i int, j int ) ENGINE=$engine_type;
528
insert into t1 values (1,2);
529
select * from t1 where i=1 and j=2;
530
create index ax1 on t1 (i,j);
531
select * from t1 where i=1 and j=2;
535
# Test min-max optimization
538
eval create $temp table t1 (
542
) ENGINE = $engine_type;
544
INSERT INTO t1 VALUES (1, 1);
545
SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
549
# Test INSERT DELAYED
552
eval create $temp table t1 (a int NOT NULL) engine=$engine_type;
553
# Can't test this in 3.23
554
# INSERT DELAYED INTO t1 VALUES (1);
555
INSERT INTO t1 VALUES (1);
561
# Crash when using many tables (Test case by Jeremy D Zawodny)
564
eval create $temp table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = $engine_type;
565
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
567
explain select * from t1 where a > 0 and a < 50;
573
eval create $temp table t1 (a char(20), unique (a(5))) engine=$engine_type;
575
eval create $temp table t1 (a char(20), index (a(5))) engine=$engine_type;
576
show create table t1;
580
# Test using temporary table and auto_increment
583
eval create temporary table t1 (a int not null auto_increment, primary key(a)) engine=$engine_type;
584
insert into t1 values (NULL),(NULL),(NULL);
585
delete from t1 where a=3;
586
insert into t1 values (NULL);
588
alter table t1 add b int;
593
eval create $temp table t1
595
id int auto_increment primary key,
596
name varchar(32) not null,
600
) engine=$engine_type;
601
insert into t1 values (1,'one','one value',101),
602
(2,'two','two value',102),(3,'three','three value',103);
603
replace into t1 (value,name,uid) values ('other value','two',102);
604
delete from t1 where uid=102;
605
replace into t1 (value,name,uid) values ('other value','two',102);
606
replace into t1 (value,name,uid) values ('other value','two',102);
614
# Check that the creation of a table with engine = $engine_type does
615
# in a certain database (already containing some tables using other
616
# storage engines) not prevent the dropping of this database.
618
create database mysqltest;
619
eval create $temp table mysqltest.t1 (a int not null) engine= $engine_type;
620
insert into mysqltest.t1 values(1);
621
eval create $temp table mysqltest.t2 (a int not null) engine= $other_engine_type;
622
insert into mysqltest.t2 values(1);
623
eval create $temp table mysqltest.t3 (a int not null) engine= $other_engine_type1;
624
insert into mysqltest.t3 values(1);
626
drop database mysqltest;
627
# Don't check error message
629
show tables from mysqltest;
632
# Test truncate table with and without auto_commit
636
eval create $temp table t1 (a int not null) engine= $engine_type;
637
insert into t1 values(1),(2);
643
insert into t1 values(1),(2);
650
eval create $temp table t1 (a int not null) engine= $engine_type;
651
insert into t1 values(1),(2);
653
insert into t1 values(1),(2);
656
insert into t1 values(1),(2);
662
# Test of how ORDER BY works when doing it on the whole table
665
eval create $temp table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=$engine_type;
666
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
668
explain select * from t1 order by a;
670
explain select * from t1 order by b;
672
explain select * from t1 order by c;
674
explain select a from t1 order by a;
676
explain select b from t1 order by b;
678
explain select a,b from t1 order by b;
680
explain select a,b from t1;
682
explain select a,b,c from t1;
689
eval create $temp table t1 (t int not null default 1, key (t)) engine=$engine_type;
694
# A simple test with some isolation levels
695
# TODO: Make this into a test using replication to really test how
699
eval create $temp table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=$engine_type;
702
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
703
SELECT @@tx_isolation,@@global.tx_isolation;
704
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
705
select id, code, name from t1 order by id;
709
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
710
insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
711
select id, code, name from t1 order by id;
715
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
716
insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
717
select id, code, name from t1 order by id;
726
eval create $temp table t1 (a int, b int) engine=$engine_type;
727
insert into t1 values(20,null);
728
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
730
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
731
t2.b=t3.a order by 1;
732
insert into t1 values(10,null);
733
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
734
t2.b=t3.a order by 1;
738
if ($test_foreign_keys)
741
# Test of multi-table-delete with foreign key constraints
744
eval create $temp table t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=$engine_type;
745
eval create $temp table t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE ) ENGINE=$engine_type;
746
insert into t1 set id=1;
747
insert into t2 set id=1, t1_id=1;
748
delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
752
eval create $temp table t1(id INT NOT NULL, PRIMARY KEY (id)) ENGINE=$engine_type;
753
eval create $temp table t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) ENGINE=$engine_type;
754
INSERT INTO t1 VALUES(1);
755
INSERT INTO t2 VALUES(1, 1);
757
UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
759
UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
764
if ($test_transactions)
767
# Test of range_optimizer
772
eval create $temp table t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=$engine_type;
774
eval create $temp table t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=$engine_type;
776
eval create $temp table t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=$engine_type;
778
INSERT INTO t3 VALUES("my-test-1", "my-test-2");
781
INSERT INTO t1 VALUES("this-key", "will disappear");
782
INSERT INTO t2 VALUES("this-key", "will also disappear");
783
DELETE FROM t3 WHERE id1="my-test-1";
793
SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
800
# Check update with conflicting key
803
eval create $temp table t1 (a int not null primary key, b int not null, unique (b)) engine=$engine_type;
804
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
805
# We need the a < 1000 test here to quard against the halloween problems
806
UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
811
# Test that MySQL priorities clustered indexes
813
eval create $temp table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=$engine_type;
814
eval create $temp table t2 (a int not null auto_increment primary key, b int) ENGINE = $other_engine_type;
815
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
816
insert into t2 (a) select b from t1;
817
insert into t1 (b) select b from t2;
818
insert into t2 (a) select b from t1;
819
insert into t1 (a) select b from t2;
820
insert into t2 (a) select b from t1;
821
insert into t1 (a) select b from t2;
822
insert into t2 (a) select b from t1;
823
insert into t1 (a) select b from t2;
824
insert into t2 (a) select b from t1;
825
insert into t1 (a) select b from t2;
826
insert into t2 (a) select b from t1;
827
insert into t1 (a) select b from t2;
828
insert into t2 (a) select b from t1;
829
insert into t1 (a) select b from t2;
830
insert into t2 (a) select b from t1;
831
insert into t1 (a) select b from t2;
832
insert into t2 (a) select b from t1;
833
insert into t1 (a) select b from t2;
834
select count(*) from t1;
836
explain select * from t1 where c between 1 and 2500;
839
explain select * from t1 where c between 1 and 2500;
843
# Test of UPDATE ... ORDER BY
846
eval create $temp table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=$engine_type;
848
insert into t1 (id) values (null),(null),(null),(null),(null);
849
update t1 set fk=69 where fk is null order by id limit 1;
853
eval create $temp table t1 (a int not null, b int not null, key (a)) engine=$engine_type;
854
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
856
update t1 set b=(@tmp:=@tmp+1) order by a;
857
update t1 set b=99 where a=1 order by b asc limit 1;
858
update t1 set b=100 where a=1 order by b desc limit 2;
859
update t1 set a=a+10+b where a=1 order by b;
860
select * from t1 order by a,b;
864
# test autoincrement with TRUNCATE
868
eval create $temp table t1 (a integer auto_increment primary key) engine=$engine_type;
869
insert into t1 (a) values (NULL),(NULL);
871
insert into t1 (a) values (NULL),(NULL);
876
if ($test_foreign_keys)
879
# Test dictionary handling with spaceand quoting
882
eval create $temp table t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=$engine_type;
883
eval create $temp table t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) ENGINE=$engine_type;
884
#show create table t2;
888
# Test of multi updated and foreign keys
891
eval create $temp table `t1` (`id` int not null ,primary key ( `id` )) engine = $engine_type;
892
insert into `t1`values ( 1 ) ;
893
eval create $temp table `t2` (`id` int not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = $engine_type;
894
insert into `t2`values ( 1 ) ;
895
eval create $temp table `t3` (`id` int not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = $engine_type;
896
insert into `t3`values ( 1 ) ;
898
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
900
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
902
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
906
# test for recursion depth limit
908
eval create $temp table t1(
912
foreign key(pid) references t1(id) on delete cascade) engine=$engine_type;
913
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
914
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
916
delete from t1 where id=0;
917
delete from t1 where id=15;
918
delete from t1 where id=0;
922
# End of FOREIGN KEY tests
928
eval create $temp table t1 (col1 int)ENGINE=$engine_type;
929
eval create $temp table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
930
(stamp))ENGINE=$engine_type;
931
insert into t1 values (1),(2),(3);
932
# Note that timestamp 3 is wrong
933
--error 1685 # Bad timestamp
934
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
935
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
936
'20020204120000' GROUP BY col1;
940
# Test by Francois MASUREL
945
eval create $temp table t1 (
946
`id` int NOT NULL auto_increment,
947
`id_object` int default '0',
948
`id_version` int NOT NULL default '1',
949
`label` varchar(100) NOT NULL default '',
952
KEY `id_object` (`id_object`),
953
KEY `id_version` (`id_version`)
954
) ENGINE=$engine_type;
956
INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
958
eval create $temp table t2 (
959
`id` int NOT NULL auto_increment,
960
`id_version` int NOT NULL default '1',
962
KEY `id_version` (`id_version`)
963
) ENGINE=$engine_type;
965
INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
967
SELECT t2.id, t1.`label` FROM t2 INNER JOIN
968
(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl
969
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
973
# Live checksum feature available + enabled
974
eval create $temp table t1 (a int, b varchar(200), c text not null) engine=$other_live_chks_engine_type;
975
# Live checksum feature available + disabled
976
eval create $temp table t2 (a int, b varchar(200), c text not null) engine=$other_live_chks_engine_type;
978
# Live checksum feature not available + enabled
979
eval create $temp table t3 (a int, b varchar(200), c varchar(200) not null) engine=$other_non_live_chks_engine_type;
980
# Live checksum feature not available + disabled
981
eval create $temp table t4 (a int, b varchar(200), c varchar(200) not null) engine=$other_non_live_chks_engine_type;
983
# Live checksum feature probably available + enabled
984
eval create $temp table t5 (a int, b varchar(200), c text not null) engine=$engine_type;
985
# Live checksum feature probably available + disabled
986
eval create $temp table t6 (a int, b varchar(200), c text not null) engine=$engine_type;
988
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
989
insert t2 select * from t1;
990
insert t3 select * from t1;
991
insert t4 select * from t1;
992
insert t5 select * from t1;
993
insert t6 select * from t1;
994
checksum table t1, t2, t3, t4, t5, t6, t7;
995
checksum table t1, t2, t3, t4, t5, t6, t7;
996
checksum table t1, t2, t3, t4, t5, t6, t7;
997
# #show table status;
998
drop table t1,t2,t3, t4, t5, t6;
1001
# Test problem with refering to different fields in same table in UNION
1002
# (Bug#2552: UNION returns NULL instead of expected value (innoDB only tables))
1006
eval create $temp table t1 (id int, name char(10) not null, name2 char(10) not null) engine=$engine_type;
1007
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
1008
select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
1012
# Bug#2160: Extra error message for create $temp table LIKE with InnoDB
1014
eval create $temp table t1 (a int) engine=$engine_type;
1016
create table t2 like t1;
1017
create table t2 like t1 engine=innodb;
1018
show create table t2;
1021
if ($test_foreign_keys)
1024
# Test of automaticly created foreign keys
1027
eval create $temp table t1 (id int not null, id2 int not null, unique (id,id2)) engine=$engine_type;
1028
eval create $temp table t2 (id int not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = $engine_type;
1029
show create table t1;
1030
show create table t2;
1031
create index id on t2 (id);
1032
show create table t2;
1033
create index id2 on t2 (id);
1034
show create table t2;
1035
drop index id2 on t2;
1037
drop index id on t2;
1038
show create table t2;
1041
eval create $temp table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = $engine_type;
1042
show create table t2;
1043
create unique index id on t2 (id,id2);
1044
show create table t2;
1047
# Check foreign key columns created in different order than key columns
1048
eval create $temp table t2 (id int not null, id2 int not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = $engine_type;
1049
show create table t2;
1052
eval create $temp table t2 (id int not null, id2 int not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = $engine_type;
1053
show create table t2;
1056
eval create $temp table t2 (id int not null, id2 int not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = $engine_type;
1057
show create table t2;
1060
eval create $temp table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = $engine_type;
1061
show create table t2;
1064
eval create $temp table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= $engine_type;
1065
show create table t2;
1066
alter table t2 add index id_test (id), add index id_test2 (id,id2);
1067
show create table t2;
1070
# Test error handling
1072
# Clean up filename -- embedded server reports whole path without .frm,
1073
# regular server reports relative path with .frm (argh!)
1074
--replace_result \\ / $DRIZZLE_TEST_DIR . /var/master-data/ / t2.frm t2
1076
eval create $temp table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = $engine_type;
1080
eval create $temp table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=$engine_type;
1081
show create table t2;
1083
eval create $temp table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=$engine_type;
1084
show create table t2;
1087
# End of FOREIGN KEY tests
1091
# Let us test binlog_cache_use and binlog_cache_disk_use status vars.
1092
# Actually this test has nothing to do with innodb per se, it just requires
1093
# transactional table.
1096
show status like "binlog_cache_use";
1097
show status like "binlog_cache_disk_use";
1099
eval create $temp table t1 (a int) engine=$engine_type;
1101
# Now we are going to create transaction which is long enough so its
1102
# transaction binlog will be flushed to disk...
1108
eval insert into t1 values( $1 );
1113
show status like "binlog_cache_use";
1114
show status like "binlog_cache_disk_use";
1116
# Transaction which should not be flushed to disk and so should not
1117
# increase binlog_cache_disk_use.
1121
show status like "binlog_cache_use";
1122
show status like "binlog_cache_disk_use";
1126
# Bug #6126: Duplicate columns in keys gives misleading error message
1129
eval create $temp table t1 (c char(10), index (c,c)) engine=$engine_type;
1131
eval create $temp table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=$engine_type;
1133
eval create $temp table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=$engine_type;
1135
eval create $temp table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=$engine_type;
1136
eval create $temp table t1 (c1 char(10), c2 char(10)) engine=$engine_type;
1138
alter table t1 add key (c1,c1);
1140
alter table t1 add key (c2,c1,c1);
1142
alter table t1 add key (c1,c2,c1);
1144
alter table t1 add key (c1,c1,c2);
1148
# Bug #4082: integer truncation
1151
eval create $temp table t1(a int, b int) engine=$engine_type;
1152
insert into t1 values ('1111', '3333');
1153
select distinct concat(a, b) from t1;
1156
if ($fulltext_query_unsupported)
1159
# BUG#7709 test case - Boolean fulltext query against unsupported
1160
# engines does not fail
1163
eval create $temp table t1 ( a char(10) ) ENGINE=$engine_type;
1165
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
1169
if ($test_foreign_keys)
1172
# check null values #1
1176
eval create $temp table t1 (a_id int NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=$engine_type DEFAULT CHARSET=latin1;
1177
INSERT INTO t1 VALUES (1),(2),(3);
1178
eval create $temp table t2 (b_id int NOT NULL default '0',b_a int NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
1179
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=$engine_type DEFAULT CHARSET=latin1;
1181
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
1182
SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
1188
# Bug#11816 - Truncate table doesn't work with temporary innodb tables
1189
# This is not an innodb bug, but we test it using innodb.
1191
eval create temporary table t1 (a int) engine=$engine_type;
1192
insert into t1 values (4711);
1194
insert into t1 values (42);
1197
# Show that it works with permanent tables too.
1198
eval create $temp table t1 (a int) engine=$engine_type;
1199
insert into t1 values (4711);
1201
insert into t1 values (42);
1206
# Bug #13025 Server crash during filesort
1209
eval create $temp table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=$engine_type;
1210
insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
1211
select * from t1 order by a,b,c,d;
1212
explain select * from t1 order by a,b,c,d;
1216
# BUG#11039,#13218 Wrong key length in min()
1219
eval create $temp table t1 (a char(1), b char(1), key(a, b)) engine=$engine_type;
1220
insert into t1 values ('8', '6'), ('4', '7');
1221
select min(a) from t1;
1222
select min(b) from t1 where a='8';
1228
# range optimizer problem
1231
eval create $temp table t1 (x bigint not null primary key) engine=$engine_type;
1232
# The below is out of range for a BIGINT (signed)
1234
insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
1236
select count(*) from t1 where x>0;
1237
select count(*) from t1 where x=0;
1238
select count(*) from t1 where x<0;
1239
select count(*) from t1 where x < -16;
1240
select count(*) from t1 where x = -16;
1241
explain select count(*) from t1 where x > -16;
1242
select count(*) from t1 where x > -16;
1243
select * from t1 where x > -16;
1244
select count(*) from t1 where x = 18446744073709551601;
1247
# Please do not remove the following skipped InnoDB specific tests.
1248
# They make the synchronization with innodb.test easier and give
1249
# an idea what to test on other storage engines.
1253
# Test for testable InnoDB status variables. This test
1254
# uses previous ones(pages_created, rows_deleted, ...).
1255
show status like "Innodb_buffer_pool_pages_total";
1256
show status like "Innodb_page_size";
1257
show status like "Innodb_rows_deleted";
1258
show status like "Innodb_rows_inserted";
1259
show status like "Innodb_rows_updated";
1261
# Test for row locks InnoDB status variables.
1262
show status like "Innodb_row_lock_waits";
1263
show status like "Innodb_row_lock_current_waits";
1264
show status like "Innodb_row_lock_time";
1265
show status like "Innodb_row_lock_time_max";
1266
show status like "Innodb_row_lock_time_avg";
1268
# Test for innodb_sync_spin_loops variable
1269
show variables like "innodb_sync_spin_loops";
1270
set global innodb_sync_spin_loops=1000;
1271
show variables like "innodb_sync_spin_loops";
1272
set global innodb_sync_spin_loops=0;
1273
show variables like "innodb_sync_spin_loops";
1274
set global innodb_sync_spin_loops=20;
1275
show variables like "innodb_sync_spin_loops";
1277
# Test for innodb_thread_concurrency variable
1278
show variables like "innodb_thread_concurrency";
1279
set global innodb_thread_concurrency=1001;
1280
show variables like "innodb_thread_concurrency";
1281
set global innodb_thread_concurrency=0;
1282
show variables like "innodb_thread_concurrency";
1283
set global innodb_thread_concurrency=16;
1284
show variables like "innodb_thread_concurrency";
1286
# Test for innodb_concurrency_tickets variable
1287
show variables like "innodb_concurrency_tickets";
1288
set global innodb_concurrency_tickets=1000;
1289
show variables like "innodb_concurrency_tickets";
1290
set global innodb_concurrency_tickets=0;
1291
show variables like "innodb_concurrency_tickets";
1292
set global innodb_concurrency_tickets=500;
1293
show variables like "innodb_concurrency_tickets";
1295
# Test for innodb_thread_sleep_delay variable
1296
show variables like "innodb_thread_sleep_delay";
1297
set global innodb_thread_sleep_delay=100000;
1298
show variables like "innodb_thread_sleep_delay";
1299
set global innodb_thread_sleep_delay=0;
1300
show variables like "innodb_thread_sleep_delay";
1301
set global innodb_thread_sleep_delay=10000;
1302
show variables like "innodb_thread_sleep_delay";
1311
let $default=`select @@storage_engine`;
1312
eval set storage_engine=$engine_type;
1313
source include/varchar.inc;
1316
# Some errors/warnings on create
1319
# Clean up filename -- embedded server reports whole path without .frm,
1320
# regular server reports relative path with .frm (argh!)
1321
# @TODO The below fails because it assumes latin1
1322
# as the charset. Possibly re-enable a similar test
1323
#--replace_result \\ / $DRIZZLE_TEST_DIR . /var/master-data/ / t1.frm t1
1324
#create $temp table t1 (v varchar(65530), key(v));
1326
#create $temp table t1 (v varchar(65536));
1327
#show create table t1;
1329
#create $temp table t1 (v varchar(65530) character set utf8);
1330
#show create table t1;
1333
#eval set storage_engine=$default;
1335
# InnoDB specific varchar tests
1336
#eval create $temp table t1 (v varchar(16384)) engine=$engine_type;
1340
# BUG#11039 Wrong key length in min()
1343
eval create $temp table t1 (a char(1), b char(1), key(a, b)) engine=$engine_type;
1344
insert into t1 values ('8', '6'), ('4', '7');
1345
select min(a) from t1;
1346
select min(b) from t1 where a='8';
1350
# Bug #11080 & #11005 Multi-row REPLACE fails on a duplicate key error
1353
eval create $temp table t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=$engine_type;
1354
insert into t1 (b) values (1);
1355
replace into t1 (b) values (2), (1), (3);
1358
insert into t1 (b) values (1);
1359
replace into t1 (b) values (2);
1360
replace into t1 (b) values (1);
1361
replace into t1 (b) values (3);
1365
eval create $temp table t1 (rowid int not null auto_increment, val int not null,primary
1366
key (rowid), unique(val)) engine=$engine_type;
1367
replace into t1 (val) values ('1'),('2');
1368
replace into t1 (val) values ('1'),('2');
1369
--error ER_DUP_ENTRY
1370
insert into t1 (val) values ('1'),('2');
1374
if ($no_autoinc_update)
1377
# Test that update does not change internal auto-increment value
1380
eval create $temp table t1 (a int not null auto_increment primary key, val int) engine=$engine_type;
1381
insert into t1 (val) values (1);
1382
update t1 set a=2 where a=1;
1383
# We should get the following error because InnoDB does not update the counter
1384
--error ER_DUP_ENTRY
1385
insert into t1 (val) values (1);
1392
# Bug#10465: DECIMAL, crash on DELETE (InnoDB only)
1396
eval create $temp table t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=$engine_type;
1398
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
1399
SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
1400
SELECT GRADE FROM t1 WHERE GRADE= 151;
1403
if ($test_foreign_keys)
1406
# Test that the slow TRUNCATE implementation resets autoincrement columns
1410
eval create $temp table t1 (
1411
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
1412
) ENGINE=$engine_type;
1414
eval create $temp table t2 (
1415
id INTEGER NOT NULL,
1416
FOREIGN KEY (id) REFERENCES t1 (id)
1417
) ENGINE=$engine_type;
1419
INSERT INTO t1 (id) VALUES (NULL);
1422
INSERT INTO t1 (id) VALUES (NULL);
1425
# continued from above; test that doing a slow TRUNCATE on a table with 0
1426
# rows resets autoincrement columns
1429
INSERT INTO t1 (id) VALUES (NULL);
1433
# Test that foreign keys in temporary tables are not accepted (bug #12084)
1434
eval create $temp table t1
1437
) ENGINE=$engine_type;
1440
eval CREATE TEMPORARY TABLE t2
1442
id INT NOT NULL PRIMARY KEY,
1444
FOREIGN KEY (b) REFERENCES test.t1(id)
1445
) ENGINE=$engine_type;
1448
# End of FOREIGN KEY test
1450
# Please do not remove the following skipped InnoDB specific tests.
1451
# They make the synchronization with innodb.test easier and give
1452
# an idea what to test on other storage engines.
1457
# Test that index column max sizes are honored (bug #13315)
1461
eval create $temp table t1 (col1 varchar(2000), index (col1(767)))
1462
character set = latin1 engine = $engine_type;
1465
eval create $temp table t2 (col1 char(255), index (col1))
1466
character set = latin1 engine = $engine_type;
1467
eval create $temp table t3 (col1 binary(255), index (col1))
1468
character set = latin1 engine = $engine_type;
1469
eval create $temp table t4 (col1 varchar(767), index (col1))
1470
character set = latin1 engine = $engine_type;
1471
eval create $temp table t5 (col1 varchar(767) primary key)
1472
character set = latin1 engine = $engine_type;
1473
eval create $temp table t6 (col1 varbinary(767) primary key)
1474
character set = latin1 engine = $engine_type;
1475
eval create $temp table t7 (col1 text, index(col1(767)))
1476
character set = latin1 engine = $engine_type;
1477
eval create $temp table t8 (col1 blob, index(col1(767)))
1478
character set = latin1 engine = $engine_type;
1481
# multi-column indexes are allowed to be longer
1482
eval create $temp table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
1483
character set = latin1 engine = $engine_type;
1485
show create table t9;
1487
drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
1489
# these should have their index length trimmed
1490
eval create $temp table t1 (col1 varchar(768), index(col1))
1491
character set = latin1 engine = $engine_type;
1492
eval create $temp table t2 (col1 varbinary(768), index(col1))
1493
character set = latin1 engine = $engine_type;
1494
eval create $temp table t3 (col1 text, index(col1(768)))
1495
character set = latin1 engine = $engine_type;
1496
eval create $temp table t4 (col1 blob, index(col1(768)))
1497
character set = latin1 engine = $engine_type;
1499
show create table t1;
1501
drop table t1, t2, t3, t4;
1504
# End of skipped test
1506
# Please do not remove the following skipped InnoDB specific tests.
1507
# They make the synchronization with innodb.test easier and give
1508
# an idea what to test on other storage engines.
1512
# these should be refused
1514
eval create $temp table t1 (col1 varchar(768) primary key)
1515
character set = latin1 engine = $engine_type;
1517
eval create $temp table t2 (col1 varbinary(768) primary key)
1518
character set = latin1 engine = $engine_type;
1520
eval create $temp table t3 (col1 text, primary key(col1(768)))
1521
character set = latin1 engine = $engine_type;
1523
eval create $temp table t4 (col1 blob, primary key(col1(768)))
1524
character set = latin1 engine = $engine_type;
1528
if ($test_foreign_keys)
1531
# Test improved foreign key error messages (bug #3443)
1534
eval create $temp table t1
1537
) ENGINE=$engine_type;
1539
eval create $temp table t2
1542
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1543
) ENGINE=$engine_type;
1546
INSERT INTO t2 VALUES(2);
1548
INSERT INTO t1 VALUES(1);
1549
INSERT INTO t2 VALUES(1);
1552
DELETE FROM t1 WHERE id = 1;
1557
SET FOREIGN_KEY_CHECKS=0;
1559
SET FOREIGN_KEY_CHECKS=1;
1562
INSERT INTO t2 VALUES(3);
1566
# End of FOREIGN tests
1568
if ($test_transactions)
1571
# Test that checksum table uses a consistent read Bug #12669
1573
connect (a,localhost,root,,);
1574
connect (b,localhost,root,,);
1576
eval create $temp table t1(a int not null) engine=$engine_type DEFAULT CHARSET=latin1;
1577
insert into t1 values (1),(2);
1581
insert into t1 values(3);
1584
# Here checksum should not see insert
1596
eval create $temp table t1(a int not null) engine=$engine_type DEFAULT CHARSET=latin1;
1597
insert into t1 values (1),(2);
1602
insert into t1 values(3);
1605
# Here checksum sees insert
1615
# tests for bugs #9802 and #13778
1617
if ($test_foreign_keys)
1619
# test that FKs between invalid types are not accepted
1621
set foreign_key_checks=0;
1622
eval create $temp table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = $engine_type;
1623
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1625
eval create $temp table t1(a char(10) primary key, b varchar(20)) engine = $engine_type;
1626
set foreign_key_checks=1;
1629
# test that FKs between different charsets are not accepted in CREATE even
1632
set foreign_key_checks=0;
1633
eval create $temp table t1(a varchar(10) primary key) engine = $engine_type DEFAULT CHARSET=latin1;
1634
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1636
eval create $temp table t2 (a varchar(10), foreign key (a) references t1(a)) engine = $engine_type DEFAULT CHARSET=utf8;
1637
set foreign_key_checks=1;
1640
# test that invalid datatype conversions with ALTER are not allowed
1642
set foreign_key_checks=0;
1643
eval create $temp table t2 (a varchar(10), foreign key (a) references t1(a)) engine = $engine_type;
1644
eval create $temp table t1(a varchar(10) primary key) engine = $engine_type;
1646
alter table t1 modify column a int;
1647
set foreign_key_checks=1;
1650
# test that charset conversions with ALTER are allowed when f_k_c is 0
1652
set foreign_key_checks=0;
1653
eval create $temp table t2 (a varchar(10), foreign key (a) references t1(a)) engine = $engine_type DEFAULT CHARSET=latin1;
1654
eval create $temp table t1(a varchar(10) primary key) engine = $engine_type DEFAULT CHARSET=latin1;
1655
alter table t1 convert to character set utf8;
1656
set foreign_key_checks=1;
1659
# test that RENAME does not allow invalid charsets when f_k_c is 0
1661
set foreign_key_checks=0;
1662
eval create $temp table t2 (a varchar(10), foreign key (a) references t1(a)) engine = $engine_type DEFAULT CHARSET=latin1;
1663
eval create $temp table t3(a varchar(10) primary key) engine = $engine_type DEFAULT CHARSET=utf8;
1664
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1666
rename table t3 to t1;
1667
set foreign_key_checks=1;
1670
# test that foreign key errors are reported correctly (Bug #15550)
1672
eval create $temp table t1(a int primary key) row_format=redundant engine=$engine_type;
1673
eval create $temp table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=$engine_type;
1674
eval create $temp table t3(a int primary key) row_format=compact engine=$engine_type;
1675
eval create $temp table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=$engine_type;
1677
insert into t1 values(1);
1678
insert into t3 values(1);
1680
insert into t2 values(2);
1682
insert into t4 values(2);
1683
insert into t2 values(1);
1684
insert into t4 values(1);
1702
drop table t4,t3,t2,t1;
1704
# End of FOREIGN KEY tests
1707
# Please do not remove the following skipped InnoDB specific tests.
1708
# They make the synchronization with innodb.test easier and give
1709
# an idea what to test on other storage engines.
1714
# Test that we can create a large (>1K) key
1716
eval create $temp table t1 (a varchar(255) character set utf8,
1717
b varchar(255) character set utf8,
1718
c varchar(255) character set utf8,
1719
d varchar(255) character set utf8,
1720
key (a,b,c,d)) engine=$engine_type;
1722
--error ER_TOO_LONG_KEY
1723
eval create $temp table t1 (a varchar(255) character set utf8,
1724
b varchar(255) character set utf8,
1725
c varchar(255) character set utf8,
1726
d varchar(255) character set utf8,
1727
e varchar(255) character set utf8,
1728
key (a,b,c,d,e)) engine=$engine_type;
1731
# test the padding of BINARY types and collations (Bug #14189)
1733
eval create $temp table t1 (s1 varbinary(2),primary key (s1)) engine=$engine_type;
1734
eval create $temp table t2 (s1 binary(2),primary key (s1)) engine=$engine_type;
1735
eval create $temp table t3 (s1 varchar(2),primary key (s1)) engine=$engine_type;
1736
eval create $temp table t4 (s1 char(2),primary key (s1)) engine=$engine_type;
1738
insert into t1 values (0x41),(0x4120),(0x4100);
1739
-- error ER_DUP_ENTRY
1740
insert into t2 values (0x41),(0x4120),(0x4100);
1741
insert into t2 values (0x41),(0x4120);
1742
-- error ER_DUP_ENTRY
1743
insert into t3 values (0x41),(0x4120),(0x4100);
1744
insert into t3 values (0x41),(0x4100);
1745
-- error ER_DUP_ENTRY
1746
insert into t4 values (0x41),(0x4120),(0x4100);
1747
insert into t4 values (0x41),(0x4100);
1748
select hex(s1) from t1;
1749
select hex(s1) from t2;
1750
select hex(s1) from t3;
1751
select hex(s1) from t4;
1752
drop table t1,t2,t3,t4;
1755
if (test_foreign_keys)
1757
eval create $temp table t1 (a int primary key,s1 varbinary(3) not null unique) engine=$engine_type;
1758
eval create $temp table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=$engine_type;
1760
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
1762
insert into t2 values(0x42);
1763
insert into t2 values(0x41);
1764
select hex(s1) from t2;
1765
update t1 set s1=0x123456 where a=2;
1766
select hex(s1) from t2;
1768
update t1 set s1=0x12 where a=1;
1770
update t1 set s1=0x12345678 where a=1;
1772
update t1 set s1=0x123457 where a=1;
1773
update t1 set s1=0x1220 where a=1;
1774
select hex(s1) from t2;
1775
update t1 set s1=0x1200 where a=1;
1776
select hex(s1) from t2;
1777
update t1 set s1=0x4200 where a=1;
1778
select hex(s1) from t2;
1780
delete from t1 where a=1;
1781
delete from t1 where a=2;
1782
update t2 set s1=0x4120;
1785
delete from t1 where a!=3;
1786
select a,hex(s1) from t1;
1787
select hex(s1) from t2;
1791
eval create $temp table t1 (a int primary key,s1 varchar(2) not null unique) engine=$engine_type;
1792
eval create $temp table t2 (s1 char(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=$engine_type;
1794
insert into t1 values(1,0x4100),(2,0x41);
1795
insert into t2 values(0x41);
1796
select hex(s1) from t2;
1797
update t1 set s1=0x1234 where a=1;
1798
select hex(s1) from t2;
1799
update t1 set s1=0x12 where a=2;
1800
select hex(s1) from t2;
1801
delete from t1 where a=1;
1803
delete from t1 where a=2;
1804
select a,hex(s1) from t1;
1805
select hex(s1) from t2;
1809
# End FOREIGN KEY tests
1811
if ($test_foreign_keys)
1813
# Ensure that <tablename>_ibfk_0 is not mistreated as a
1814
# generated foreign key identifier. (Bug #16387)
1816
eval create $temp table t1(a INT, PRIMARY KEY(a)) ENGINE=$engine_type;
1817
eval create $temp table t2(a INT) ENGINE=$engine_type;
1818
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
1819
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
1820
ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
1821
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
1822
SHOW create $temp table t2;
1826
if ($test_foreign_keys)
1829
# Test that cascading updates leading to duplicate keys give the correct
1830
# error message (bug #9680)
1833
eval create $temp table t1 (
1834
field1 varchar(8) NOT NULL DEFAULT '',
1835
field2 varchar(8) NOT NULL DEFAULT '',
1836
PRIMARY KEY (field1, field2)
1837
) ENGINE=$engine_type;
1839
eval create $temp table t2 (
1840
field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
1841
FOREIGN KEY (field1) REFERENCES t1 (field1)
1842
ON DELETE CASCADE ON UPDATE CASCADE
1843
) ENGINE=$engine_type;
1845
INSERT INTO t1 VALUES ('old', 'somevalu');
1846
INSERT INTO t1 VALUES ('other', 'anyvalue');
1848
INSERT INTO t2 VALUES ('old');
1849
INSERT INTO t2 VALUES ('other');
1851
--error ER_FOREIGN_DUPLICATE_KEY
1852
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
1858
# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
1860
eval create $temp table t1 (
1865
) engine=$engine_type;
1867
eval create $temp table t2 (
1870
) engine=$engine_type;
1872
alter table t1 add constraint c2_fk foreign key (c2)
1873
references t2(c1) on delete cascade;
1874
show create table t1;
1876
alter table t1 drop foreign key c2_fk;
1877
show create table t1;
1881
# End FOREIGN KEY test
1884
# Bug #14360: problem with intervals
1887
eval create $temp table t1(a date) engine=$engine_type;
1888
eval create $temp table t2(a date, key(a)) engine=$engine_type;
1889
insert into t1 values('2005-10-01');
1890
insert into t2 values('2005-10-01');
1891
select * from t1, t2
1892
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
1895
eval create $temp table t1 (id int not null, f_id int not null, f int not null,
1896
primary key(f_id, id)) engine=$engine_type;
1897
eval create $temp table t2 (id int not null,s_id int not null,s varchar(200),
1898
primary key(id)) engine=$engine_type;
1899
INSERT INTO t1 VALUES (8, 1, 3);
1900
INSERT INTO t1 VALUES (1, 2, 1);
1901
INSERT INTO t2 VALUES (1, 0, '');
1902
INSERT INTO t2 VALUES (8, 1, '');
1904
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
1905
where mm.id is null lock in share mode;
1909
# Test case where X-locks on unused rows should be released in a
1910
# update (because READ COMMITTED isolation level)
1914
connect (a,localhost,root,,);
1915
connect (b,localhost,root,,);
1917
eval create $temp table t1(a int not null, b int, primary key(a)) engine=$engine_type;
1918
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
1921
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
1922
update t1 set b = 5 where b = 1;
1925
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
1927
# X-lock to record (7,3) should be released in a update
1929
select * from t1 where a = 7 and b = 3 for update;
1939
if ($test_transactions)
1942
# Test case where no locks should be released (because we are not
1943
# using READ COMMITTED isolation level)
1946
connect (a,localhost,root,,);
1947
connect (b,localhost,root,,);
1949
eval create $temp table t1(a int not null, b int, primary key(a)) engine=$engine_type;
1950
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
1953
select * from t1 lock in share mode;
1954
update t1 set b = 5 where b = 1;
1958
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
1961
select * from t1 where a = 2 and b = 2 for update;
1963
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
1976
# Consistent read should be used in following selects
1978
# 1) INSERT INTO ... SELECT
1979
# 2) UPDATE ... = ( SELECT ...)
1980
# 3) CREATE ... SELECT
1982
connect (a,localhost,root,,);
1983
connect (b,localhost,root,,);
1985
eval create $temp table t1(a int not null, b int, primary key(a)) engine=$engine_type;
1986
insert into t1 values (1,2),(5,3),(4,2);
1987
eval create $temp table t2(d int not null, e int, primary key(d)) engine=$engine_type;
1988
insert into t2 values (8,6),(12,1),(3,1);
1991
select * from t2 for update;
1994
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
1995
insert into t1 select * from t2;
1996
update t1 set b = (select e from t2 where a = d);
1997
eval create $temp table t3(d int not null, e int, primary key(d)) engine=$engine_type
2005
drop table t1, t2, t3;
2008
# Consistent read should not be used if
2010
# (a) isolation level is serializable OR
2011
# (b) select ... lock in share mode OR
2012
# (c) select ... for update
2014
# in following queries:
2016
# 1) INSERT INTO ... SELECT
2017
# 2) UPDATE ... = ( SELECT ...)
2018
# 3) CREATE ... SELECT
2020
connect (a,localhost,root,,);
2021
eval SET SESSION STORAGE_ENGINE = $engine_type;
2022
connect (b,localhost,root,,);
2023
eval SET SESSION STORAGE_ENGINE = $engine_type;
2024
connect (c,localhost,root,,);
2025
eval SET SESSION STORAGE_ENGINE = $engine_type;
2026
connect (d,localhost,root,,);
2027
eval SET SESSION STORAGE_ENGINE = $engine_type;
2028
connect (e,localhost,root,,);
2029
eval SET SESSION STORAGE_ENGINE = $engine_type;
2030
connect (f,localhost,root,,);
2031
eval SET SESSION STORAGE_ENGINE = $engine_type;
2032
connect (g,localhost,root,,);
2033
eval SET SESSION STORAGE_ENGINE = $engine_type;
2034
connect (h,localhost,root,,);
2035
eval SET SESSION STORAGE_ENGINE = $engine_type;
2036
connect (i,localhost,root,,);
2037
eval SET SESSION STORAGE_ENGINE = $engine_type;
2038
connect (j,localhost,root,,);
2039
eval SET SESSION STORAGE_ENGINE = $engine_type;
2041
create $temp table t1(a int not null, b int, primary key(a));
2042
insert into t1 values (1,2),(5,3),(4,2);
2043
create $temp table t2(a int not null, b int, primary key(a));
2044
insert into t2 values (8,6),(12,1),(3,1);
2045
create $temp table t3(d int not null, b int, primary key(d));
2046
insert into t3 values (8,6),(12,1),(3,1);
2047
create $temp table t5(a int not null, b int, primary key(a));
2048
insert into t5 values (1,2),(5,3),(4,2);
2049
create $temp table t6(d int not null, e int, primary key(d));
2050
insert into t6 values (8,6),(12,1),(3,1);
2051
create $temp table t8(a int not null, b int, primary key(a));
2052
insert into t8 values (1,2),(5,3),(4,2);
2053
create $temp table t9(d int not null, e int, primary key(d));
2054
insert into t9 values (8,6),(12,1),(3,1);
2057
select * from t2 for update;
2060
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2062
insert into t1 select * from t2;
2065
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2067
update t3 set b = (select b from t2 where a = d);
2070
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2072
create $temp table t4(a int not null, b int, primary key(a)) select * from t2;
2075
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2077
insert into t5 (select * from t2 lock in share mode);
2080
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2082
update t6 set e = (select b from t2 where a = d lock in share mode);
2085
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2087
create $temp table t7(a int not null, b int, primary key(a)) select * from t2 lock in share mode;
2090
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2092
insert into t8 (select * from t2 for update);
2095
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2097
update t9 set e = (select b from t2 where a = d for update);
2100
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2102
create $temp table t10(a int not null, b int, primary key(a)) select * from t2 for update;
2154
drop table t1, t2, t3, t5, t6, t8, t9;
2156
# End transactional tests
2158
if (test_foreign_keys)
2160
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
2162
eval create $temp table t1 (DB_ROW_ID int) engine=$engine_type;
2165
# Bug #17152: Wrong result with BINARY comparison on aliased column
2168
eval create $temp table t1 (
2169
a BIGINT(20) NOT NULL,
2171
) ENGINE=$engine_type DEFAULT CHARSET=UTF8;
2173
eval create $temp table t2 (
2174
a BIGINT(20) NOT NULL,
2175
b VARCHAR(128) NOT NULL,
2178
KEY idx_t2_b_c (b,c(200)),
2179
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
2181
) ENGINE=$engine_type DEFAULT CHARSET=UTF8;
2183
INSERT INTO t1 VALUES (1);
2184
INSERT INTO t2 VALUES (1, 'bar', 'vbar');
2185
INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
2186
INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
2187
INSERT INTO t2 VALUES (1, 'customer_over', '1');
2189
SELECT * FROM t2 WHERE b = 'customer_over';
2190
SELECT * FROM t2 WHERE BINARY b = 'customer_over';
2191
SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
2192
/* Bang: Empty result set, above was expected: */
2193
SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
2194
SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
2199
if ($no_spatial_key)
2202
# Bug #15680 (SPATIAL key in innodb)
2204
--error ER_TABLE_CANT_HANDLE_SPKEYS
2205
eval create $temp table t1 (g geometry not null, spatial gk(g)) engine=$engine_type;
2209
# Test optimize on table with open transaction
2212
eval create $temp table t1 ( a int ) ENGINE=$engine_type;
2214
INSERT INTO t1 VALUES (1);
2215
eval ALTER TABLE t1 ENGINE=$engine_type;
2218
#######################################################################
2220
# This is derivate of t/innodb.test and has to be maintained by #
2221
# MySQL guys only. #
2223
# Please synchronize this file from time to time with t/innodb.test. #
2224
# Please, DO NOT create a toplevel testcase innodb-mix2.test, because #
2225
# innodb.test does already these tests. #
2227
#######################################################################