Skip to content

Inconsistent BINARY cast behavior between VIEW and subquery #63240

@momoway

Description

@momoway

Bug Report

1. Minimal reproduce step (Required)

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions