pingcap / pingcap/tidb

index out of bound only triggered when query run twice

Open
#65,839 2 comments 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
contribution may-affects-7.1 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

Hi,

In the following test case, there are two identical queries. The first query runs correctly, but the second query triggers an index out of bound error.

```
CREATE TABLE t0(c1 FLOAT);
CREATE INDEX i0 ON t0(c1 ASC);
set @@tidb_enable_chunk_rpc=0;
REPLACE INTO t0 VALUES (0.5223332881233415), (-0.0);
REPLACE INTO t0 VALUES (NULL);
ALTER TABLE t0 MODIFY c1 DECIMAL;
set @@tidb_max_chunk_size=38147;
SELECT t0.c1 FROM t0 NATURAL RIGHT JOIN t0 AS t0_0 WHERE ((t0.c1) IS NULL) ORDER BY t0.c1; -- NULL
SELECT t0.c1 FROM t0 NATURAL RIGHT JOIN t0 AS t0_0 WHERE ((t0.c1) IS NULL) ORDER BY t0.c1; -- runtime error: index out of range [40] with length 16
```

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

The second query does not trigger error.

### 3. What did you see instead (Required)

The second query triggers an error `runtime error: index out of range [40] with length 16`

### 4. What is your TiDB version? (Required)

Release Version: v9.0.0-beta.2.pre-1118-gfc6f7b2e42\nEdition: Community\nGit Commit Hash: fc6f7b2e42be08957a9b80e5761bfa4793066353\nGit Branch: master\nUTC Build Time: 2026-01-26 12:27:51\nGoVersion: go1.25.6\nRace Enabled: false\nCheck Table Before Drop: false\nStore: unistore\nKernel Type: Classic

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.