1
by brian
clean slate |
1 |
-- source include/testdb_only.inc
|
2 |
--disable_warnings
|
|
3 |
DROP TABLE IF EXISTS t1,t2,t3; |
|
4 |
--enable_warnings
|
|
5 |
||
6 |
#
|
|
7 |
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables |
|
8 |
#
|
|
9 |
||
10 |
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; |
|
11 |
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id), |
|
12 |
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE, |
|
13 |
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB; |
|
14 |
||
15 |
CREATE TABLE t3 (id INT PRIMARY KEY, t2_id INT, INDEX par_ind (t2_id), |
|
16 |
FOREIGN KEY (id, t2_id) REFERENCES t2(t1_id, id) ON DELETE CASCADE) ENGINE=INNODB; |
|
17 |
||
1273.19.6
by Brian Aker
This remove the original info_schema system for the server. More still to |
18 |
#select * from information_schema.OLD_TABLE_CONSTRAINTS where |
19 |
#TABLE_SCHEMA= "test"; |
|
1643.3.13
by Brian Aker
Remove sort() and add in DEBUG mode to randomize the results of generators. |
20 |
--sorted_result
|
1273.19.6
by Brian Aker
This remove the original info_schema system for the server. More still to |
21 |
select * from data_dictionary.indexes where TABLE_SCHEMA= "test"; |
1
by brian
clean slate |
22 |
|
23 |
drop table t3, t2, t1; |
|
24 |
||
25 |
#
|
|
26 |
# Test for REFERENTIAL_CONSTRAINTS table |
|
27 |
#
|
|
28 |
CREATE TABLE t1(a1 INT NOT NULL, a2 INT NOT NULL, |
|
29 |
PRIMARY KEY(a1, a2)) ENGINE=INNODB; |
|
30 |
CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2), |
|
31 |
CONSTRAINT A1 |
|
32 |
FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2) |
|
33 |
ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB; |
|
34 |
CREATE TABLE t3(b1 INT, b2 INT, INDEX t3_indx (b1, b2), |
|
35 |
CONSTRAINT A2 |
|
36 |
FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2) |
|
37 |
ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB; |
|
38 |
CREATE TABLE t4(b1 INT, b2 INT, UNIQUE KEY t4_ukey (b1, b2), |
|
39 |
CONSTRAINT A3 |
|
40 |
FOREIGN KEY (b1, b2) REFERENCES t3(b1, b2) |
|
41 |
ON UPDATE NO ACTION ON DELETE SET NULL) ENGINE=INNODB; |
|
42 |
CREATE TABLE t5(b1 INT, b2 INT, INDEX (b1, b2), |
|
43 |
CONSTRAINT A4 |
|
44 |
FOREIGN KEY (b1, b2) REFERENCES t4(b1, b2) |
|
45 |
ON UPDATE RESTRICT ON DELETE CASCADE) ENGINE=INNODB; |
|
46 |
||
1273.19.6
by Brian Aker
This remove the original info_schema system for the server. More still to |
47 |
#select a.CONSTRAINT_SCHEMA, b.TABLE_NAME, CONSTRAINT_TYPE, |
48 |
# b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, |
|
49 |
# MATCH_OPTION, UPDATE_RULE, DELETE_RULE, b.REFERENCED_TABLE_NAME |
|
50 |
#from information_schema.OLD_TABLE_CONSTRAINTS a, |
|
51 |
# information_schema.OLD_REFERENTIAL_CONSTRAINTS b |
|
52 |
#where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and |
|
53 |
#a.CONSTRAINT_NAME = b.CONSTRAINT_NAME; |
|
1
by brian
clean slate |
54 |
drop tables t5, t4, t3, t2, t1; |
55 |
||
56 |
#
|
|
57 |
# Bug#25026 `information_schema.KEY_COLUMN_USAGE`.`REFERENCED_TABLE_NAME` returns garbage |
|
58 |
#
|
|
59 |
create database `db-1`; |
|
60 |
use `db-1`; |
|
61 |
create table `t-2` ( |
|
765
by Brian Aker
Fix information_schema_chmod test. |
62 |
id int not null auto_increment, |
1
by brian
clean slate |
63 |
primary key (id) |
64 |
) engine=innodb; |
|
65 |
||
66 |
create table `t-1` ( |
|
765
by Brian Aker
Fix information_schema_chmod test. |
67 |
id int not null auto_increment, |
68 |
idtype int not null, |
|
1
by brian
clean slate |
69 |
primary key (id), |
70 |
key fk_t1_1 (idtype), |
|
71 |
constraint fk_t1_1 foreign key (idtype) references `t-2` (id) |
|
72 |
) engine=innodb; |
|
73 |
use test; |
|
1273.19.6
by Brian Aker
This remove the original info_schema system for the server. More still to |
74 |
#select referenced_table_schema, referenced_table_name |
75 |
#from data_dictionary.indexes |
|
76 |
#where constraint_schema = 'db-1'; |
|
1
by brian
clean slate |
77 |
drop database `db-1`; |
78 |
||
79 |
#
|
|
80 |
# Bug#35108 SELECT FROM REFERENTIAL_CONSTRAINTS crashes |
|
81 |
#
|
|
82 |
create table t1(id int primary key) engine = Innodb; |
|
83 |
create table t2(pid int, foreign key (pid) references t1(id)) engine = Innodb; |
|
84 |
set foreign_key_checks = 0; |
|
85 |
drop table t1; |
|
1273.19.6
by Brian Aker
This remove the original info_schema system for the server. More still to |
86 |
#select UNIQUE_CONSTRAINT_NAME |
87 |
#from data_dictionary.OLD_referential_constraints |
|
88 |
#where constraint_schema = schema(); |
|
1
by brian
clean slate |
89 |
drop table t2; |
90 |
set foreign_key_checks = 1; |