Debian Codegraph @

mysql-test/suite/innodb/r/stored_fk.result

raw
1 # Create statement with FK on base column of stored column
2 create table t1(f1 int primary key);
3 create table t2(f1 int, f2 int as(f1) stored,
4 foreign key(f1) references t1(f1) on delete cascade)engine=innodb;
5 ERROR HY000: Cannot add foreign key constraint
6 # adding new stored column during alter table copy operation.
7 create table t2(f1 int not null, f2 int as (f1) virtual,
8 foreign key(f1) references t1(f1) on update cascade)engine=innodb;
9 alter table t2 add column f3 int as (f1) stored, add column f4 int as (f1) virtual;
10 ERROR HY000: Cannot add foreign key constraint
11 drop table t2, t1;
12 # adding foreign key constraint for base columns during alter copy.
13 create table t1(f1 int primary key);
14 create table t2(f1 int not null, f2 int as (f1) stored);
15 alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=copy;
16 ERROR HY000: Cannot add foreign key constraint
17 drop table t2, t1;
18 # adding foreign key constraint for base columns during online alter.
19 create table t1(f1 int primary key);
20 create table t2(f1 int not null, f2 int as (f1) stored);
21 set foreign_key_checks = 0;
22 alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=inplace;
23 ERROR HY000: Cannot add foreign key on the base column of stored column.
24 drop table t2, t1;
25 # adding stored column via online alter.
26 create table t1(f1 int primary key);
27 create table t2(f1 int not null,
28 foreign key(f1) references t1(f1) on update cascade)engine=innodb;
29 alter table t2 add column f2 int as (f1) stored, algorithm=inplace;
30 ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
31 drop table t2, t1;
32 set foreign_key_checks = 1;
33 #
34 # BUG#26731689 FK ON TABLE WITH GENERATED COLS: ASSERTION POS < N_DEF
35 #
36 SET @foreign_key_checks_saved = @@foreign_key_checks;
37 SET foreign_key_checks=0;
38 DROP TABLE IF EXISTS s,t;
39 CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED, c INT,
40 d INT GENERATED ALWAYS AS (0) VIRTUAL, e INT) ENGINE=innodb;
41 CREATE TABLE t (a INT) ENGINE=innodb;
42 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
43 ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'c' in the referenced table 't'
44 ALTER TABLE t ADD PRIMARY KEY(a);
45 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
46 DROP TABLE s,t;
47 CREATE TABLE s (a INT GENERATED ALWAYS AS (0) VIRTUAL,
48 b INT GENERATED ALWAYS AS (0) STORED, c INT) ENGINE=innodb;
49 CREATE TABLE t (a INT) ENGINE=innodb;
50 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
51 ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'c' in the referenced table 't'
52 ALTER TABLE t ADD PRIMARY KEY(a);
53 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
54 DROP TABLE s,t;
55 CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED) ENGINE=innodb;
56 CREATE TABLE t (a INT PRIMARY KEY) ENGINE=innodb;
57 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
58 DROP TABLE s,t;
59 CREATE TABLE s (a INT, b INT) ENGINE=innodb;
60 CREATE TABLE t (a INT) ENGINE=innodb;
61 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
62 ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'c' in the referenced table 't'
63 ALTER TABLE t ADD PRIMARY KEY(a);
64 ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
65 DROP TABLE s,t;
66 SET @@foreign_key_checks = @foreign_key_checks_saved;