diff options
author | monty@mysql.com <> | 2004-05-12 00:29:52 +0300 |
---|---|---|
committer | monty@mysql.com <> | 2004-05-12 00:29:52 +0300 |
commit | 116f61c656678830e045938c26c3b4b6c89aa4b0 (patch) | |
tree | 11c75fdf1dd0dbc84178dbfbb39f5a584d19d581 /mysql-test/t/innodb.test | |
parent | 6ad9691dc8098aa94cd1994e009d4eb48f689265 (diff) | |
download | mariadb-git-116f61c656678830e045938c26c3b4b6c89aa4b0.tar.gz |
Don't automaticly generate a new key for a foreign key constraint if there is already a usable key.
Prefer not automatic keys before automatic keys. If there is two conf
Diffstat (limited to 'mysql-test/t/innodb.test')
-rw-r--r-- | mysql-test/t/innodb.test | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index e20be83b4b6..a260ab1263d 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1044,3 +1044,46 @@ drop table t1; create table t1 (a int) engine=innodb; create table t2 like t1; drop table t1,t2; + +# +# Test of automaticly created foreign keys +# + +create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb; +create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb; +show create table t1; +show create table t2; +create index id on t2 (id); +show create table t2; +create index id2 on t2 (id); +show create table t2; +drop index id2 on t2; +--error 1025,1025 +drop index id on t2; +show create table t2; +drop table t2; + +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; +show create table t2; +create unique index id on t2 (id,id2); +show create table t2; +drop table t2; + +# Check foreign key columns created in different order than key columns +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; +show create table t2; +drop table t2; + +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; +show create table t2; +drop table t2; + +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; +show create table t2; +drop table t2; + +# Test error handling +--error 1005 +create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; + +drop table t1; |