LOAD DATA still panics on generated-column hard errors such as invalid regexp or invalid JSON cast
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
Two generated-column reproducers can hit the same problem.
Case 1: invalid regexp in generated column
```sql
set @@sql_mode='';
use test;
drop table if exists t_gen_regex_like;
create table t_gen_regex_like (
k varchar(20),
s varchar(64),
g tinyint generated always as (regexp_like('a', s)) stored,
primary key(k)
);
```
Create `/tmp/t_gen_regex_like.txt` with:
```text
k1|(
```
Run:
```sql
load data local infile '/tmp/t_gen_regex_like.txt'
into table t_gen_regex_like
fields terminated by '|';
```
Case 2: invalid JSON cast in generated column
```sql
set @@sql_mode='';
use test;
drop table if exists t_gen_json_cast;
create table t_gen_json_cast (
k varchar(20),
s text,
g json generated always as (cast(s as json)) stored,
primary key(k)
);
```
Create `/tmp/t_gen_json_cast.txt` with:
```text
k1|oops
```
Run:
```sql
load data local infile '/tmp/t_gen_json_cast.txt'
into table t_gen_json_cast
fields terminated by '|';
```
### 2. What did you expect to see? (Required)
`LOAD DATA` should surface the original generated-column error and stop the statement cleanly. It should not panic and should not turn the failure into a downstream internal error.
For example:
- case 1 should report the regexp parsing error
- case 2 should report the invalid JSON error
### 3. What did you see instead (Required)
For case 1, TiDB first reports the original warning:
```text
Warning 1139: Got error 'error parsing regexp: missing closing ): `(`' from regexp
```
but then fails with:
```text
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
```
For case 2, TiDB first reports the original warning:
```text
Warning 3140: Invalid JSON text: The document root must not be followed by other values.
```
but then fails with:
```text
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
```
TiDB log shows the original row-building error first and then the panic in downstream key checking:
```text
failed to get row
commitWork panicked
buildHandleFromDatumRow -> getKeysNeedCheckOneRow -> batchCheckAndInsert
```
These reproducers use a common-handle primary key. The same generated JSON trigger also reproduces on other downstream shapes:
- int primary key: `ERROR 1105 (HY000): runtime error: index out of range [0] with length 0`
- unique index: `ERROR 8039 (HY000): Index column ... offset out of bound, row: []`
### 4. What is your TiDB version? (Required)
```text
Release Version: v26.3.0-alpha-2-g8a45fc4c16
Edition: Community
Git Commit Hash: 8a45fc4c16565ed0712f94b5ca2e7a219bfb80d4
Git Branch: HEAD
UTC Build Time: 2026-04-02 05:32:08
GoVersion: go1.25.8
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic
```
Related to #67533, but these reproducers do not depend on `VECTOR`.
Contributor guide
Assessment
This issue has not been assessed yet.