Skip to content

Runtime error index out of range for Key partitioned table when partitioning column is not the first column. #50206

@mjonss

Description

@mjonss

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t (b varchar(255), a int primary key nonclustered, key (b)) partition by key(a) partitions 3;
insert into t values ('Ab', 1),('abc',2),('BC',3),('AC',4),('BA',5),('cda',6);
analyze table t;
select * from t where a = 2;

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

Success

3. What did you see instead (Required)

tidb> create table t (b varchar(255), a int primary key nonclustered, key (b)) partition by key(a) partitions 3;
Query OK, 0 rows affected (0.13 sec)

tidb> insert into t values ('Ab', 1),('abc',2),('BC',3),('AC',4),('BA',5),('cda',6);
Query OK, 6 rows affected (0.02 sec)
Records: 6  Duplicates: 0  Warnings: 0

tidb> analyze table t;
Query OK, 0 rows affected, 6 warnings (0.29 sec)

tidb> select * from t where a = 2;
ERROR 1105 (HY000): runtime error: index out of range [1] with length 1

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v7.5.0
Edition: Community
Git Commit Hash: 069631e2ecfedc000ffb92c67207bea81380f020
Git Branch: heads/refs/tags/v7.5.0
UTC Build Time: 2023-11-24 08:50:14
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions