pingcap / pingcap/tidb

(NOT EXISTS …) <= ALL (…) inside WHERE silently returns an empty result

Open
#70,846 5 comments 0 reactions 0 assignees View on GitHub
affects-25.10 affects-7.5 affects-8.1 affects-8.5 contribution severity/critical 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)

```
CREATE TABLE t_ex (c int); INSERT INTO t_ex VALUES (1);
SELECT (NOT EXISTS (SELECT 1 FROM t_ex)) <= ALL (SELECT c FROM t_ex); -- v8.5.8: 1 (correct)
SELECT * FROM t_ex
WHERE (NOT EXISTS (SELECT 1 FROM t_ex)) <= ALL (SELECT c FROM t_ex); -- v8.5.8: 0 rows (!)
-- master: 1 row
```

### 2. What did you expect to see? (Required)
```
mysql> SELECT * FROM t_ex
-> WHERE (NOT EXISTS (SELECT 1 FROM t_ex)) <= ALL (SELECT c FROM t_ex); -- v8.5.8: 0 rows (!)
+------+
| c |
+------+
| 1 |
+------+
1 row in set (0.00 sec)

```
### 3. What did you see instead (Required)
```
mysql> SELECT * FROM t_ex
-> WHERE (NOT EXISTS (SELECT 1 FROM t_ex)) <= ALL (SELECT c FROM t_ex); -- v8.5.8: 0 rows (!)
Empty set (0.00 sec)
```

### 4. What is your TiDB version? (Required)
```
mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.8-dirty
Edition: Community
Git Commit Hash: 8b857efa20363d50a8fa2ea7dd9809a85a61b115
Git Branch: HEAD
UTC Build Time: 2026-08-31 12:40:55
GoVersion: go1.25.12
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

```

Contributor guide

Open the contributing guide

Research direction

No source file or test is named in the report. Start by running the minimal reproduction and comparing the standalone expression with the same expression in the WHERE clause, then trace TiDB's handling of NOT EXISTS combined with ALL. Done means the WHERE query returns the expected single row while preserving correct standalone evaluation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.