MDEV-3798: EXPLAIN UPDATE/DELETE:
- Port grant_explain_non_select.{test,result} from mysql-5.6 - Per Sanja's hint, fix mysql_make_view() to take into account that EXPLAIN now is not necessarily EXPLAIN SELECT.
This commit is contained in:
parent
e522ebc221
commit
25d0175fde
178
mysql-test/r/grant_explain_non_select.result
Normal file
178
mysql-test/r/grant_explain_non_select.result
Normal file
@ -0,0 +1,178 @@
|
||||
CREATE DATABASE privtest_db;
|
||||
CREATE TABLE privtest_db.t1 (a INT);
|
||||
CREATE TABLE privtest_db.t2 (a INT);
|
||||
INSERT INTO privtest_db.t2 VALUES (1), (2), (3);
|
||||
GRANT USAGE ON *.* TO 'privtest'@'localhost';
|
||||
GRANT SELECT ON privtest_db.t2 TO 'privtest'@'localhost';
|
||||
USE privtest_db;
|
||||
EXPLAIN INSERT INTO t1 VALUES (10);
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
INSERT INTO t1 VALUES (10);
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN INSERT INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
GRANT INSERT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN INSERT INTO t1 VALUES (10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL
|
||||
INSERT INTO t1 VALUES (10);
|
||||
EXPLAIN INSERT INTO t1 SELECT * FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
ERROR 42000: INSERT,DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
ERROR 42000: INSERT,DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: INSERT,DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: INSERT,DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
GRANT INSERT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REVOKE INSERT ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
GRANT INSERT, DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
UPDATE t1 SET a = a + 1;
|
||||
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
GRANT UPDATE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
|
||||
UPDATE t1 SET a = a + 1;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
|
||||
REVOKE UPDATE ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
UPDATE t1 SET a = a + 1;
|
||||
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
GRANT UPDATE, SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8
|
||||
UPDATE t1 SET a = a + 1;
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
GRANT DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT DELETE, SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
CREATE VIEW privtest_db.v1 (a) AS SELECT a FROM privtest_db.t1;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON privtest_db.v1 TO 'privtest'@'localhost';
|
||||
EXPLAIN SELECT * FROM v1;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
SELECT * FROM v1;
|
||||
a
|
||||
11
|
||||
4
|
||||
4
|
||||
11
|
||||
4
|
||||
4
|
||||
EXPLAIN INSERT INTO v1 VALUES (10);
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
INSERT INTO v1 VALUES (10);
|
||||
EXPLAIN INSERT INTO v1 SELECT * FROM t2;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
INSERT INTO v1 SELECT * FROM t2;
|
||||
EXPLAIN REPLACE INTO v1 VALUES (10);
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
REPLACE INTO v1 VALUES (10);
|
||||
EXPLAIN REPLACE INTO v1 SELECT * FROM t2;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
REPLACE INTO v1 SELECT * FROM t2;
|
||||
EXPLAIN UPDATE v1 SET a = a + 1;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
UPDATE v1 SET a = a + 1;
|
||||
EXPLAIN UPDATE v1, t2 SET v1.a = v1.a + 1 WHERE v1.a = t2.a;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
UPDATE v1, t2 SET v1.a = v1.a + 1 WHERE v1.a = t2.a;
|
||||
EXPLAIN DELETE FROM v1 WHERE a = 10;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
DELETE FROM v1 WHERE a = 10;
|
||||
EXPLAIN DELETE FROM v1 USING v1, t2 WHERE v1.a = t2.a;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
DELETE FROM v1 USING v1, t2 WHERE v1.a = t2.a;
|
||||
DROP USER 'privtest'@localhost;
|
||||
USE test;
|
||||
DROP DATABASE privtest_db;
|
258
mysql-test/t/grant_explain_non_select.test
Normal file
258
mysql-test/t/grant_explain_non_select.test
Normal file
@ -0,0 +1,258 @@
|
||||
#
|
||||
# Privilege-specific tests for WL#4897: Add EXPLAIN INSERT/UPDATE/DELETE
|
||||
#
|
||||
|
||||
# Grant tests not performed with embedded server
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
# Save the initial number of concurrent sessions
|
||||
--source include/count_sessions.inc
|
||||
|
||||
CREATE DATABASE privtest_db;
|
||||
|
||||
CREATE TABLE privtest_db.t1 (a INT);
|
||||
CREATE TABLE privtest_db.t2 (a INT);
|
||||
INSERT INTO privtest_db.t2 VALUES (1), (2), (3);
|
||||
|
||||
GRANT USAGE ON *.* TO 'privtest'@'localhost';
|
||||
GRANT SELECT ON privtest_db.t2 TO 'privtest'@'localhost';
|
||||
|
||||
connect(con1,localhost,privtest,,);
|
||||
connection con1;
|
||||
|
||||
USE privtest_db;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN INSERT INTO t1 VALUES (10);
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
INSERT INTO t1 VALUES (10);
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN INSERT INTO t1 SELECT * FROM t2;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
GRANT INSERT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
EXPLAIN INSERT INTO t1 VALUES (10);
|
||||
INSERT INTO t1 VALUES (10);
|
||||
|
||||
EXPLAIN INSERT INTO t1 SELECT * FROM t2;
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
|
||||
|
||||
connection default;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
GRANT INSERT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
REVOKE INSERT ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
GRANT INSERT, DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
EXPLAIN REPLACE INTO t1 VALUES (10);
|
||||
REPLACE INTO t1 VALUES (10);
|
||||
|
||||
EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
|
||||
REPLACE INTO t1 SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
UPDATE t1 SET a = a + 1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
GRANT UPDATE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
UPDATE t1 SET a = a + 1;
|
||||
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
REVOKE UPDATE ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
UPDATE t1 SET a = a + 1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
GRANT UPDATE, SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
EXPLAIN UPDATE t1 SET a = a + 1;
|
||||
UPDATE t1 SET a = a + 1;
|
||||
|
||||
EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
GRANT DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
GRANT DELETE, SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
EXPLAIN DELETE FROM t1 WHERE a = 10;
|
||||
DELETE FROM t1 WHERE a = 10;
|
||||
|
||||
EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
|
||||
|
||||
# Views
|
||||
|
||||
connection default;
|
||||
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
|
||||
CREATE VIEW privtest_db.v1 (a) AS SELECT a FROM privtest_db.t1;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON privtest_db.v1 TO 'privtest'@'localhost';
|
||||
connection con1;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN SELECT * FROM v1;
|
||||
SELECT * FROM v1;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN INSERT INTO v1 VALUES (10);
|
||||
INSERT INTO v1 VALUES (10);
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN INSERT INTO v1 SELECT * FROM t2;
|
||||
INSERT INTO v1 SELECT * FROM t2;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN REPLACE INTO v1 VALUES (10);
|
||||
REPLACE INTO v1 VALUES (10);
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN REPLACE INTO v1 SELECT * FROM t2;
|
||||
REPLACE INTO v1 SELECT * FROM t2;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN UPDATE v1 SET a = a + 1;
|
||||
UPDATE v1 SET a = a + 1;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN UPDATE v1, t2 SET v1.a = v1.a + 1 WHERE v1.a = t2.a;
|
||||
UPDATE v1, t2 SET v1.a = v1.a + 1 WHERE v1.a = t2.a;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN DELETE FROM v1 WHERE a = 10;
|
||||
DELETE FROM v1 WHERE a = 10;
|
||||
|
||||
--error ER_VIEW_NO_EXPLAIN
|
||||
EXPLAIN DELETE FROM v1 USING v1, t2 WHERE v1.a = t2.a;
|
||||
DELETE FROM v1 USING v1, t2 WHERE v1.a = t2.a;
|
||||
|
||||
connection default;
|
||||
disconnect con1;
|
||||
|
||||
DROP USER 'privtest'@localhost;
|
||||
USE test;
|
||||
DROP DATABASE privtest_db;
|
||||
|
||||
# Wait till we reached the initial number of concurrent sessions
|
||||
--source include/wait_until_count_sessions.inc
|
@ -1300,8 +1300,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
|
||||
underlying tables.
|
||||
Skip this step if we are opening view for prelocking only.
|
||||
*/
|
||||
if (!table->prelocking_placeholder &&
|
||||
(old_lex->sql_command == SQLCOM_SELECT && old_lex->describe))
|
||||
if (!table->prelocking_placeholder && (old_lex->describe))
|
||||
{
|
||||
/*
|
||||
The user we run EXPLAIN as (either the connected user who issued
|
||||
|
Loading…
x
Reference in New Issue
Block a user