Skip to content

GRANT/REVOKE ON non-existent table incorrectly returns error #28533

@morgo

Description

@morgo

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP DATABASE IF EXISTS d1;
DROP USER IF EXISTS u1;
CREATE DATABASE d1;
USE d1;
CREATE TABLE t1 (a int);
CREATE USER u1;
GRANT ALTER ON d1.t1 TO u1; -- table exists, works
GRANT INSERT, CREATE ON d1.t2 TO u1; -- table doesn't exist; fails in tidb, works in MySQL.

DROP TABLE t1;
REVOKE ALTER ON d1.t1 FROM u1; -- revoke fails when table doesn't exist (serious)

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

mysql [localhost:8024] {root} (d1) > DROP DATABASE IF EXISTS d1;
Query OK, 1 row affected (0.00 sec)

mysql [localhost:8024] {root} ((none)) > DROP USER IF EXISTS u1;
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8024] {root} ((none)) > CREATE DATABASE d1;
Query OK, 1 row affected (0.00 sec)

mysql [localhost:8024] {root} ((none)) > USE d1;
Database changed
mysql [localhost:8024] {root} (d1) > CREATE TABLE t1 (a int);
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8024] {root} (d1) > CREATE USER u1;
Query OK, 0 rows affected (0.01 sec)

mysql [localhost:8024] {root} (d1) > GRANT ALTER ON d1.t1 TO u1; -- table exists, works
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8024] {root} (d1) > GRANT INSERT, CREATE ON d1.t2 TO u1; -- table doesn't exist; fails in tidb, works in MySQL.
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8024] {root} (d1) > DROP TABLE t1;
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8024] {root} (d1) > REVOKE ALTER ON d1.t1 FROM u1; 
Query OK, 0 rows affected (0.00 sec)

3. What did you see instead (Required)

mysql> DROP DATABASE IF EXISTS d1;
Query OK, 0 rows affected (0.01 sec)

mysql> DROP USER IF EXISTS u1;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE DATABASE d1;
Query OK, 0 rows affected (0.00 sec)

mysql> USE d1;
Database changed
mysql> CREATE TABLE t1 (a int);
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER u1;
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALTER ON d1.t1 TO u1; -- table exists, works
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT INSERT, CREATE ON d1.t2 TO u1; -- table doesn't exist; fails in tidb, works in MySQL.
ERROR 1146 (42S02): Table 'd1.t2' doesn't exist

mysql> DROP TABLE t1;
Query OK, 0 rows affected (0.01 sec)

mysql> REVOKE ALTER ON d1.t1 FROM u1; -- serious
ERROR 1146 (42S02): Table 'd1.t1' doesn't exist

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.3.0-alpha-256-gb0b559f23
Edition: Community
Git Commit Hash: b0b559f2389de5e27d0d2e12d2bfae049186b54b
Git Branch: master
UTC Build Time: 2021-10-01 14:52:33
GoVersion: go1.16.7
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.severity/moderatesig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions