pingcap / pingcap/tidb

Tuple-IN batch point-get prepared statement panics on the second EXECUTE

Open
#70,844 5 comments 0 reactions 0 assignees View on GitHub
affects-25.10 affects-26.3 affects-7.5 affects-8.1 affects-8.5 contribution severity/major sig/execution 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)
```
CREATE TABLE t (k1 int, k2 int, v int, UNIQUE KEY uk(k1, k2));
INSERT INTO t VALUES (1,2,100), (3,2,200), (1,4,300);
PREPARE st FROM 'select v from t where (k1, k2) in ((1, ?), (?, 2))';
SET @a = 2, @b = 3;
EXECUTE st USING @a, @b; -- (100), (200) — fine
SET @a = 4, @b = 3;
EXECUTE st USING @a, @b; -- ERROR 1105: nil pointer dereference
```
### 2. What did you expect to see? (Required)

### 3. What did you see instead (Required)
```
mysql> CREATE TABLE t (k1 int, k2 int, v int, UNIQUE KEY uk(k1, k2));
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO t VALUES (1,2,100), (3,2,200), (1,4,300);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> PREPARE st FROM 'select v from t where (k1, k2) in ((1, ?), (?, 2))';
Query OK, 0 rows affected (0.00 sec)

mysql> SET @a = 2, @b = 3;
Query OK, 0 rows affected (0.00 sec)

mysql> EXECUTE st USING @a, @b; -- (100), (200) — fine
+------+
| v |
+------+
| 100 |
| 200 |
+------+
2 rows in set (0.00 sec)

mysql> SET @a = 4, @b = 3;
Query OK, 0 rows affected (0.00 sec)

mysql> EXECUTE st USING @a, @b; -- ERROR 1105: nil pointer dereference
ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference
mysql>
```
### 4. What is your TiDB version? (Required)
```
mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.8-dirty
Edition: Community
Git Commit Hash: 8b857efa20363d50a8fa2ea7dd9809a85a61b115
Git Branch: HEAD
UTC Build Time: 2026-08-31 12:40:55
GoVersion: go1.25.12
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

```

Contributor guide

Open the contributing guide

Research direction

Start by running the provided CREATE TABLE, PREPARE, SET, and repeated EXECUTE reproduction against TiDB, then trace the prepared-statement execution path for tuple-IN batch point gets. Done means the second EXECUTE no longer panics and returns the correct result or a safe error, with a regression test covering both executions.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.