Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
10.11, 11.4, 11.8, 12.3
-
Can result in data loss
-
Description
The following test case, adapted from Bug#39147834 statement rollback on indexed virtual columns will crash when FK ON UPDATE SET NULL hits duplicate key on parent update, will crash a CMAKE_BUILD_TYPE=Debug of MariaDB Server. It should also corrupt an index on indexed virtual columns:
|
mysql-test/suite/innodb/t/fk_cascade_virtual_index_rollback.test |
--source include/have_innodb.inc
|
|
|
# Bug#39147834 statement rollback on indexed virtual columns crashes when |
# FK ON UPDATE SET NULL updates the parent key. |
|
|
CREATE TABLE t18 ( |
c5 INT NOT NULL, |
PRIMARY KEY (c5) |
) ENGINE=InnoDB;
|
|
|
CREATE TABLE t21 ( |
c1 INT NOT NULL, |
c2 INT DEFAULT NULL, |
c2v INT AS (c2 DIV 1), c1v INT AS (FLOOR(c1)), |
KEY i15 (c2v, c1v), |
CONSTRAINT t21_ibfk_1 FOREIGN KEY (c2) REFERENCES t18 (c5) ON UPDATE SET NULL |
) ENGINE=InnoDB;
|
|
|
INSERT INTO t18 (c5) VALUES (1), (2); |
INSERT INTO t21 (c1, c2) VALUES (0, 1); |
|
|
# This first changes 1 to 3 and cascades c2 = 1 to c2 = NULL. Updating the |
# second parent row (2 to 3) then hits the duplicate primary key. The whole |
# statement must roll back, including the functional-index update in t21. |
--error ER_DUP_ENTRY
|
UPDATE t18 SET c5 = 3; |
|
|
SELECT c5 FROM t18 ORDER BY c5; |
SELECT c1, c2 FROM t21; |
|
|
DROP TABLE t21, t18; |
|
|
# Bug#39872048: DELETE with ON DELETE SET NULL must preserve all functional |
# index key parts when its effects are rolled back. |
CREATE TABLE parent ( |
id INT PRIMARY KEY |
) ENGINE=InnoDB;
|
|
|
CREATE TABLE child ( |
a INT DEFAULT NULL, |
parent_id INT DEFAULT NULL, |
KEY idx_functional ((IFNULL(a, 0)), (IFNULL(parent_id, 0))), |
CONSTRAINT fk_parent FOREIGN KEY (parent_id) REFERENCES parent (id) |
ON DELETE SET NULL |
) ENGINE=InnoDB;
|
|
|
INSERT INTO parent VALUES (1); |
INSERT INTO child VALUES (NULL, 1); |
|
|
START TRANSACTION; |
DELETE FROM parent WHERE id = 1; |
ROLLBACK; |
|
|
SELECT id FROM parent; |
SELECT a, parent_id FROM child; |
|
|
DROP TABLE child, parent; |
|
10.11 120162359b059b5abf0eb310c5ad590731dd17eb |
2026-10-21 12:26:23 4 [ERROR] InnoDB: Record in index `i15` of table `test`.`t21` was not found on update: TUPLE (info_bits=0, 3 fields): {[4] (0x80000001),NULL,[6] (0x000000000200)} at: COMPACT RECORD(info_bits=0, 1 fields): {[8]infimum (0x696E66696D756D00)}
|
mariadbd: /mariadb/10.6/storage/innobase/row/row0upd.cc:1926: dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*): Assertion `0' failed.
|
Attachments
Issue Links
- blocks
-
MDEV-41670 Merge applicable InnoDB changes from MySQL 8.4.13
-
- Open
-