pingcap / pingcap/tidb

The stored data contains spaces in front of it and when used as a query condition, an error message "index out of range" is displayed.

Open
#55,676 2 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

When migrating from Oracle to TiDB, when the stored data contains spaces in front of it, join queries and distinct queries are prone to index out of range errors. For example, in SQL: select x,x,x,xx,x,x from a,b where a.pno=b.kno; if the data stored in a.pno contains spaces in front of it, such as "0188" (the same applies to b.kno). In this case, this SQL will most likely report an index out of range error.

### 1. Minimal reproduce step (Required)

1、create table a(pno varchar(30),b varchar(30));
2、create table b(kno varchar(30),b varchar(30));
insert into a values(' 0100','accaaa')(' 0001','bbbbd');
insert into b values(' 0100','accaaa')(' 0001','bbbbd');
3、select x,x,x,xx,x,x from a,b where a.pno=b.kno;
### 2. What did you expect to see? (Required)
Normal query, giving correct query results
### 3. What did you see instead (Required)
Error index out of range
### 4. What is your TiDB version? (Required)
v8.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.