index out of range [0] with length 0 when using prepare plan cache #19192
Closed
Description
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
new_collations_enabled_on_first_bootstrap = true
prepared-plan-cache.enabled = true
CREATE TABLE `t` (
`c_int` int(11) DEFAULT NULL,
`c_int2` int(11) GENERATED ALWAYS AS (`c_int` * 2) STORED,
`c_str` varchar(40) DEFAULT NULL,
`c_str2` varchar(40) DEFAULT NULL,
`c_datetime` datetime DEFAULT NULL,
`c_datetime2` datetime DEFAULT NULL,
`c_timestamp` timestamp NULL DEFAULT NULL,
`c_timestamp2` timestamp NULL DEFAULT NULL,
`c_double` double DEFAULT NULL,
`c_double2` double DEFAULT NULL,
`c_decimal` decimal(12,6) DEFAULT NULL,
KEY `c_int` (`c_int`),
KEY `c_int2` (`c_int2`),
KEY `c_str` (`c_str`),
KEY `c_int_2` (`c_int`,`c_str`),
KEY `c_decimal` (`c_decimal`),
KEY `c_datetime` (`c_datetime`),
UNIQUE KEY `c_datetime2` (`c_datetime2`,`c_datetime`),
KEY `c_timestamp2` (`c_timestamp2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
INSERT INTO `t` (`c_int`, `c_str`, `c_str2`, `c_datetime`, `c_datetime2`, `c_timestamp`, `c_timestamp2`, `c_double`, `c_double2`, `c_decimal`) VALUES (1,'quizzical goldberg','awesome nightingale','2020-05-20 14:06:50','2020-05-21 10:26:58','2020-03-07 13:34:24','2020-01-06 06:32:22',8.120238,93.081973,4.188000),(2,'vibrant moore','mystifying banach','2020-05-05 21:19:18','2020-05-18 19:34:10','2020-02-03 16:00:02','2020-03-24 03:24:59',45.353692,72.942041,8.493000),(5,'vibrant moore','gracious wescoff','2020-03-13 19:59:31','2020-01-13 02:48:57','2020-03-02 16:22:44','2020-04-14 08:43:53',8.698416,88.150439,4.766000),(6,'wizardly wescoff','confident newton','2020-02-06 02:33:38','2020-06-30 01:36:27','2020-06-22 21:57:44','2020-05-19 13:34:38',38.000458,34.614586,7.708000),(7,'hopeful payne','loving antonelli','2020-06-03 18:39:10','2020-01-31 01:28:59','2020-03-17 15:11:55','2020-01-27 16:15:44',76.601025,15.157077,2.327000),(8,'frosty northcutt','crazy engelbart','2020-05-01 18:34:39','2020-02-08 13:09:30','2020-04-17 23:35:29','2020-01-11 13:35:34',61.350777,96.035396,8.166000),(9,'vibrant moore','nostalgic ramanujan','2020-05-29 15:19:55','2020-01-14 07:18:53','2020-04-09 00:17:01','2020-01-19 06:17:37',40.455101,45.393835,7.050000),(10,'funny blackwell','fervent black','2020-06-09 05:57:02','2020-01-30 12:16:00','2020-02-19 20:20:20','2020-03-05 18:40:09',72.813538,96.54546,2.089000),(11,'objective antonelli','inspiring lewin','2020-04-29 08:40:33','2020-01-05 10:44:12','2020-06-06 03:09:58','2020-01-01 05:29:53',34.2709,36.396483,4.910000),(12,'romantic wilbur','intelligent allen','2020-03-17 07:21:10','2020-03-29 08:41:31','2020-03-09 14:41:51','2020-04-20 09:17:40',89.270577,39.561856,5.409000),(13,'stoic galois','flamboyant ritchie','2020-06-13 22:09:30','2020-06-08 19:20:04','2020-06-03 10:14:49','2020-01-09 03:07:06',31.450598,30.61192,1.217000),(15,'reverent yalow','boring ishizaka','2020-01-21 02:05:25','2020-05-07 00:34:24','2020-04-20 21:25:50','2020-05-11 14:47:16',86.941937,37.081463,8.641000);
begin;
update t set c_str = 'goofy ganguly' where c_int = 6 and c_str = 'elated goldberg';
update t set c_str = 'practical blackwell' where c_int = 14 and c_int2 in (27, 3, 16);
update t set c_str = 'romantic turing' where c_int in (16, 9, 21);
update t set c_int = c_int + 10, c_str = 'angry pascal' where c_int in (29, 34);
prepare stmt from "select c_int, c_int2, c_str, c_str2, c_double, c_double2, c_decimal, c_datetime, c_datetime2, c_timestamp, c_timestamp2 from t where c_str = ?";
set @a= 'exciting tesla';
execute stmt using @a;
set@a= 'pensive goldstine';
execute stmt using @a;
insert into t (c_int, c_int2, c_str, c_str2, c_datetime, c_datetime2, c_double, c_double2) values (24, 5, 'focused kepler', 'infallible kowalevski', '2020-01-06 05:29:39', '2020-01-02 12:11:57', 26.587924, 29.212838);
commit;
2. What did you expect to see? (Required)
mysql> insert into t (c_int, c_int2, c_str, c_str2, c_datetime, c_datetime2, c_double, c_double2) values (24, 5, 'focused kepler', 'infallible kowalevski', '2020-01-06 05:29:39', '2020-01-02 12:11:57', 26.587924, 29.212838);
ERROR 3105 (HY000): The value specified for generated column 'c_int2' in table 't' is not allowed.
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
3. What did you see instead (Required)
mysql> insert into t (c_int, c_int2, c_str, c_str2, c_datetime, c_datetime2, c_double, c_double2) values (24, 5, 'focused kepler', 'infallible kowalevski', '2020-01-06 05:29:39', '2020-01-02 12:11:57', 26.587924, 29.212838);
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
mysql> commit;
ERROR 2013 (HY000): Lost connection to MySQL server during query
4. What is your TiDB version? (Required)
Release Version: v4.0.3-62-g3948c7ba7
Edition: Community
Git Commit Hash: 3948c7ba7b5d4a081abf2162b791ab67fe650882
Git Branch: release-4.0
UTC Build Time: 2020-08-12 08:00:18
GoVersion: go1.14.6
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
SIG slack channel
Score
- 300