File: stored_fk.result

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (75 lines) | stat: -rw-r--r-- 4,224 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
create table t1(f1 int primary key) engine=innodb;
# Create statement with FK on base column of stored column
create table t2(f1 int not null, f2 int as (f1) stored,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
ERROR HY000: Function or expression 'f1' cannot be used in the GENERATED ALWAYS AS clause of `f2`
create table t2(f1 int not null, f2 int as (f1) virtual, f3 int as (f2) stored,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
ERROR HY000: Function or expression 'f2' cannot be used in the GENERATED ALWAYS AS clause of `f3`
# adding new stored column during alter table copy operation.
create table t2(f1 int not null, f2 int as (f1) virtual,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
alter table t2 add column f3 int as (f1) stored, add column f4 int as (f1) virtual;
ERROR HY000: Function or expression 'f1' cannot be used in the GENERATED ALWAYS AS clause of `f3`
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `f1` int(11) NOT NULL,
  `f2` int(11) GENERATED ALWAYS AS (`f1`) VIRTUAL,
  KEY `f1` (`f1`),
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table t2;
# adding foreign key constraint for base columns during alter copy.
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=copy;
ERROR HY000: Function or expression 'f1' cannot be used in the GENERATED ALWAYS AS clause of `f2`
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `f1` int(11) NOT NULL,
  `f2` int(11) GENERATED ALWAYS AS (`f1`) STORED
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table t2;
# adding foreign key constraint for base columns during online alter.
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
set foreign_key_checks = 0;
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=inplace;
ERROR HY000: Function or expression 'f1' cannot be used in the GENERATED ALWAYS AS clause of `f2`
drop table t2;
# adding stored column via online alter.
create table t2(f1 int not null,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
alter table t2 add column f2 int as (f1) stored, algorithm=inplace;
ERROR HY000: Function or expression 'f1' cannot be used in the GENERATED ALWAYS AS clause of `f2`
drop table t2, t1;
#
# BUG#26731689 FK ON TABLE WITH GENERATED COLS: ASSERTION POS < N_DEF
#
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED,  c INT,
d INT GENERATED ALWAYS AS (0) VIRTUAL, e INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'c' in the referenced table 't'
ALTER  TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT GENERATED ALWAYS AS (0) VIRTUAL,
b INT GENERATED ALWAYS AS (0) STORED,  c INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'c' in the referenced table 't'
ALTER  TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT,  b INT GENERATED ALWAYS AS (0) STORED) ENGINE=innodb;
CREATE TABLE t (a INT PRIMARY KEY) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT, b INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'c' in the referenced table 't'
ALTER  TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;