mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Merge 10.2 into 10.3
This commit is contained in:
@ -161,3 +161,62 @@ c d
|
||||
6 30
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
#
|
||||
# MDEV-17187 table doesn't exist in engine after ALTER other tables
|
||||
# with CONSTRAINTs
|
||||
#
|
||||
set foreign_key_checks=on;
|
||||
create table t1 (id int not null primary key) engine=innodb;
|
||||
create table t2 (id int not null primary key, fid int not null,
|
||||
CONSTRAINT fk_fid FOREIGN KEY (fid) REFERENCES t1 (id))engine=innodb;
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 1), (2, 1), (3, 2);
|
||||
set foreign_key_checks=off;
|
||||
alter table t2 drop index fk_fid;
|
||||
set foreign_key_checks=on;
|
||||
delete from t1 where id=2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`))
|
||||
insert into t2 values(4, 99);
|
||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`))
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
id fid
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
set foreign_key_checks=off;
|
||||
delete from t1 where id=2;
|
||||
insert into t2 values(4, 99);
|
||||
set foreign_key_checks=on;
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
3
|
||||
select * from t2;
|
||||
id fid
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 99
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`id` int(11) NOT NULL,
|
||||
`fid` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1,t2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
||||
drop table t1,t2;
|
||||
ERROR 42S02: Unknown table 'test.t2'
|
||||
|
Reference in New Issue
Block a user