~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Test syntax of foreign keys
3
#
4
5
--disable_warnings
6
drop table if exists t1;
7
--enable_warnings
8
9
create table t1 (
10
	a int not null references t2,
11
	b int not null references t2 (c),
12
	primary key (a,b),
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
16
	  on update 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);
20
21
create index a on t1 (a);
22
create unique index b on t1 (a,b);
23
drop table t1;
24
25
# End of 4.1 tests
26
27
#
28
# Bug#34455 (Ambiguous foreign keys syntax is accepted)
29
#
30
31
--disable_warnings
32
drop table if exists t_34455;
33
--enable_warnings
34
35
# 2 match clauses, illegal
36
--error ER_PARSE_ERROR
37
create table t_34455 (
38
  a int not null,
39
  foreign key (a) references t3 (a) match full match partial);
40
41
# match after on delete, illegal
42
--error ER_PARSE_ERROR
43
create table t_34455 (
44
  a int not null,
45
  foreign key (a) references t3 (a) on delete set default match full);
46
47
# match after on update, illegal
48
--error ER_PARSE_ERROR
49
create table t_34455 (
50
  a int not null,
51
  foreign key (a) references t3 (a) on update set default match full);
52
53
# 2 on delete clauses, illegal
54
--error ER_PARSE_ERROR
55
create table t_34455 (
56
  a int not null,
57
  foreign key (a) references t3 (a)
58
  on delete set default on delete set default);
59
60
# 2 on update clauses, illegal
61
--error ER_PARSE_ERROR
62
create table t_34455 (
63
  a int not null,
64
  foreign key (a) references t3 (a)
65
  on update set default on update set default);
66
67
create table t_34455 (a int not null);
68
69
# 2 match clauses, illegal
70
--error ER_PARSE_ERROR
71
alter table t_34455
72
  add foreign key (a) references t3 (a) match full match partial);
73
74
# match after on delete, illegal
75
--error ER_PARSE_ERROR
76
alter table t_34455
77
  add foreign key (a) references t3 (a) on delete set default match full);
78
79
# match after on update, illegal
80
--error ER_PARSE_ERROR
81
alter table t_34455
82
  add foreign key (a) references t3 (a) on update set default match full);
83
84
# 2 on delete clauses, illegal
85
--error ER_PARSE_ERROR
86
alter table t_34455
87
  add foreign key (a) references t3 (a)
88
  on delete set default on delete set default);
89
90
# 2 on update clauses, illegal
91
--error ER_PARSE_ERROR
92
alter table t_34455
93
  add foreign key (a) references t3 (a)
94
  on update set default on update set default);
95
96
drop table t_34455;
97