pingcap / pingcap/tidb

Bit shift for BLOB type behaves incosistently with MySQL8

Open
#53,943 2 comments 0 reactions 0 assignees View on GitHub
compatibility-mysql80 impact/wrong-result may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 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)
init db
```sql
create table t2(a blob);
create table t3(a blob);
insert into t2 values(0xC2A0);
insert into t3 values(0xC2);
select * from t2,t3 where t2.a like concat("%",t3.a,"%");
```

Then running:
```sql
select * from t2,t3 where (t2.a >> 4) = t3.a;
select * from t2,t3 where (t2.a >> 8) = t3.a;
```

### 2. What did you expect to see? (Required)
MySQL8.0.33 shows empty set for each query.
```sql
Empty set (0.01 sec)
Empty set (0.01 sec)
```

### 3. What did you see instead (Required)

TiDB 8.1 shows one row with warning.
```sql
+------+------+
| a | a |
+------+------+
|   | � |
+------+------+
1 row in set, 2 warnings (0.00 sec)
+------+------+
| a | a |
+------+------+
|   | � |
+------+------+
1 row in set, 2 warnings (0.01 sec)
> show warnings;
+---------+------+---------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '' |
| Warning | 1292 | Truncated incorrect DOUBLE value: '�' |
+---------+------+---------------------------------------+
```

### 4. What is your TiDB version? (Required)

```sql
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.1.0
Edition: Community
Git Commit Hash: 945d07c5d5c7a1ae212f6013adfb187f2de24b23
Git Branch: HEAD
UTC Build Time: 2024-05-21 03:51:57
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

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.