pingcap / pingcap/tidb

Inconsistent BINARY cast behavior between VIEW and subquery

Open
#63,240 2 comments 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
contribution fuzz/sqlancer severity/moderate sig/sql-infra type/bug
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

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.