pingcap / pingcap/tidb

Unexpected error `Can't find column Column#3 in schema Column` when construct prepared statement for EXPLAIN

Open
#63,898 0 comments 0 reactions 0 assignees View on GitHub
contribution severity/moderate sig/planner 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)

The following test case triggers an unexpected error `Can't find column Column#3 in schema Column: [database5r.t0._tidb_rowid] PKOrUK: [] NullableUK: []`

```
CREATE TABLE t0(c0 CHAR );
CREATE VIEW v0(c0) AS SELECT ((FIELD(t0.c0, 1))!=(false)) FROM t0;
PREPARE prepare_query FROM 'EXPLAIN SELECT t0.c0 FROM v0, t0 WHERE ((t0.c0)=(REPLACE(?, v0.c0, ?)))';
```

I tried this in MySQL and there is no error.

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

No error.

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

`Can't find column Column#3 in schema Column: [database5r.t0._tidb_rowid] PKOrUK: [] NullableUK: []`

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

```
Release Version: v9.0.0-beta.2.pre-551-g71caddf56d\nEdition: Community\nGit Commit Hash: 71caddf56d9c1887650568101590417558149e3f\nGit Branch: master\nUTC Build Time: 2025-09-24 10:56:45\nGoVersion: go1.23.12\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.