~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Bug#21114 (Foreign key creation fails to table with name format)
3
#
4
# Trying to trick the parser into thinking $FCT(...) is a function call,
5
# which is not in the CREATE TABLE and FOREIGN KEY ... REFERENCES syntax
6
#
7
# Usage :
8
#
9
# let $engine_type=InnoDb;
10
# let $verbose=1;
11
# let $FCT= <value_1>;
12
# -- source parser_stress_func.inc
13
# let $FCT= <value_2>;
14
# -- source parser_stress_func.inc
15
# let $verbose=0;
16
# let $FCT= <value_3>;
17
# -- source parser_stress_func.inc
18
# let $FCT= <value_4>;
19
# -- source parser_stress_func.inc
20
21
-- disable_warnings
22
eval drop table if exists $FCT;
23
drop table if exists bug21114_child;
24
-- enable_warnings
25
26
--disable_query_log
27
--disable_result_log
28
29
eval CREATE TABLE $FCT(
30
  col1 int not null,
31
  col2 int not null,
32
  col3 varchar(10),
33
  CONSTRAINT pk PRIMARY KEY (col1, col2)
34
) ENGINE $engine_type;
35
36
eval CREATE TABLE bug21114_child(
37
  pk int not null,
38
  fk_col1 int not null,
39
  fk_col2 int not null,
40
  fk_col3 int not null,
41
  fk_col4 int not null,
42
  CONSTRAINT fk_fct FOREIGN KEY (fk_col1, fk_col2)
43
    REFERENCES $FCT(col1, col2),
44
  CONSTRAINT fk_fct_space FOREIGN KEY (fk_col3, fk_col4)
45
    REFERENCES $FCT (col1, col2)
46
) ENGINE $engine_type;
47
48
--enable_query_log
49
--enable_result_log
50
51
if ($verbose)
52
{
53
  eval SHOW CREATE TABLE $FCT;
54
  SHOW CREATE TABLE bug21114_child;
55
}
56
57
DROP TABLE bug21114_child;
58
eval DROP TABLE $FCT;
59