Inconsistent behaviors when cast an integer value into the binary format
- 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)
I run the following cases.
```sql
-- 1
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 SMALLINT);
INSERT INTO t1 (c1) VALUES (-119);
SELECT c1 NOT LIKE (BINARY c1) FROM t1; -- actual: {1}, expected: {0}
-- 2
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 TINYINT);
INSERT INTO t1 (c1) VALUES (-119);
SELECT c1 NOT LIKE (BINARY c1) FROM t1; -- {0}
-- 3
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 (c1) VALUES (-119);
SELECT c1 NOT LIKE (BINARY c1) FROM t1; -- actual: {1}, expected: {0}
-- 4
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 BIGINT);
INSERT INTO t1 (c1) VALUES (-119);
SELECT c1 NOT LIKE (BINARY c1) FROM t1; -- actual: {1}, expected: {0}
```
### 2. What did you expect to see? (Required)
I expect these cases should produce the consistent result, e.g., all produced 0.
### 3. What did you see instead (Required)
Different results are returned.
### 4. What is your TiDB version? (Required)
Release Version: v8.5.1
Edition: Community
Git Commit Hash: fea86c8e35ad4a86a5e1160701f99493c2ee547c
Git Branch: HEAD
UTC Build Time: 2025-01-16 07:38:34
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Contributor guide
Assessment
This issue has not been assessed yet.