LEFT JOIN null-extension of virtual generated columns can panic in TiFlash MPP
- 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)
```sql
DROP DATABASE IF EXISTS gc_tiflash_gc_min3;
CREATE DATABASE gc_tiflash_gc_min3;
USE gc_tiflash_gc_min3;
CREATE TABLE t1 (
d VARCHAR(10),
gc_v_prefix VARCHAR(8) GENERATED ALWAYS AS (substr(d, 1, 2)) VIRTUAL
);
CREATE TABLE t2 (
id INT
);
INSERT INTO t2 VALUES (1);
ALTER TABLE t1 SET TIFLASH REPLICA 1;
ALTER TABLE t2 SET TIFLASH REPLICA 1;
SET SESSION tidb_isolation_read_engines = 'tiflash';
SET SESSION tidb_enforce_mpp = ON;
SELECT * FROM t2 LEFT JOIN t1 ON NULL;
SELECT t1.gc_v_prefix FROM t2 LEFT JOIN t1 ON 0;
```
### 2. What did you expect to see? (Required)
Both queries should return a single null-extended row from the left outer join.
Expected results:
```sql
SELECT * FROM t2 LEFT JOIN t1 ON NULL;
-- 1 | NULL | NULL
SELECT t1.gc_v_prefix FROM t2 LEFT JOIN t1 ON 0;
-- NULL
```
### 3. What did you see instead (Required)
With TiFlash MPP enabled, the queries fail:
```sql
SELECT * FROM t2 LEFT JOIN t1 ON NULL;
-- ERROR 1105 (HY000): runtime error: index out of range [2] with length 1
SELECT t1.gc_v_prefix FROM t2 LEFT JOIN t1 ON 0;
-- ERROR 1105 (HY000): Can't find column gc_tiflash_gc_min3.t1.d in schema Column: [gc_tiflash_gc_min3.t1.gc_v_prefix] PKOrUK: [] NullableUK: []
```
In the original wider repro, the first error can also appear as:
```sql
ERROR 1105 (HY000): runtime error: index out of range [3] with length 1
```
### 4. What is your TiDB version? (Required)
```sql
Release Version: v9.0.0
Edition: Community
Git Commit Hash: 4ae7a12ae7884061a9b095584fd22bc3eab23112
Git Branch: heads/refs/tags/v9.0.0
UTC Build Time: 2026-04-25 02:22:25
GoVersion: go1.25.9
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic
```
Contributor guide
Assessment
This issue has not been assessed yet.