【 TiDB 版本】 TiDB V6.5.9,V7.5.1均存在此问题,
【 Bug 的影响】 DML语句无法执行
【可能的问题复现步骤】
SQL:
CREATE TABLE test1 (
col1 bigint(20) NOT NULL ,
col2 varchar(36) NOT NULL ,
col3 int(11) DEFAULT NULL ,
col4 varchar(36) NOT NULL ,
col5 varchar(255) DEFAULT NULL ,
modify_time bigint(20) DEFAULT NULL,
create_time bigint(20) DEFAULT NULL,
col6 json DEFAULT NULL ,
col7 json DEFAULT NULL ,
col8 json GENERATED ALWAYS AS (json_merge_patch(ifnull(col6, _utf8mb4’{}‘), ifnull(col7, _utf8mb4’{}'))) STORED,
col9 varchar(36) GENERATED ALWAYS AS (left(json_unquote(json_extract(col8, _utf8mb4’$.col9[0]')), 36)) VIRTUAL,
col10 varchar(30) GENERATED ALWAYS AS (left(json_unquote(json_extract(col8, _utf8mb4’$.col10’)), 30)) VIRTUAL,
KEY dev_idx1 (col4,col1,col10,col3,col5),
KEY dev_idx2 (col3,col1,col9)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO test1 VALUES (-100000000, ‘123459789332’, 1, ‘123459789332’, ‘AAAAA’, 1675871871, 1675760995, ‘{“col10”: “CCCCC”, “col9”: [“ABCDEFG”]}’, ‘{“col10”: “DDDDD”, “col9”: [“abcdefg”]}’, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (-100000000, ‘123459789332’, 1, ‘123459789332’, ‘BBBBB’, 1675908861, 1675908861, ‘{“col10”: “CCCCC”, “col9”: [“ABCDEFG”]}’, NULL, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (0, ‘123459789332’, 1, ‘123459789332’, ‘AAAAA’, 1675956409, 1675908882, ‘{“col10”: “CCCCC”, “col9”: [“ABCDEFG”]}’, ‘{“col10”: “DDDDD”,“col9”: [“abcdefg”]}’, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (-100000000, ‘123459789332’, 1, ‘123459789332’, ‘BBBBB’, 1675871896, 1675871896, ‘{“col10”: “CCCCC”,“col9”: [“ABCDEFG”]}’, NULL, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (-100000000, ‘123459789332’, 1, ‘123459789332’, ‘AAAAA’, 1675908836, 1675871916, ‘{“col10”: “CCCCC”,“col9”: [“ABCDEFG”]}’, ‘{“col10”: “DDDDD”,“col9”: [“abcdefg”]}’, DEFAULT, DEFAULT, DEFAULT);
UPDATE test1 SET col7 = ‘{“col10”:“DDDDD”,“col9”:[“abcdefg”]}’ WHERE col2 = ‘123459789332’;
UPDATE test1 SET col1 = -100000000 WHERE col4 = ‘123459789332’;
DELETE FROM test1 WHERE col1 < 0;
【看到的非预期行为】 DELETE 报错
【期望看到的行为】DELETE 可以正常执行
【其他背景信息或者截图】
PS:在V5.4.0版本中上述SQL可以执行,但会导致数据与索引不一致的BUG。