pingcap / pingcap/tidb

Privileges for INSERT command is incompatible with MySQL

Open
#64,025 0 comments 1 reaction 0 assignees View on GitHub
contribution sig/sql-infra 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)

```
-- connect as root
CREATE DATABASE test;
CREATE TABLE test.tbl (x INT, y INT DEFAULT 10);
CREATE USER foo;
GRANT INSERT ON test.tbl TO foo;

-- connect as foo
INSERT INTO test.tbl (x) VALUES (y+y);
```
### 2. What did you expect to see? (Required)
```
MySQL [(none)]> INSERT INTO test.tbl (x) VALUES (y+y);
ERROR 1143 (42000): SELECT command denied to user 'foo'@'%' for column 'y' in table 'tbl'
```
Since MySQL requires `SELECT` privilege for `INSERT INTO test.tbl (x) VALUES (y+y)`, and TiDB is designed to be compatible with MySQL, TiDB should require `SELECT` privilege for this command as well.
### 3. What did you see instead (Required)
```
MySQL [(none)]> INSERT INTO test.tbl (x) VALUES (y+y);
Query OK, 1 row affected (0.001 sec)
```
### 4. What is your TiDB version? (Required)
```
Release Version: v9.0.0-beta.1
Edition: Community
Git Commit Hash: 7aff918dcbfa6facf2adef9ade9961c40f217421
Git Branch: HEAD
UTC Build Time: 2025-03-24 09:09:55
GoVersion: go1.23.7
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.