pingcap / pingcap/tidb

WHERE ... IN ... incorrectly returns rows

Open
#65,307 3 comments 0 reactions 0 assignees View on GitHub
contribution first-time-contributor may-affects-7.1 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

When using the IN predicate to compare a BINARY column with a BIT column returned from a subquery the server returns incorrect results.

### 1. Minimal reproduce step (Required)

```
CREATE TABLE t1(c1 BIT);
CREATE TABLE t2(c1 BINARY(1));

INSERT INTO t1(c1) VALUES(b'0');
INSERT INTO t2(c1) VALUES('o');
INSERT INTO t2(c1) VALUES('E');

SELECT c1 FROM t2 WHERE t2.c1 IN (SELECT c1 FROM t1);
/*
ACTUAL RESULT (Incorrect):
+------------+
| c1 |
+------------+
| 0x6F |
| 0x45 |
+------------+
2 rows in set

EXPECTED RESULT (Correct):
Empty set (0 rows)
*/
```

### 2. What did you expect to see? (Required)
Return empty set.

### 3. What did you see instead (Required)
Wrongly return 2 records.

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

```
tidb_version(): Release Version: v7.5.1
Edition: Community
Git Commit Hash: 7d16cc79e81bbf573124df3fd9351c26963f3e70
Git Branch: heads/refs/tags/v7.5.1
UTC Build Time: 2024-02-27 14:30:59
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: unistore
```

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.