Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error: index out of range [0] with length 0 #42150

Closed
ChenPeng2013 opened this issue Mar 13, 2023 · 1 comment · Fixed by #42220
Closed

runtime error: index out of range [0] with length 0 #42150

ChenPeng2013 opened this issue Mar 13, 2023 · 1 comment · Fixed by #42220
Assignees
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 epic/plan-cache severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@ChenPeng2013
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)


use test;
drop table if exists t1, t2;
CREATE TABLE `t1` (
  `c_int` int(11) NOT NULL,
  `c_str` varchar(40) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `c_datetime` datetime DEFAULT NULL,
  `c_timestamp` timestamp NULL DEFAULT NULL,
  `c_double` double DEFAULT NULL,
  `c_decimal` decimal(12,6) DEFAULT NULL,
  `c_enum` enum('blue','green','red','yellow','white','orange','purple') NOT NULL,
  PRIMARY KEY (`c_int`,`c_enum`) /*T![clustered_index] CLUSTERED */,
  KEY `c_decimal` (`c_decimal`),
  UNIQUE KEY `c_datetime` (`c_datetime`),
  UNIQUE KEY `c_timestamp` (`c_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `t2` (
  `c_int` int(11) NOT NULL,
  `c_str` varchar(40) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `c_datetime` datetime DEFAULT NULL,
  `c_timestamp` timestamp NULL DEFAULT NULL,
  `c_double` double DEFAULT NULL,
  `c_decimal` decimal(12,6) DEFAULT NULL,
  `c_enum` enum('blue','green','red','yellow','white','orange','purple') NOT NULL,
  PRIMARY KEY (`c_int`,`c_enum`) /*T![clustered_index] CLUSTERED */,
  KEY `c_decimal` (`c_decimal`),
  UNIQUE KEY `c_datetime` (`c_datetime`),
  UNIQUE KEY `c_timestamp` (`c_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

/* test */ /* t02:008 */ prepare stmt16 from "select * from t1 where c_enum in (select c_enum from t2 where t1.c_str in (?, ?, ?) )  ";
/* test */ /* t02:008 */ set @v0 = "nice hellman";
/* test */ /* t02:008 */ set @v1 = "flamboyant booth";
/* test */ /* t02:008 */ set @v2 = "quirky brahmagupta";
/* test:query */ /* t02:008 */ execute stmt16 using @v0, @v1, @v2;
/* test:query */ /* t02:008 */ execute stmt16 using @v0, @v1, @v2;

2. What did you expect to see? (Required)

MySQL [test]> /* test:query */ /* t02:008 */ execute stmt16 using @v0, @v1, @v2;
Empty set (0.01 sec)

MySQL [test]> /* test:query */ /* t02:008 */ execute stmt16 using @v0, @v1, @v2;
Empty set (0.01 sec)

3. What did you see instead (Required)

MySQL [test]> /* test:query */ /* t02:008 */ execute stmt16 using @v0, @v1, @v2;
Empty set (0.01 sec)

MySQL [test]> /* test:query */ /* t02:008 */ execute stmt16 using @v0, @v1, @v2;
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0

4. What is your TiDB version? (Required)

| Release Version: v6.7.0-alpha-246-g145b7cd
Edition: Community
Git Commit Hash: 145b7cdf72feeecf7f2b0b3e01693c603712dce5
Git Branch: master
UTC Build Time: 2023-03-13 01:04:19
GoVersion: go1.20.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
@ChenPeng2013 ChenPeng2013 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/major epic/plan-cache labels Mar 13, 2023
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Mar 13, 2023
@ChenPeng2013 ChenPeng2013 removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.1 may-affects-6.5 labels Mar 13, 2023
@fzzf678 fzzf678 self-assigned this Mar 13, 2023
@fzzf678
Copy link
Contributor

fzzf678 commented Mar 14, 2023

minimal reproduce step

mysql> prepare stmt from 'select c_enum from t1';
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt;
Empty set (0.00 sec)

mysql> execute stmt;
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0

plan

+-----------------------+----------+---------+-----------+----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+--------+------+
| id                    | estRows  | actRows | task      | access object                          | execution info                                                                                                                                                                                | operator info                  | memory | disk |
+-----------------------+----------+---------+-----------+----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+--------+------+
| IndexReader_9         | 10000.00 | 0       | root      |                                        | time:623.8µs, loops:1, cop_task: {num: 1, max: 462.4µs, proc_keys: 0, rpc_num: 1, rpc_time: 417.8µs, copr_cache_hit_ratio: 0.00, build_task_duration: 25.1µs, max_distsql_concurrency: 1}     | index:IndexFullScan_8          | N/A    | N/A  |
| └─IndexFullScan_8     | 10000.00 | 0       | cop[tikv] | table:t1, index:c_datetime(c_datetime) | tikv_task:{time:379.8µs, loops:0}                                                                                                                                                             | keep order:false, stats:pseudo | N/A    | N/A  |
+-----------------------+----------+---------+-----------+----------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+--------+------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 epic/plan-cache severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants