Debian Codegraph @

mysql-test/suite/ndb/r/ndb_fk_db.result

raw
1 create database mydb0;
2 use mydb0;
3 create table parent (
4 a int primary key,
5 b int not null,
6 c int not null,
7 unique(b) using hash,
8 index(c)) engine = ndb;
9 create database mydb1;
10 use mydb1;
11 create table child (
12 a int primary key,
13 b int not null,
14 c int not null,
15 constraint fk1 foreign key(a) references mydb0.parent (a),
16 unique(b) using hash,
17 index(c)) engine = ndb;
18 show create table child;
19 Table Create Table
20 child CREATE TABLE `child` (
21 `a` int NOT NULL,
22 `b` int NOT NULL,
23 `c` int NOT NULL,
24 PRIMARY KEY (`a`),
25 UNIQUE KEY `b` (`b`) USING HASH,
26 KEY `c` (`c`),
27 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`)
28 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
29 alter table child algorithm=copy, add constraint fk2 foreign key (b)
30 references mydb0.parent(a);
31 show create table child;
32 Table Create Table
33 child CREATE TABLE `child` (
34 `a` int NOT NULL,
35 `b` int NOT NULL,
36 `c` int NOT NULL,
37 PRIMARY KEY (`a`),
38 UNIQUE KEY `b` (`b`) USING HASH,
39 KEY `c` (`c`),
40 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`),
41 CONSTRAINT `fk2` FOREIGN KEY (`b`) REFERENCES `mydb0`.`parent` (`a`)
42 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
43 alter table child algorithm=inplace, add constraint fk3 foreign key (c)
44 references mydb0.parent(a);
45 show create table child;
46 Table Create Table
47 child CREATE TABLE `child` (
48 `a` int NOT NULL,
49 `b` int NOT NULL,
50 `c` int NOT NULL,
51 PRIMARY KEY (`a`),
52 UNIQUE KEY `b` (`b`) USING HASH,
53 KEY `c` (`c`),
54 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`),
55 CONSTRAINT `fk2` FOREIGN KEY (`b`) REFERENCES `mydb0`.`parent` (`a`),
56 CONSTRAINT `fk3` FOREIGN KEY (`c`) REFERENCES `mydb0`.`parent` (`a`)
57 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
58 alter table child algorithm=copy, drop foreign key fk2;
59 show create table child;
60 Table Create Table
61 child CREATE TABLE `child` (
62 `a` int NOT NULL,
63 `b` int NOT NULL,
64 `c` int NOT NULL,
65 PRIMARY KEY (`a`),
66 UNIQUE KEY `b` (`b`) USING HASH,
67 KEY `c` (`c`),
68 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`),
69 CONSTRAINT `fk3` FOREIGN KEY (`c`) REFERENCES `mydb0`.`parent` (`a`)
70 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
71 alter table child algorithm=inplace, drop foreign key fk3;
72 show create table child;
73 Table Create Table
74 child CREATE TABLE `child` (
75 `a` int NOT NULL,
76 `b` int NOT NULL,
77 `c` int NOT NULL,
78 PRIMARY KEY (`a`),
79 UNIQUE KEY `b` (`b`) USING HASH,
80 KEY `c` (`c`),
81 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`)
82 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
83 alter table mydb0.parent algorithm=copy, rename mydb1.parent;
84 show create table child;
85 Table Create Table
86 child CREATE TABLE `child` (
87 `a` int NOT NULL,
88 `b` int NOT NULL,
89 `c` int NOT NULL,
90 PRIMARY KEY (`a`),
91 UNIQUE KEY `b` (`b`) USING HASH,
92 KEY `c` (`c`),
93 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`)
94 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
95 alter table mydb1.parent algorithm=inplace, rename mydb0.parent;
96 show create table child;
97 Table Create Table
98 child CREATE TABLE `child` (
99 `a` int NOT NULL,
100 `b` int NOT NULL,
101 `c` int NOT NULL,
102 PRIMARY KEY (`a`),
103 UNIQUE KEY `b` (`b`) USING HASH,
104 KEY `c` (`c`),
105 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`)
106 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
107 use test;
108 alter table mydb1.child algorithm=copy, add constraint fk2 foreign key (b)
109 references mydb0.parent(a);
110 use mydb1;
111 show create table child;
112 Table Create Table
113 child CREATE TABLE `child` (
114 `a` int NOT NULL,
115 `b` int NOT NULL,
116 `c` int NOT NULL,
117 PRIMARY KEY (`a`),
118 UNIQUE KEY `b` (`b`) USING HASH,
119 KEY `c` (`c`),
120 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`),
121 CONSTRAINT `fk2` FOREIGN KEY (`b`) REFERENCES `mydb0`.`parent` (`a`)
122 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
123 use test;
124 alter table mydb1.child algorithm=inplace, add constraint fk3 foreign key (c)
125 references mydb0.parent(a);
126 use mydb1;
127 show create table child;
128 Table Create Table
129 child CREATE TABLE `child` (
130 `a` int NOT NULL,
131 `b` int NOT NULL,
132 `c` int NOT NULL,
133 PRIMARY KEY (`a`),
134 UNIQUE KEY `b` (`b`) USING HASH,
135 KEY `c` (`c`),
136 CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `mydb0`.`parent` (`a`),
137 CONSTRAINT `fk2` FOREIGN KEY (`b`) REFERENCES `mydb0`.`parent` (`a`),
138 CONSTRAINT `fk3` FOREIGN KEY (`c`) REFERENCES `mydb0`.`parent` (`a`)
139 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
140 use test;
141 drop database mydb1;
142 drop database mydb0;
143 set @i=2;
144 create database mydb0;
145 use mydb0;
146 create table t0 (a int primary key) engine = innodb;
147 create table t1 (a int primary key) engine = innodb;
148 alter table mydb0.t0 add constraint fk0 foreign key (a)
149 references mydb0.t1(a);
150 alter table mydb0.t1 add constraint fk1 foreign key (a)
151 references mydb0.t0(a);
152 drop database mydb0;
153 set @i=1;
154 create database mydb0;
155 use mydb0;
156 create table t0 (a int primary key) engine = ndb;
157 create table t1 (a int primary key) engine = ndb;
158 alter table mydb0.t0 add constraint fk0 foreign key (a)
159 references mydb0.t1(a);
160 alter table mydb0.t1 add constraint fk1 foreign key (a)
161 references mydb0.t0(a);
162 drop database mydb0;
163 set @i=2;
164 create database mydb0;
165 use mydb0;
166 create table t0 (a int primary key) engine = innodb;
167 create database mydb1;
168 use mydb1;
169 create table t1 (a int primary key) engine = innodb;
170 alter table mydb0.t0 add constraint fk0 foreign key (a)
171 references mydb1.t1(a);
172 alter table mydb1.t1 add constraint fk1 foreign key (a)
173 references mydb0.t0(a);
174 drop database mydb0;
175 ERROR HY000: Cannot drop table 't0' referenced by a foreign key constraint 'fk1' on table 't1'.
176 drop database mydb1;
177 ERROR HY000: Cannot drop table 't1' referenced by a foreign key constraint 'fk0' on table 't0'.
178 alter table mydb0.t0 drop foreign key fk0;
179 drop database mydb0;
180 ERROR HY000: Cannot drop table 't0' referenced by a foreign key constraint 'fk1' on table 't1'.
181 drop database mydb1;
182 drop database mydb0;
183 set @i=1;
184 create database mydb0;
185 use mydb0;
186 create table t0 (a int primary key) engine = ndb;
187 create database mydb1;
188 use mydb1;
189 create table t1 (a int primary key) engine = ndb;
190 alter table mydb0.t0 add constraint fk0 foreign key (a)
191 references mydb1.t1(a);
192 alter table mydb1.t1 add constraint fk1 foreign key (a)
193 references mydb0.t0(a);
194 drop database mydb0;
195 ERROR HY000: Cannot drop table 't0' referenced by a foreign key constraint 'fk1' on table 't1'.
196 drop database mydb1;
197 ERROR HY000: Cannot drop table 't1' referenced by a foreign key constraint 'fk0' on table 't0'.
198 alter table mydb0.t0 drop foreign key fk0;
199 drop database mydb0;
200 ERROR HY000: Cannot drop table 't0' referenced by a foreign key constraint 'fk1' on table 't1'.
201 drop database mydb1;
202 drop database mydb0;