pingcap / pingcap/tidb

Strange permission check output of the `DELETE` command that contains an invalid `WHERE` clause

Open
#62,450 0 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Strange permission check output of the `DELETE` command that contains an invalid `WHERE` clause.

When a table's definition contains `INT PRIMARY KEY` (e.g., `CREATE TABLE x (x INT PRIMARY KEY);`), statements like `DELETE FROM x WHERE x = 2147483648;` (where 2147483648 is a **invalid** int value) can be executed by other users without the command denied error.

It seems that the `DELETE` command cannot affect anything since the `WHERE` clause is always FALSE. However, it should still be denied since other users do not have the DELETE privilege.

### 1. Minimal reproduce step (Required)

```sql
-- login as root
CREATE TABLE test.x (x INT PRIMARY KEY);
CREATE USER foo;

-- login as foo
DELETE FROM test.x WHERE x = 2147483647;
-- ERROR 1142 (42000): SELECT command denied to user 'foo'@'%' for table 'x'
DELETE FROM test.x WHERE x = 2147483648;
-- Query OK, 0 rows affected (0.01 sec)
```

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

Both `DELETE` commands should fail.

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

The second command succeeds, which contains an invalid INT value in `WHERE` clause.

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

```
Release Version: v9.0.0-beta.1.pre-533-g671534a
Edition: Community
Git Commit Hash: 671534a755e5ac3fbb5b515cc15f4d54142e6810
Git Branch: HEAD
UTC Build Time: 2025-04-09 14:12:27
GoVersion: go1.23.8
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.