2
# Test syntax of foreign keys
6
drop table if exists t1;
10
a int not null references t2,
11
b int not null references t2 (c),
13
foreign key (a) references t3 match full,
14
foreign key (a) references t3 match partial,
15
foreign key (a,b) references t3 (c,d) on delete no action
17
foreign key (a,b) references t3 (c,d) on update cascade,
18
foreign key (a,b) references t3 (c,d) on delete set default,
19
foreign key (a,b) references t3 (c,d) on update set null);
21
create index a on t1 (a);
22
create unique index b on t1 (a,b);
28
# Bug#34455 (Ambiguous foreign keys syntax is accepted)
32
drop table if exists t_34455;
35
# 2 match clauses, illegal
36
--error ER_PARSE_ERROR
37
create table t_34455 (
39
foreign key (a) references t3 (a) match full match partial);
41
# match after on delete, illegal
42
--error ER_PARSE_ERROR
43
create table t_34455 (
45
foreign key (a) references t3 (a) on delete set default match full);
47
# match after on update, illegal
48
--error ER_PARSE_ERROR
49
create table t_34455 (
51
foreign key (a) references t3 (a) on update set default match full);
53
# 2 on delete clauses, illegal
54
--error ER_PARSE_ERROR
55
create table t_34455 (
57
foreign key (a) references t3 (a)
58
on delete set default on delete set default);
60
# 2 on update clauses, illegal
61
--error ER_PARSE_ERROR
62
create table t_34455 (
64
foreign key (a) references t3 (a)
65
on update set default on update set default);
67
create table t_34455 (a int not null);
69
# 2 match clauses, illegal
70
--error ER_PARSE_ERROR
72
add foreign key (a) references t3 (a) match full match partial);
74
# match after on delete, illegal
75
--error ER_PARSE_ERROR
77
add foreign key (a) references t3 (a) on delete set default match full);
79
# match after on update, illegal
80
--error ER_PARSE_ERROR
82
add foreign key (a) references t3 (a) on update set default match full);
84
# 2 on delete clauses, illegal
85
--error ER_PARSE_ERROR
87
add foreign key (a) references t3 (a)
88
on delete set default on delete set default);
90
# 2 on update clauses, illegal
91
--error ER_PARSE_ERROR
93
add foreign key (a) references t3 (a)
94
on update set default on update set default);