Inconsistent BINARY cast behavior between VIEW and subquery
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
```sql
CREATE TABLE test1(c0 VARCHAR(4));
INSERT INTO test1 VALUES ('11');
CREATE VIEW v AS (SELECT HEX(CAST(c0 AS BINARY)) AS c0 FROM test1);
SELECT c0 FROM v;
DROP VIEW v;
SELECT c0 FROM (SELECT HEX(CAST(c0 AS BINARY)) AS c0 FROM test1) AS v;
```
### 2. What did you expect to see? (Required)
Both queries should produce the same results
In MySQL, both approaches return the same result `3131`
### 3. What did you see instead (Required)
```
+----------+
| c0 |
+----------+
| 31310000 |
+----------+
```
```
+------+
| c0 |
+------+
| 3131 |
+------+
```
### 4. What is your TiDB version? (Required)
```
tiup playground nightly --host 0.0.0.0 --kv 3 --tiflash 3
```
```
8.0.11-TiDB-v9.0.0-beta.2.pre-384-g5fab436
```
Contributor guide
Assessment
This issue has not been assessed yet.