Skip to content

show create table should fail when the user only has create temporary table privilege #29281

@djshow832

Description

@djshow832

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql -h127.1 -uroot -P4000

mysql> create database tmpdb;
Query OK, 0 rows affected (0.01 sec)

mysql> create table tmpdb.t(id int);
Query OK, 0 rows affected (0.01 sec)

mysql> drop user test_user;
Query OK, 0 rows affected (0.01 sec)

mysql> create user test_user;
Query OK, 0 rows affected (0.01 sec)

mysql> grant create temporary tables on tmpdb.* to test_user;
Query OK, 0 rows affected (0.00 sec)
mysql -h127.1 -utest_user -P4000

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| tmpdb              |
+--------------------+
2 rows in set (0.00 sec)

mysql> use tmpdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------+
| Tables_in_tmpdb |
+-----------------+
| t               |
+-----------------+
1 row in set (0.00 sec)

mysql> show create table t;
+-------+------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

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

mysql -h127.1 -utest_user -Ac

mysql> use tmpdb;
Database changed
mysql> show tables;
Empty set (0.01 sec)

mysql> show create table t;
ERROR 1142 (42000): SHOW command denied to user 'test_user'@'localhost' for table 't'

3. What did you see instead (Required)

mysql -h127.1 -utest_user -P4000

mysql> use tmpdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------+
| Tables_in_tmpdb |
+-----------------+
| t               |
+-----------------+
1 row in set (0.00 sec)

mysql> show create table t;
+-------+------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

master

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions