Skip to content

Commit 671a37f

Browse files
committed
Adjust the test case for MariaDB
Note: it does not appear to cover the bug fix! The test will pass even if the Oracle Bug #26731689 fix is reverted.
1 parent 3d10966 commit 671a37f

File tree

2 files changed

+40
-43
lines changed

2 files changed

+40
-43
lines changed

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
11
# Create statement with FK on base column of stored column
22
create table t1(f1 int, f2 int as(f1) stored,
33
foreign key(f1) references t2(f1) on delete cascade)engine=innodb;
4-
ERROR HY000: Cannot add foreign key constraint
4+
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
55
# adding new stored column during alter table copy operation.
6-
create table t1(f1 int primary key);
6+
create table t1(f1 int primary key) engine=innodb;
77
create table t2(f1 int not null, f2 int as (f1) virtual,
88
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
99
alter table t2 add column f3 int as (f1) stored, add column f4 int as (f1) virtual;
10-
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 150 - Foreign key constraint is incorrectly formed)
11-
drop table t2, t1;
10+
show create table t2;
11+
Table Create Table
12+
t2 CREATE TABLE `t2` (
13+
`f1` int(11) NOT NULL,
14+
`f2` int(11) GENERATED ALWAYS AS (`f1`) VIRTUAL,
15+
`f3` int(11) GENERATED ALWAYS AS (`f1`) STORED,
16+
`f4` int(11) GENERATED ALWAYS AS (`f1`) VIRTUAL,
17+
KEY `f1` (`f1`),
18+
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
19+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
20+
drop table t2;
1221
# 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);
22+
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
1523
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;
24+
show create table t2;
25+
Table Create Table
26+
t2 CREATE TABLE `t2` (
27+
`f1` int(11) NOT NULL,
28+
`f2` int(11) GENERATED ALWAYS AS (`f1`) STORED,
29+
KEY `f1` (`f1`),
30+
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
31+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
32+
drop table t2;
1833
# 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);
34+
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
2135
set foreign_key_checks = 0;
2236
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;
37+
ERROR 0A000: Cannot add foreign key on the base column of stored column
38+
drop table t2;
2539
# adding stored column via online alter.
26-
create table t1(f1 int primary key);
2740
create table t2(f1 int not null,
2841
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
2942
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.
43+
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
3144
drop table t2, t1;
32-
set foreign_key_checks = 1;
3345
#
3446
# BUG#26731689 FK ON TABLE WITH GENERATED COLS: ASSERTION POS < N_DEF
3547
#
36-
SET @foreign_key_checks_saved = @@foreign_key_checks;
37-
SET foreign_key_checks=0;
38-
DROP TABLE IF EXISTS s,t;
3948
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED, c INT,
4049
d INT GENERATED ALWAYS AS (0) VIRTUAL, e INT) ENGINE=innodb;
4150
CREATE TABLE t (a INT) ENGINE=innodb;
@@ -63,4 +72,3 @@ ERROR HY000: Failed to add the foreign key constaint. Missing index for constrai
6372
ALTER TABLE t ADD PRIMARY KEY(a);
6473
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
6574
DROP TABLE s,t;
66-
SET @@foreign_key_checks = @foreign_key_checks_saved;

mysql-test/suite/innodb/t/stored_fk.test

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,46 @@
11
--source include/have_innodb.inc
22

33
--echo # Create statement with FK on base column of stored column
4-
--error ER_CANNOT_ADD_FOREIGN
4+
--error ER_CANT_CREATE_TABLE
55
create table t1(f1 int, f2 int as(f1) stored,
66
foreign key(f1) references t2(f1) on delete cascade)engine=innodb;
77

88
--echo # adding new stored column during alter table copy operation.
9-
create table t1(f1 int primary key);
9+
create table t1(f1 int primary key) engine=innodb;
1010
create table t2(f1 int not null, f2 int as (f1) virtual,
1111
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
1212

13-
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
14-
--error ER_ERROR_ON_RENAME
13+
# MySQL 5.7 would refuse this
14+
#--error ER_ERROR_ON_RENAME
1515
alter table t2 add column f3 int as (f1) stored, add column f4 int as (f1) virtual;
16-
drop table t2, t1;
16+
show create table t2;
17+
drop table t2;
1718

1819
--echo # adding foreign key constraint for base columns during alter copy.
19-
create table t1(f1 int primary key);
20-
create table t2(f1 int not null, f2 int as (f1) stored);
21-
--error ER_CANNOT_ADD_FOREIGN
20+
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
21+
# MySQL 5.7 would refuse this
2222
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=copy;
23-
drop table t2, t1;
23+
show create table t2;
24+
drop table t2;
2425

2526
--echo # adding foreign key constraint for base columns during online alter.
26-
create table t1(f1 int primary key);
27-
create table t2(f1 int not null, f2 int as (f1) stored);
27+
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
2828
set foreign_key_checks = 0;
29-
--error ER_CANNOT_ADD_FOREIGN_BASE_COL_STORED
29+
--error 138
3030
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=inplace;
31-
drop table t2, t1;
31+
drop table t2;
3232

3333
--echo # adding stored column via online alter.
34-
create table t1(f1 int primary key);
3534
create table t2(f1 int not null,
3635
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
3736
--error ER_ALTER_OPERATION_NOT_SUPPORTED
3837
alter table t2 add column f2 int as (f1) stored, algorithm=inplace;
3938
drop table t2, t1;
40-
set foreign_key_checks = 1;
4139

4240
--echo #
4341
--echo # BUG#26731689 FK ON TABLE WITH GENERATED COLS: ASSERTION POS < N_DEF
4442
--echo #
4543

46-
SET @foreign_key_checks_saved = @@foreign_key_checks;
47-
SET foreign_key_checks=0;
48-
49-
--disable_warnings
50-
DROP TABLE IF EXISTS s,t;
51-
--enable_warnings
52-
5344
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED, c INT,
5445
d INT GENERATED ALWAYS AS (0) VIRTUAL, e INT) ENGINE=innodb;
5546

@@ -101,5 +92,3 @@ ALTER TABLE t ADD PRIMARY KEY(a);
10192
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
10293

10394
DROP TABLE s,t;
104-
105-
SET @@foreign_key_checks = @foreign_key_checks_saved;

0 commit comments

Comments
 (0)