TiDB cannot execute query with Case...When... condition
- 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 table if exists t1;
CREATE TABLE t1 (
c1 INT ZEROFILL,
c2 BIT(42)
);
INSERT IGNORE INTO t1
VALUES (TRUE, 10101001000000110110110001010000100100);
SELECT t1.c1
FROM t1
WHERE INET6_NTOA(
CASE
WHEN t1.c2 = -1638932481 THEN t1.c2
ELSE t1.c2
END
);
```
### 2. What did you expect to see? (Required)
TiDB should execute normally.
### 3. What did you see instead (Required)
TiDB throws errors.
```sql
-- TiDB
mysql> SELECT t1.c1
-> FROM t1
-> WHERE INET6_NTOA(
-> CASE
-> WHEN t1.c2 = -1638932481 THEN t1.c2
-> ELSE t1.c2
-> END
-> );
ERROR 1105 (HY000): baseBuiltinFunc.vecEvalString() should never be called, please contact the TiDB team for help
-- MySQL 8.4.1
mysql> SELECT t1.c1
-> FROM t1
-> WHERE INET6_NTOA(
-> CASE
-> WHEN t1.c2 = -1638932481 THEN t1.c2
-> ELSE t1.c2
-> END
-> );
Empty set, 1 warning (0.01 sec)
```
### 4. What is your TiDB version? (Required)
Release Version: v8.5.0
Contributor guide
Research direction
Start by running the supplied SQL reproduction against TiDB v8.5.0 and compare its result with MySQL 8.4.1. Trace the CASE expression and INET6_NTOA execution path from the reported vecEvalString error; done means the query executes normally without that error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100