pingcap / pingcap/tidb

Different error code with not granted UPDATE statement

Open
#34,327 0 comments 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
severity/minor sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step
```sql
DROP DATABASE IF EXISTS privtest_db;
DROP USER IF EXISTS privtest@localhost;

CREATE DATABASE privtest_db;
CREATE TABLE privtest_db.t1 (a INT);
INSERT INTO privtest_db.t1 VALUES (10);

CREATE USER 'privtest'@'localhost';
GRANT SELECT, UPDATE ON privtest_db.t1 TO 'privtest'@'localhost';
REVOKE UPDATE ON privtest_db.t1 FROM 'privtest'@'localhost';

-- as privtest user
EXPLAIN UPDATE privtest_db.t1 SET a = a + 1;

--- as root
DROP USER 'privtest'@localhost;
USE test;
DROP DATABASE privtest_db;
```

### 2. What did you expect to see?
```sql
mysql> EXPLAIN UPDATE privtest_db.t1 SET a = a + 1;
ERROR 1142 (42000): UPDATE command denied to user 'privtest'@'localhost' for table 't1'
```
### 3. What did you see instead
```sql
tidb> EXPLAIN UPDATE privtest_db.t1 SET a = a + 1;
ERROR 8121 (HY000): privilege check for 'Update' fail
```
### 4. What is your TiDB version?
```
tidb_version(): Release Version: v6.1.0-alpha-306-g090feabf7
Edition: Community
Git Commit Hash: 090feabf7caa37052c544303da2291621e78d5ef
Git Branch: master
UTC Build Time: 2022-04-28 18:24:47
GoVersion: go1.18.1
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

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.