Non-prepared plan cache + zero-argument function call panics
- 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)
```
SET SESSION tidb_enable_non_prepared_plan_cache = 1;
CREATE TABLE t (a datetime, b int);
SELECT * FROM t WHERE a = date_format();
-- v8.5.8: ERROR 1105: runtime error: index out of range [0] with length 0
-- master: ERROR 1582: Incorrect parameter count (correct user-level error)
```
### 2. What did you expect to see? (Required)
### 3. What did you see instead (Required)
```
mysql> SET SESSION tidb_enable_non_prepared_plan_cache = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE t (a datetime, b int);
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT * FROM t WHERE a = date_format();
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
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
Research direction
Start with the reported SQL reproduction after enabling tidb_enable_non_prepared_plan_cache, then trace the non-prepared plan-cache path for the zero-argument date_format() call. Compare v8.5.8's panic with master’s incorrect-parameter-count behavior; done means the query returns the user-level parameter-count error without an index-out-of-range panic.
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