337
334
user_name varchar(12),
339
336
subscribed char(1),
340
user_id int DEFAULT '0' NOT NULL,
337
user_id int(11) DEFAULT '0' NOT NULL,
343
340
access_date date,
344
342
approved datetime,
345
dummy_primary_key int NOT NULL auto_increment,
343
dummy_primary_key int(11) NOT NULL auto_increment,
346
344
PRIMARY KEY (dummy_primary_key)
348
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','2000-09-07 23:06:59',1);
349
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','2000-09-07 23:06:59',2);
350
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','2000-09-07 23:06:59',3);
351
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','2000-09-07 23:06:59',4);
352
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','2000-09-07 23:06:59',5);
353
select user_name, password , subscribed, user_id, quota, weight, access_date, approved, dummy_primary_key from t1 order by user_name;
346
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
347
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
348
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
349
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
350
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
351
select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
489
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
490
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
491
LOCK TABLES t1 WRITE;
493
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
499
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
500
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
501
LOCK TABLES t1 WRITE;
504
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
506
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
508
select id,id3 from t1;
488
513
# Test prefix key
490
515
create table t1 (a char(20), unique (a(5))) engine=innodb;
635
# Test of multi-table-delete
639
number bigint(20) NOT NULL default '0',
640
cname char(15) NOT NULL default '',
641
carrier_id int(6) NOT NULL default '0',
642
privacy int(4) NOT NULL default '0',
643
last_mod_date timestamp NOT NULL,
644
last_mod_id int(6) NOT NULL default '0',
645
last_app_date timestamp NOT NULL,
646
last_app_id int(6) default '-1',
647
version int(6) NOT NULL default '0',
648
assigned_scps int(11) default '0',
649
status int(4) default '0'
651
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
652
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
653
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
654
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
655
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
656
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
658
number bigint(20) NOT NULL default '0',
659
cname char(15) NOT NULL default '',
660
carrier_id int(6) NOT NULL default '0',
661
privacy int(4) NOT NULL default '0',
662
last_mod_date timestamp NOT NULL,
663
last_mod_id int(6) NOT NULL default '0',
664
last_app_date timestamp NOT NULL,
665
last_app_id int(6) default '-1',
666
version int(6) NOT NULL default '0',
667
assigned_scps int(11) default '0',
668
status int(4) default '0'
670
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
671
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
672
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
673
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
676
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null);
611
683
# A simple test with some isolation levels
612
684
# TODO: Make this into a test using replication to really test how
711
# Test of multi-table-update
713
create table t1 (n int(10), d int(10)) engine=innodb;
714
create table t2 (n int(10), d int(10)) engine=innodb;
715
insert into t1 values(1,1),(1,2);
716
insert into t2 values(1,10),(2,20);
717
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
723
# Bug #29136 erred multi-delete on trans table does not rollback
728
drop table if exists t1, t2;
730
CREATE TABLE t1 (a int, PRIMARY KEY (a));
731
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
732
create trigger trg_del_t2 after delete on t2 for each row
733
insert into t1 values (1);
734
insert into t1 values (1);
735
insert into t2 values (1),(2);
738
# exec cases A, B - see multi_update.test
740
# A. send_error() w/o send_eof() branch
747
select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
639
755
# Testing of IFNULL
641
757
create table t1 (a int, b int) engine=innodb;
661
777
create table t2 (a int not null, b int, primary key (a)) engine = innodb;
662
778
insert into t1 values (10, 20);
663
779
insert into t2 values (10, 20);
780
update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
664
781
drop table t1,t2;
784
# Test of multi-table-delete with foreign key constraints
787
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
788
CREATE 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=INNODB;
789
insert into t1 set id=1;
790
insert into t2 set id=1, t1_id=1;
791
delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
795
CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
796
CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) ENGINE=INNODB;
797
INSERT INTO t1 VALUES(1);
798
INSERT INTO t2 VALUES(1, 1);
800
UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
802
UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
667
807
# Test of range_optimizer
850
# Test multi update with different join methods
853
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
854
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
855
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
856
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
858
# Full join, without key
859
update t1,t2 set t1.a=t1.a+100;
863
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
867
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
871
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
876
CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
877
CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
879
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
880
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
884
create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = innodb;
885
insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2);
886
select distinct parent,child from t1 order by parent;
710
890
# Test that MySQL priorities clustered indexes
712
892
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
935
# Test of multi-table-updates (bug #1980).
938
create table t1 ( c char(8) not null ) engine=innodb;
939
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
940
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
942
alter table t1 add b char(8) not null;
943
alter table t1 add a char(8) not null;
944
alter table t1 add primary key (a,b,c);
945
update t1 set a=c, b=c;
947
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
948
insert into t2 select * from t1;
950
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
755
954
# test autoincrement with TRUNCATE
773
972
drop table t2,t1;
975
# Test of multi updated and foreign keys
978
create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = innodb;
979
insert into `t1`values ( 1 ) ;
980
create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
981
insert into `t2`values ( 1 ) ;
982
create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
983
insert into `t3`values ( 1 ) ;
985
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
987
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;
989
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
776
993
# test for recursion depth limit
782
999
foreign key(pid) references t1(id) on delete cascade) engine=innodb;
783
1000
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
784
1001
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
785
--error ER_ROW_IS_REFERENCED_2
786
1003
delete from t1 where id=0;
787
1004
delete from t1 where id=15;
788
1005
delete from t1 where id=0;
793
1010
# Test timestamps
796
CREATE TABLE t1 (col1 int) ENGINE=InnoDB;
797
CREATE TABLE t2 (col1 int, stamp TIMESTAMP,INDEX stamp_idx (stamp)) ENGINE=InnoDB;
1013
CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
1014
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
1015
(stamp))ENGINE=InnoDB;
798
1016
insert into t1 values (1),(2),(3);
799
1017
# Note that timestamp 3 is wrong
800
insert into t2 values (1, 20020204110000),(2, 20020204110001),(4,20020204110002 ),(5,20020204110003);
1018
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
801
1019
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
802
1020
'20020204120000' GROUP BY col1;
803
1021
drop table t1,t2;
820
1038
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);
822
1040
CREATE TABLE t2 (
823
`id` int NOT NULL auto_increment,
824
`id_version` int NOT NULL default '1',
1041
`id` int(10) NOT NULL auto_increment,
1042
`id_version` int(10) NOT NULL default '1',
825
1043
PRIMARY KEY (`id`),
826
1044
KEY `id_version` (`id_version`)
827
1045
) ENGINE=InnoDB;
833
1051
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
834
1052
drop table t1,t2;
836
create TEMPORARY table t1 (a int, b varchar(200), c text not null) engine=myisam;
837
create table t2 (a int, b varchar(200), c text not null) engine=innodb;
838
create table t3 (a int, b varchar(200), c text not null) engine=innodb;
1054
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
1055
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
1056
create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
839
1057
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
840
1058
insert t2 select * from t1;
841
1059
insert t3 select * from t1;
842
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
1060
checksum table t1, t2, t3, t4 quick;
1061
checksum table t1, t2, t3, t4;
1062
checksum table t1, t2, t3, t4 extended;
843
1064
drop table t1,t2,t3;
871
1092
create index id2 on t2 (id);
872
1093
show create table t2;
873
1094
drop index id2 on t2;
874
--error ER_ERROR_ON_RENAME, ER_ERROR_ON_RENAME
875
1096
drop index id on t2;
876
1097
show create table t2;
879
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
1100
create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
880
1101
show create table t2;
881
1102
create unique index id on t2 (id,id2);
882
1103
show create table t2;
885
1106
# Check foreign key columns created in different order than key columns
886
create 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 = innodb;
887
show create table t2;
890
create table t2 (id int not null, id2 int not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
891
show create table t2;
894
create 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 = innodb;
895
show create table t2;
898
create 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 = innodb;
899
show create table t2;
902
create table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
1107
create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1108
show create table t2;
1111
create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
1112
show create table t2;
1115
create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1116
show create table t2;
1119
create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
1120
show create table t2;
1123
create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
903
1124
show create table t2;
904
1125
alter table t2 add index id_test (id), add index id_test2 (id,id2);
905
1126
show create table t2;
926
1147
# Bug #6126: Duplicate columns in keys gives misleading error message
928
--error ER_DUP_FIELDNAME
929
1150
create table t1 (c char(10), index (c,c)) engine=innodb;
930
--error ER_DUP_FIELDNAME
931
1152
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
932
--error ER_DUP_FIELDNAME
933
1154
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
934
--error ER_DUP_FIELDNAME
935
1156
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
936
1157
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
937
--error ER_DUP_FIELDNAME
938
1159
alter table t1 add key (c1,c1);
939
--error ER_DUP_FIELDNAME
940
1161
alter table t1 add key (c2,c1,c1);
941
--error ER_DUP_FIELDNAME
942
1163
alter table t1 add key (c1,c2,c1);
943
--error ER_DUP_FIELDNAME
944
1165
alter table t1 add key (c1,c1,c2);
948
1169
# Bug #4082: integer truncation
951
create table t1(a int, b int) engine=innodb;
1172
create table t1(a int(1) , b int(1)) engine=innodb;
952
1173
insert into t1 values ('1111', '3333');
953
1174
select distinct concat(a, b) from t1;
1178
# BUG#7709 test case - Boolean fulltext query against unsupported
1179
# engines does not fail
1182
CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
1184
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
957
1188
# check null values #1
960
1191
--disable_warnings
961
CREATE TABLE t1 (a_id int NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB;
1192
CREATE TABLE t1 (a_id int(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
962
1193
INSERT INTO t1 VALUES (1),(2),(3);
963
CREATE TABLE t2 (b_id int NOT NULL default '0',b_a int NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
964
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB;
1194
CREATE TABLE t2 (b_id int(4) NOT NULL default '0',b_a int(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
1195
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
965
1196
--enable_warnings
966
1197
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
967
1198
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;
1023
1254
explain select count(*) from t1 where x > -16;
1024
1255
select count(*) from t1 where x > -16;
1025
1256
select * from t1 where x > -16;
1026
select count(*) from t1 where x = 1152921504606846961;
1257
select count(*) from t1 where x = 18446744073709551601;
1030
## Not deterministic.
1031
1261
# Test for testable InnoDB status variables. This test
1032
1262
# uses previous ones(pages_created, rows_deleted, ...).
1033
--replace_column 2 #
1034
1263
show status like "Innodb_buffer_pool_pages_total";
1035
--replace_column 2 #
1036
1264
show status like "Innodb_page_size";
1037
--replace_column 2 #
1038
1265
show status like "Innodb_rows_deleted";
1039
--replace_column 2 #
1040
1266
show status like "Innodb_rows_inserted";
1041
--replace_column 2 #
1042
1267
show status like "Innodb_rows_updated";
1044
## Test for row locks InnoDB status variables.
1045
--replace_column 2 #
1269
# Test for row locks InnoDB status variables.
1046
1270
show status like "Innodb_row_lock_waits";
1047
--replace_column 2 #
1048
1271
show status like "Innodb_row_lock_current_waits";
1049
--replace_column 2 #
1050
1272
show status like "Innodb_row_lock_time";
1051
--replace_column 2 #
1052
1273
show status like "Innodb_row_lock_time_max";
1053
--replace_column 2 #
1054
1274
show status like "Innodb_row_lock_time_avg";
1056
1276
# Test for innodb_sync_spin_loops variable
1057
set @my_innodb_sync_spin_loops = @@global.innodb_sync_spin_loops;
1058
1277
show variables like "innodb_sync_spin_loops";
1059
1278
set global innodb_sync_spin_loops=1000;
1060
1279
show variables like "innodb_sync_spin_loops";
1220
1459
create table t1 (col1 varchar(2000), index (col1(767)))
1460
character set = latin1 engine = innodb;
1223
1462
# normal indexes
1224
1463
create table t2 (col1 char(255), index (col1))
1464
character set = latin1 engine = innodb;
1465
create table t3 (col1 binary(255), index (col1))
1466
character set = latin1 engine = innodb;
1226
1467
create table t4 (col1 varchar(767), index (col1))
1228
create table t5 (col1 varchar(190) primary key)
1230
create table t6 (col1 varbinary(254) primary key)
1468
character set = latin1 engine = innodb;
1469
create table t5 (col1 varchar(767) primary key)
1470
character set = latin1 engine = innodb;
1471
create table t6 (col1 varbinary(767) primary key)
1472
character set = latin1 engine = innodb;
1232
1473
create table t7 (col1 text, index(col1(767)))
1474
character set = latin1 engine = innodb;
1234
1475
create table t8 (col1 blob, index(col1(767)))
1476
character set = latin1 engine = innodb;
1237
1478
# multi-column indexes are allowed to be longer
1238
1479
create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
1480
character set = latin1 engine = innodb;
1241
1482
show create table t9;
1243
drop table t1, t2, t4, t5, t6, t7, t8, t9;
1484
drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
1245
1486
# these should have their index length trimmed
1246
1487
create table t1 (col1 varchar(768), index(col1))
1488
character set = latin1 engine = innodb;
1248
1489
create table t2 (col1 varbinary(768), index(col1))
1490
character set = latin1 engine = innodb;
1250
1491
create table t3 (col1 text, index(col1(768)))
1492
character set = latin1 engine = innodb;
1252
1493
create table t4 (col1 blob, index(col1(768)))
1494
character set = latin1 engine = innodb;
1255
1496
show create table t1;
1257
1498
drop table t1, t2, t3, t4;
1259
1500
# these should be refused
1260
--error ER_TOO_LONG_KEY
1261
1502
create table t1 (col1 varchar(768) primary key)
1263
--error ER_TOO_LONG_KEY
1264
create table t2 (col1 varbinary(1024) primary key)
1266
--error ER_TOO_LONG_KEY
1503
character set = latin1 engine = innodb;
1505
create table t2 (col1 varbinary(768) primary key)
1506
character set = latin1 engine = innodb;
1267
1508
create table t3 (col1 text, primary key(col1(768)))
1269
--error ER_TOO_LONG_KEY
1270
create table t4 (col1 blob, primary key(col1(1024)))
1509
character set = latin1 engine = innodb;
1511
create table t4 (col1 blob, primary key(col1(768)))
1512
character set = latin1 engine = innodb;
1274
1515
# Test improved foreign key error messages (bug #3443)
1285
1526
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1286
1527
) ENGINE=InnoDB;
1288
--error ER_NO_REFERENCED_ROW_2
1289
1530
INSERT INTO t2 VALUES(2);
1291
1532
INSERT INTO t1 VALUES(1);
1292
1533
INSERT INTO t2 VALUES(1);
1294
--error ER_ROW_IS_REFERENCED_2
1295
1536
DELETE FROM t1 WHERE id = 1;
1297
--error ER_ROW_IS_REFERENCED
1300
1541
SET FOREIGN_KEY_CHECKS=0;
1302
1543
SET FOREIGN_KEY_CHECKS=1;
1304
--error ER_NO_REFERENCED_ROW_2
1305
1546
INSERT INTO t2 VALUES(3);
1550
# Test that checksum table uses a consistent read Bug #12669
1552
connect (a,localhost,root,,);
1553
connect (b,localhost,root,,);
1555
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
1556
insert into t1 values (1),(2);
1560
insert into t1 values(3);
1563
# Here checksum should not see insert
1575
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
1576
insert into t1 values (1),(2);
1581
insert into t1 values(3);
1584
# Here checksum sees insert
1309
1593
# tests for bugs #9802 and #13778
1313
1597
set foreign_key_checks=0;
1314
1598
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
1315
1599
# Embedded server doesn't chdir to data directory
1316
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
1317
--error ER_CANT_CREATE_TABLE
1600
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1318
1602
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
1319
1603
set foreign_key_checks=1;
1606
# test that FKs between different charsets are not accepted in CREATE even
1609
set foreign_key_checks=0;
1610
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
1611
# Embedded server doesn't chdir to data directory
1612
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1614
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
1615
set foreign_key_checks=1;
1322
1618
# test that invalid datatype conversions with ALTER are not allowed
1324
1620
set foreign_key_checks=0;
1325
1621
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
1326
1622
create table t1(a varchar(10) primary key) engine = innodb;
1327
--error ER_ERROR_ON_RENAME, ER_ERROR_ON_RENAME
1328
1624
alter table t1 modify column a int;
1329
1625
set foreign_key_checks=1;
1330
1626
drop table t2,t1;
1628
# test that charset conversions with ALTER are allowed when f_k_c is 0
1630
set foreign_key_checks=0;
1631
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
1632
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
1633
alter table t1 convert to character set utf8;
1634
set foreign_key_checks=1;
1637
# test that RENAME does not allow invalid charsets when f_k_c is 0
1639
set foreign_key_checks=0;
1640
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
1641
create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
1642
# Embedded server doesn't chdir to data directory
1643
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1645
rename table t3 to t1;
1646
set foreign_key_checks=1;
1332
1649
# test that foreign key errors are reported correctly (Bug #15550)
1334
1651
create table t1(a int primary key) row_format=redundant engine=innodb;
1368
1685
# Test that we can create a large (>1K) key
1370
create table t1 (a varchar(255),
1374
key (a(200),b(200),c(200),d(200))) engine=innodb;
1687
create table t1 (a varchar(255) character set utf8,
1688
b varchar(255) character set utf8,
1689
c varchar(255) character set utf8,
1690
d varchar(255) character set utf8,
1691
key (a,b,c,d)) engine=innodb;
1376
1693
--error ER_TOO_LONG_KEY
1377
create table t1 (a varchar(255),
1694
create table t1 (a varchar(255) character set utf8,
1695
b varchar(255) character set utf8,
1696
c varchar(255) character set utf8,
1697
d varchar(255) character set utf8,
1698
e varchar(255) character set utf8,
1382
1699
key (a,b,c,d,e)) engine=innodb;
1385
1702
# test the padding of BINARY types and collations (Bug #14189)
1387
1704
create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
1388
create table t3 (s1 varchar(2) ,primary key (s1)) engine=innodb;
1389
create table t4 (s1 char(2) ,primary key (s1)) engine=innodb;
1705
create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
1706
create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
1707
create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
1391
1709
insert into t1 values (0x41),(0x4120),(0x4100);
1392
--error ER_DUP_ENTRY
1710
-- error ER_DUP_ENTRY
1711
insert into t2 values (0x41),(0x4120),(0x4100);
1712
insert into t2 values (0x41),(0x4120);
1713
-- error ER_DUP_ENTRY
1393
1714
insert into t3 values (0x41),(0x4120),(0x4100);
1394
1715
insert into t3 values (0x41),(0x4100);
1395
--error ER_DUP_ENTRY
1716
-- error ER_DUP_ENTRY
1396
1717
insert into t4 values (0x41),(0x4120),(0x4100);
1397
1718
insert into t4 values (0x41),(0x4100);
1398
1719
select hex(s1) from t1;
1720
select hex(s1) from t2;
1399
1721
select hex(s1) from t3;
1400
1722
select hex(s1) from t4;
1401
drop table t1,t3,t4;
1723
drop table t1,t2,t3,t4;
1403
1725
create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
1404
create table t2 (s1 varbinary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
1726
create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
1406
1728
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
1407
1730
insert into t2 values(0x42);
1408
1731
insert into t2 values(0x41);
1409
1732
select hex(s1) from t2;
1410
--error ER_ROW_IS_REFERENCED_2
1411
1733
update t1 set s1=0x123456 where a=2;
1412
1734
select hex(s1) from t2;
1413
1736
update t1 set s1=0x12 where a=1;
1414
--error ER_DATA_TOO_LONG
1415
1738
update t1 set s1=0x12345678 where a=1;
1416
1740
update t1 set s1=0x123457 where a=1;
1417
1741
update t1 set s1=0x1220 where a=1;
1418
1742
select hex(s1) from t2;
1460
1786
DROP TABLE t2,t1;
1789
# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
1792
connect (a,localhost,root,,);
1793
connect (b,localhost,root,,);
1795
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
1796
insert into t1(a) values (1),(2),(3);
1800
update t1 set b = 5 where a = 2;
1803
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
1807
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
1808
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
1809
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
1810
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
1811
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
1821
# Another trigger test
1823
connect (a,localhost,root,,);
1824
connect (b,localhost,root,,);
1826
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
1827
create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
1828
create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
1829
create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
1830
create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
1831
insert into t1(a) values (1),(2),(3);
1832
insert into t2(a) values (1),(2),(3);
1833
insert into t3(a) values (1),(2),(3);
1834
insert into t4(a) values (1),(2),(3);
1835
insert into t3(a) values (5),(7),(8);
1836
insert into t4(a) values (5),(7),(8);
1837
insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
1840
create trigger t1t before insert on t1 for each row begin
1841
INSERT INTO t2 SET a = NEW.a;
1844
create trigger t2t before insert on t2 for each row begin
1845
DELETE FROM t3 WHERE a = NEW.a;
1848
create trigger t3t before delete on t3 for each row begin
1849
UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
1852
create trigger t4t before update on t4 for each row begin
1853
UPDATE t5 SET b = b + 1 where a = NEW.a;
1858
update t1 set b = b + 5 where a = 1;
1859
update t2 set b = b + 5 where a = 1;
1860
update t3 set b = b + 5 where a = 1;
1861
update t4 set b = b + 5 where a = 1;
1862
insert into t5(a) values(20);
1865
insert into t1(a) values(7);
1866
insert into t2(a) values(8);
1867
delete from t2 where a = 3;
1868
update t4 set b = b + 1 where a = 3;
1874
drop table t1, t2, t3, t4, t5;
1463
1880
# Test that cascading updates leading to duplicate keys give the correct
1464
1881
# error message (bug #9680)
1890
2307
DROP TABLE t1,t2;
2310
# Bug #21101 (Prints wrong error message if max row size is too large)
2314
c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
2315
c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
2316
c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
2317
c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
2318
c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
2319
c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
2320
c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
2321
c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
1893
2325
# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
1895
2327
DROP TABLE IF EXISTS t1;
1896
2328
CREATE TABLE t1(
1897
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
2329
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
1898
2330
) ENGINE=InnoDB;
1899
2331
INSERT INTO t1 VALUES(-10);
1900
2332
SELECT * FROM t1;
1908
2340
SELECT * FROM t1;
1911
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;
2344
# Bug #21409 Incorrect result returned when in READ-COMMITTED with
2347
CONNECT (c1,localhost,root,,);
2348
CONNECT (c2,localhost,root,,);
2350
SET TX_ISOLATION='read-committed';
2352
DROP TABLE IF EXISTS t1, t2;
2353
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
2354
CREATE TABLE t2 LIKE t1;
2357
SET TX_ISOLATION='read-committed';
2359
INSERT INTO t1 VALUES (1);
2362
SELECT * FROM t1 WHERE a=1;
2365
CONNECT (c1,localhost,root,,);
2366
CONNECT (c2,localhost,root,,);
2368
SET TX_ISOLATION='read-committed';
2372
SET TX_ISOLATION='read-committed';
2374
INSERT INTO t1 VALUES (2);
2377
# The result set below should be the same for both selects
2378
SELECT * FROM t1 WHERE a=2;
2379
SELECT * FROM t1 WHERE a=2;
1914
2385
#######################################################################