pingcap / pingcap/tidb

Unexpected result when using `BIT_OR` in `RIGHT JOIN`

Open
#57,284 1 comment 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
fuzz/sqlancer impact/wrong-result severity/moderate sig/planner 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
DROP DATABASE IF EXISTS db0;
CREATE DATABASE db0;
USE db0;

CREATE TABLE t0(c0 INT);

SELECT * FROM t0 RIGHT JOIN (SELECT BIT_OR(1970) FROM t0) AS sub0 ON true; -- NULL 0
SELECT * FROM t0 RIGHT JOIN (SELECT BIT_OR(1970) FROM t0) AS sub0 ON true WHERE (CASE 1 WHEN NULL THEN true END );
-- Expected: 0 rows
-- Actual: NULL 0

```

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

The first query returns one row `NULL 0`, and `CASE 1 WHEN NULL THEN true END ` should be evaluated to `NULL`; therefore the second query should return an empty set. However, one row is returned. This is also different from MySQL.

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

As mentioned above.

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

```
mysql> SELECT tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.0-alpha-79-g426ce3e570
Edition: Community
Git Commit Hash: 426ce3e57069afbd8f061d7ae39c79d3f9e2ff5d
Git Branch: HEAD
UTC Build Time: 2024-11-09 05:26:34
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
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.