Commit ed70e034 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-20865 FIXMEs

parent e0145df6
......@@ -241,46 +241,52 @@ test.t3 check status OK
drop tables ch1, t2, t1, t3;
# Rename column on referenced table
create or replace table t1 (id int primary key);
create or replace table t2 (id int references t1);
create or replace table t2 (id int references t1, id2 int references t1(id));
select * from t2;
id
id id2
alter table t1 change id xid int;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL,
`id2` int(11) DEFAULT NULL,
KEY `fk_t2` (`id`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`xid`)
KEY `fk_t2_2` (`id2`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`xid`),
CONSTRAINT `fk_t2_2` FOREIGN KEY (`id2`) REFERENCES `t1` (`xid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
select * from t1;
xid
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 2 foreign keys
test.t2 check status OK
flush table t2;
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 2 foreign keys
test.t2 check status OK
alter table t1 rename column xid to yid;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL,
`id2` int(11) DEFAULT NULL,
KEY `fk_t2` (`id`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`yid`)
KEY `fk_t2_2` (`id2`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`yid`),
CONSTRAINT `fk_t2_2` FOREIGN KEY (`id2`) REFERENCES `t1` (`yid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
select * from t1;
yid
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 2 foreign keys
test.t2 check status OK
flush table t2;
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 2 foreign keys
test.t2 check status OK
drop tables t2, t1;
# Check rename table
......
......@@ -242,7 +242,7 @@ drop tables ch1, t2, t1, t3;
--echo # Rename column on referenced table
create or replace table t1 (id int primary key);
create or replace table t2 (id int references t1);
create or replace table t2 (id int references t1, id2 int references t1(id));
select * from t2;
alter table t1 change id xid int;
show create table t2;
......
......@@ -416,7 +416,7 @@ class Alter_table_ctx
Table_name ref;
const FK_info *fk;
};
// FIXME: why this stored in std::set?
// NB: multiple foreign keys can utilize same column (see fk_prepare_rename())
mbd::set<FK_rename_col> fk_renamed_cols;
mbd::set<FK_rename_col> rk_renamed_cols;
mbd::vector<FK_add_new> fk_added;
......
......@@ -1546,11 +1546,7 @@ bool TABLE_SHARE::fk_resolve_referenced_keys(THD *thd, TABLE_SHARE *from)
if (!ids.insert(rk.foreign_id, &inserted))
return true;
if (!inserted) // FIXME: assert instead error
{
my_error(ER_DUP_CONSTRAINT_NAME, MYF(0), "FOREIGN KEY", rk.foreign_id.str);
return true;
}
DBUG_ASSERT(inserted);
}
for (FK_info &fk: from->foreign_keys)
......@@ -1564,8 +1560,9 @@ bool TABLE_SHARE::fk_resolve_referenced_keys(THD *thd, TABLE_SHARE *from)
if (!inserted)
{
my_error(ER_DUP_CONSTRAINT_NAME, MYF(0), "FOREIGN KEY", fk.foreign_id.str);
return true; // FIXME: warn instead fail
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_DUP_CONSTRAINT_NAME,
"Foreign ID already exists `%s`", fk.foreign_id.str);
continue;
}
for (Lex_cstring &fld: fk.referenced_fields)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment