mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
4428409ddb
Backport from 6.0 to 5.5
97 lines
2.4 KiB
Text
97 lines
2.4 KiB
Text
#
|
|
# Test syntax of foreign keys
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
create table t1 (
|
|
a int not null references t2,
|
|
b int not null references t2 (c),
|
|
primary key (a,b),
|
|
foreign key (a) references t3 match full,
|
|
foreign key (a) references t3 match partial,
|
|
foreign key (a,b) references t3 (c,d) on delete no action
|
|
on update no action,
|
|
foreign key (a,b) references t3 (c,d) on update cascade,
|
|
foreign key (a,b) references t3 (c,d) on delete set default,
|
|
foreign key (a,b) references t3 (c,d) on update set null);
|
|
|
|
create index a on t1 (a);
|
|
create unique index b on t1 (a,b);
|
|
drop table t1;
|
|
|
|
# End of 4.1 tests
|
|
|
|
#
|
|
# Bug#34455 (Ambiguous foreign keys syntax is accepted)
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t_34455;
|
|
--enable_warnings
|
|
|
|
# 2 match clauses, illegal
|
|
--error ER_PARSE_ERROR
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a) match full match partial);
|
|
|
|
# match after on delete, illegal
|
|
--error ER_PARSE_ERROR
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a) on delete set default match full);
|
|
|
|
# match after on update, illegal
|
|
--error ER_PARSE_ERROR
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a) on update set default match full);
|
|
|
|
# 2 on delete clauses, illegal
|
|
--error ER_PARSE_ERROR
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a)
|
|
on delete set default on delete set default);
|
|
|
|
# 2 on update clauses, illegal
|
|
--error ER_PARSE_ERROR
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a)
|
|
on update set default on update set default);
|
|
|
|
create table t_34455 (a int not null);
|
|
|
|
# 2 match clauses, illegal
|
|
--error ER_PARSE_ERROR
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a) match full match partial);
|
|
|
|
# match after on delete, illegal
|
|
--error ER_PARSE_ERROR
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a) on delete set default match full);
|
|
|
|
# match after on update, illegal
|
|
--error ER_PARSE_ERROR
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a) on update set default match full);
|
|
|
|
# 2 on delete clauses, illegal
|
|
--error ER_PARSE_ERROR
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a)
|
|
on delete set default on delete set default);
|
|
|
|
# 2 on update clauses, illegal
|
|
--error ER_PARSE_ERROR
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a)
|
|
on update set default on update set default);
|
|
|
|
drop table t_34455;
|
|
|