diff --git a/mysql-test/suite/versioning/r/foreign.result b/mysql-test/suite/versioning/r/foreign.result index 3903bee2f00..dc0f556ad86 100644 --- a/mysql-test/suite/versioning/r/foreign.result +++ b/mysql-test/suite/versioning/r/foreign.result @@ -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; diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test index ec23abac460..0a4eadd89bb 100644 --- a/mysql-test/suite/versioning/t/foreign.test +++ b/mysql-test/suite/versioning/t/foreign.test @@ -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; diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 8e7e70bd793..a3e8e8a5a3c 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -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) {