pingcap / pingcap/tidb

Inconsistent behavior between BINARY and CAST( AS BINARY)

Open
#41,768 0 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/execution 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)

```SQL
CREATE TABLE t0 (c0 INTEGER);
INSERT INTO t0 VALUES (1898743733);
SELECT t0.c0 FROM t0 ORDER BY CAST(BINARY (t0.c0) AS DATETIME); -- ERROR 1105 (HY000): expected integer
SELECT t0.c0 FROM t0 ORDER BY CAST(CAST(t0.c0 AS BINARY) AS DATETIME); -- 1898743733
```

### 2. What did you expect to see? (Required)
The first SELECT statement should return the value without any errors.
### 3. What did you see instead (Required)
The first SELECT statement returns an error.
### 4. What is your TiDB version? (Required)

Release Version: v6.6.0
Edition: Community
Git Commit Hash: f4ca0821fb96a2bdd37d2fb97eb26c07fc58d4e4
Git Branch: heads/refs/tags/v6.6.0
UTC Build Time: 2023-02-17 14:49:02
GoVersion: go1.19.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv

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.