66
66
drop database if exists mysqltest;
69
eval create table t1 (id int not null auto_increment, code tinyint not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=$engine_type;
69
eval create 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
71
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
72
72
select id, code, name from t1 order by id;
725
725
eval CREATE TABLE t1 (
726
number bigint(20) NOT NULL default '0',
726
number bigint NOT NULL default '0',
727
727
cname char(15) NOT NULL default '',
728
carrier_id smallint(6) NOT NULL default '0',
729
privacy tinyint(4) NOT NULL default '0',
728
carrier_id int NOT NULL default '0',
729
privacy int NOT NULL default '0',
730
730
last_mod_date timestamp NOT NULL,
731
last_mod_id smallint(6) NOT NULL default '0',
731
last_mod_id int NOT NULL default '0',
732
732
last_app_date timestamp NOT NULL,
733
last_app_id smallint(6) default '-1',
734
version smallint(6) NOT NULL default '0',
735
assigned_scps int(11) default '0',
736
status tinyint(4) default '0'
733
last_app_id int default '-1',
734
version int NOT NULL default '0',
735
assigned_scps int default '0',
736
status int default '0'
737
737
) ENGINE=$engine_type;
738
738
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
739
739
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
742
742
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
743
743
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
744
744
eval CREATE TABLE t2 (
745
number bigint(20) NOT NULL default '0',
745
number bigint NOT NULL default '0',
746
746
cname char(15) NOT NULL default '',
747
carrier_id smallint(6) NOT NULL default '0',
748
privacy tinyint(4) NOT NULL default '0',
747
carrier_id int NOT NULL default '0',
748
privacy int NOT NULL default '0',
749
749
last_mod_date timestamp NOT NULL,
750
last_mod_id smallint(6) NOT NULL default '0',
750
last_mod_id int NOT NULL default '0',
751
751
last_app_date timestamp NOT NULL,
752
last_app_id smallint(6) default '-1',
753
version smallint(6) NOT NULL default '0',
754
assigned_scps int(11) default '0',
755
status tinyint(4) default '0'
752
last_app_id int default '-1',
753
version int NOT NULL default '0',
754
assigned_scps int default '0',
755
status int default '0'
756
756
) ENGINE=$engine_type;
757
757
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
758
758
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
1047
1047
# Test of multi updated and foreign keys
1050
eval create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = $engine_type;
1050
eval create table `t1` (`id` int not null ,primary key ( `id` )) engine = $engine_type;
1051
1051
insert into `t1`values ( 1 ) ;
1052
eval 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 = $engine_type;
1052
eval create 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;
1053
1053
insert into `t2`values ( 1 ) ;
1054
eval create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = $engine_type;
1054
eval create table `t3` (`id` int not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = $engine_type;
1055
1055
insert into `t3`values ( 1 ) ;
1057
1057
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
1084
1084
# Test timestamps
1087
eval CREATE TABLE t1 (col1 int(1))ENGINE=$engine_type;
1088
eval CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
1087
eval CREATE TABLE t1 (col1 int)ENGINE=$engine_type;
1088
eval CREATE TABLE t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
1089
1089
(stamp))ENGINE=$engine_type;
1090
1090
insert into t1 values (1),(2),(3);
1091
1091
# Note that timestamp 3 is wrong
1092
1093
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1093
1094
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1094
1095
'20020204120000' GROUP BY col1;
1112
1113
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);
1114
1115
eval CREATE TABLE t2 (
1115
`id` int(10) NOT NULL auto_increment,
1116
`id_version` int(10) NOT NULL default '1',
1116
`id` int NOT NULL auto_increment,
1117
`id_version` int NOT NULL default '1',
1117
1118
PRIMARY KEY (`id`),
1118
1119
KEY `id_version` (`id_version`)
1119
1120
) ENGINE=$engine_type;
1189
1190
show create table t2;
1192
eval 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 = $engine_type;
1193
eval create 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;
1193
1194
show create table t2;
1194
1195
create unique index id on t2 (id,id2);
1195
1196
show create table t2;
1198
1199
# Check foreign key columns created in different order than key columns
1199
eval 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 = $engine_type;
1200
show create table t2;
1203
eval 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 = $engine_type;
1204
show create table t2;
1207
eval 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 = $engine_type;
1208
show create table t2;
1211
eval 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 = $engine_type;
1212
show create table t2;
1215
eval 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= $engine_type;
1200
eval 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 = $engine_type;
1201
show create table t2;
1204
eval 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 = $engine_type;
1205
show create table t2;
1208
eval 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 = $engine_type;
1209
show create table t2;
1212
eval 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 = $engine_type;
1213
show create table t2;
1216
eval create 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;
1216
1217
show create table t2;
1217
1218
alter table t2 add index id_test (id), add index id_test2 (id,id2);
1218
1219
show create table t2;
1326
1327
--disable_warnings
1327
eval CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=$engine_type DEFAULT CHARSET=latin1;
1328
eval CREATE TABLE t1 (a_id int NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=$engine_type DEFAULT CHARSET=latin1;
1328
1329
INSERT INTO t1 VALUES (1),(2),(3);
1329
eval CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
1330
eval CREATE TABLE t2 (b_id int NOT NULL default '0',b_a int NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
1330
1331
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;
1331
1332
--enable_warnings
1332
1333
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
1468
1471
# Clean up filename -- embedded server reports whole path without .frm,
1469
1472
# regular server reports relative path with .frm (argh!)
1470
--replace_result \\ / $DRIZZLE_TEST_DIR . /var/master-data/ / t1.frm t1
1471
create table t1 (v varchar(65530), key(v));
1473
create table t1 (v varchar(65536));
1474
show create table t1;
1476
create table t1 (v varchar(65530) character set utf8);
1477
show create table t1;
1480
eval set storage_engine=$default;
1473
# @TODO The below fails because it assumes latin1
1474
# as the charset. Possibly re-enable a similar test
1475
#--replace_result \\ / $DRIZZLE_TEST_DIR . /var/master-data/ / t1.frm t1
1476
#create table t1 (v varchar(65530), key(v));
1478
#create table t1 (v varchar(65536));
1479
#show create table t1;
1481
#create table t1 (v varchar(65530) character set utf8);
1482
#show create table t1;
1485
#eval set storage_engine=$default;
1482
1487
# InnoDB specific varchar tests
1483
eval create table t1 (v varchar(16384)) engine=$engine_type;
1488
#eval create table t1 (v varchar(16384)) engine=$engine_type;
1487
1492
# BUG#11039 Wrong key length in min()
1981
1986
DROP TABLE t2,t1;
1985
# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
1988
connect (a,localhost,root,,);
1989
connect (b,localhost,root,,);
1991
eval create table t1(a int not null, b int, c int, d int, primary key(a)) engine=$engine_type;
1992
insert into t1(a) values (1),(2),(3);
1996
update t1 set b = 5 where a = 2;
1999
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
2003
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
2004
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
2005
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
2006
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
2007
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
2017
# Another trigger test
2019
connect (a,localhost,root,,);
2020
connect (b,localhost,root,,);
2022
eval create table t1(a int not null, b int, c int, d int, primary key(a)) engine=$engine_type;
2023
eval create table t2(a int not null, b int, c int, d int, primary key(a)) engine=$engine_type;
2024
eval create table t3(a int not null, b int, c int, d int, primary key(a)) engine=$engine_type;
2025
eval create table t4(a int not null, b int, c int, d int, primary key(a)) engine=$engine_type;
2026
eval create table t5(a int not null, b int, c int, d int, primary key(a)) engine=$engine_type;
2027
insert into t1(a) values (1),(2),(3);
2028
insert into t2(a) values (1),(2),(3);
2029
insert into t3(a) values (1),(2),(3);
2030
insert into t4(a) values (1),(2),(3);
2031
insert into t3(a) values (5),(7),(8);
2032
insert into t4(a) values (5),(7),(8);
2033
insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
2036
create trigger t1t before insert on t1 for each row begin
2037
INSERT INTO t2 SET a = NEW.a;
2040
create trigger t2t before insert on t2 for each row begin
2041
DELETE FROM t3 WHERE a = NEW.a;
2044
create trigger t3t before delete on t3 for each row begin
2045
UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
2048
create trigger t4t before update on t4 for each row begin
2049
UPDATE t5 SET b = b + 1 where a = NEW.a;
2054
update t1 set b = b + 5 where a = 1;
2055
update t2 set b = b + 5 where a = 1;
2056
update t3 set b = b + 5 where a = 1;
2057
update t4 set b = b + 5 where a = 1;
2058
insert into t5(a) values(20);
2061
insert into t1(a) values(7);
2062
insert into t2(a) values(8);
2063
delete from t2 where a = 3;
2064
update t4 set b = b + 1 where a = 3;
2070
drop table t1, t2, t3, t4, t5;
2075
1989
if ($test_foreign_keys)