pingcap / pingcap/tidb

For creating view- in TIDB need create view and select privilege, in mysql need only create view privilege

Open
#34,342 1 comment 0 reactions 0 assignees View on GitHub
type/compatibility
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)

```sql

CREATE USER mysqluser1@localhost;
CREATE DATABASE mysqltest1;
USE mysqltest1;
CREATE TABLE t1 ( a INT );
CREATE TABLE t2 ( b INT );
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1), (2);
GRANT CREATE VIEW ON mysqltest1.* TO mysqluser1@localhost;
GRANT SELECT ON t1 TO mysqluser1@localhost;
GRANT INSERT ON t2 TO mysqluser1@localhost;

use mysqltest1;
CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
SELECT * FROM v1;
SELECT b FROM v1;

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

mysql> CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
Query OK, 0 rows affected (0.02 sec)

mysql> SELECT * FROM v1;
ERROR 1142 (42000): SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
mysql> SELECT b FROM v1;
ERROR 1142 (42000): SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
```
### 3. What did you see instead (Required)
```sql

mysql> CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
ERROR 1142 (42000): SELECT command denied to user 'mysqluser1'@'localhost' for table 't2'
mysql> SELECT * FROM v1;
ERROR 1146 (42S02): Table 'mysqltest1.v1' doesn't exist
mysql> SELECT b FROM v1;
ERROR 1146 (42S02): Table 'mysqltest1.v1' doesn't exist
```
### 4. What is your TiDB version? (Required)

```sql
| Release Version: v6.1.0-alpha-278-gfb342ff86
Edition: Community
Git Commit Hash: fb342ff8612fbc2a18dad3ba92044c03cc5e98c0
Git Branch: master
UTC Build Time: 2022-04-26 05:36:37
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: true |

```

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.