Skip to content

Commit

Permalink
IB: assertion failure on delete with foreign [#366]
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgs committed Dec 2, 2017
1 parent 5c820a7 commit a3802ec
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
16 changes: 16 additions & 0 deletions mysql-test/suite/versioning/r/foreign.result
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,19 @@ update parent set id=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
drop table child;
drop table parent;
create or replace table a (
cola int(10) primary key,
v_cola int(10) as (cola mod 10) virtual
) engine=innodb with system versioning;
create index v_cola on a (v_cola);
create or replace table b(
cola int(10),
v_cola int(10)
) engine=innodb with system versioning;
alter table b add constraint `v_cola_fk`
foreign key (v_cola) references a (v_cola);
insert into a(cola) values (12);
insert into b(cola, v_cola) values (10,2);
delete from a;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`b`, CONSTRAINT `v_cola_fk` FOREIGN KEY (`v_cola`) REFERENCES `a` (`v_cola`))
drop table b, a;
26 changes: 26 additions & 0 deletions mysql-test/suite/versioning/t/foreign.test
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,29 @@ update parent set id=2;

drop table child;
drop table parent;


###################
# crash on DELETE #
###################
create or replace table a (
cola int(10) primary key,
v_cola int(10) as (cola mod 10) virtual
) engine=innodb with system versioning;

create index v_cola on a (v_cola);

create or replace table b(
cola int(10),
v_cola int(10)
) engine=innodb with system versioning;

alter table b add constraint `v_cola_fk`
foreign key (v_cola) references a (v_cola);

insert into a(cola) values (12);
insert into b(cola, v_cola) values (10,2);
--error ER_ROW_IS_REFERENCED_2
delete from a;

drop table b, a;
6 changes: 2 additions & 4 deletions storage/innobase/row/row0upd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2227,10 +2227,8 @@ row_upd_store_row(
NULL, NULL, NULL, ext, node->heap);

if (node->table->n_v_cols) {
row_upd_store_v_row(
node,
node->is_delete == PLAIN_DELETE ? NULL : node->update,
thd, mysql_table);
row_upd_store_v_row(node, node->is_delete ? NULL : node->update,
thd, mysql_table);
}

if (node->is_delete == PLAIN_DELETE) {
Expand Down

0 comments on commit a3802ec

Please sign in to comment.