MDEV-29182 Assertion fld->field_no < table->n_v_def failed on cascade

row_ins_cascade_calc_update_vec(): Skip any virtual columns in the
update vector of the parent table.

Based on mysql/mysql-server@0ac176453b

Reviewed by: Debarun Banerjee
This commit is contained in:
Marko Mäkelä 2025-01-22 17:22:07 +02:00
parent b730abda09
commit 82310f926b
3 changed files with 35 additions and 1 deletions

View file

@ -1022,4 +1022,21 @@ t2 CREATE TABLE `t2` (
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop tables t2, t1;
#
# MDEV-29182 Assertion fld->field_no < table->n_v_def failed on cascade
#
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(3), c INT AS (LENGTH(b)) VIRTUAL,
INDEX(c)) ENGINE=InnoDB;
CREATE TABLE t2(a INT REFERENCES t1(a) ON UPDATE CASCADE,
b INT GENERATED ALWAYS AS(a) VIRTUAL, INDEX(b)) ENGINE=InnoDB;
INSERT INTO t1 SET a=1,b='fu';
INSERT INTO t2 SET a=1;
UPDATE t1 SET a=2,b='bar';
SELECT * FROM t1;
a b c
2 bar 3
SELECT * FROM t2;
a b
2 2
DROP TABLE t2,t1;
# End of 10.5 tests

View file

@ -1063,6 +1063,21 @@ alter table t2 add foreign key(a) references t1;
show create table t2;
drop tables t2, t1;
--echo #
--echo # MDEV-29182 Assertion fld->field_no < table->n_v_def failed on cascade
--echo #
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(3), c INT AS (LENGTH(b)) VIRTUAL,
INDEX(c)) ENGINE=InnoDB;
CREATE TABLE t2(a INT REFERENCES t1(a) ON UPDATE CASCADE,
b INT GENERATED ALWAYS AS(a) VIRTUAL, INDEX(b)) ENGINE=InnoDB;
INSERT INTO t1 SET a=1,b='fu';
INSERT INTO t2 SET a=1;
UPDATE t1 SET a=2,b='bar';
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t2,t1;
--echo # End of 10.5 tests
--source include/wait_until_count_sessions.inc

View file

@ -479,7 +479,9 @@ row_ins_cascade_calc_update_vec(
const upd_field_t* parent_ufield
= &parent_update->fields[j];
if (parent_ufield->field_no == parent_field_no) {
if (parent_ufield->field_no == parent_field_no
&& !(parent_ufield->new_val.type.prtype
& DATA_VIRTUAL)) {
ulint min_size;
const dict_col_t* col;