Commit 767a915d authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

refactor: split mysql_grant into separate components

This change splits mysql_grant based on the type of grants issued.

* mysql_grant_global -> GRANT <priv> ON *.*
* mysql_grant_db     -> GRANT <priv> ON <database>.*
* mysql_grant_proxy  -> GRANT PROXY ...

This does introduce a bit of code duplication, however it allows further
refactoring and also isolates the grant modifying logic away from other
details such as table opening, locking, binlogging.

Another side effect is that the mysql.db table is only locked for a
database level grant. Before it was locked even if there were only
global level grants issued.
parent a0cdf05d
......@@ -23,7 +23,7 @@ LOCK TABLE t1 WRITE;
REVOKE EXECUTE ON PROCEDURE sp FROM u;
ERROR HY000: Table 'procs_priv' was not locked with LOCK TABLES
REVOKE PROCESS ON *.* FROM u;
ERROR HY000: Table 'db' was not locked with LOCK TABLES
ERROR HY000: Table 'global_priv' was not locked with LOCK TABLES
DROP TABLE t1;
create database mysqltest1;
use mysqltest1;
......
......@@ -164,7 +164,7 @@ GRANT ALL ON p2 TO test_2@localhost;
ERROR HY000: Table 'tables_priv' was not locked with LOCK TABLES
INSERT INTO t2 VALUES ("GRANT ALL ON p2 TO test_2 with table locked");
GRANT USAGE ON *.* TO test_2@localhost;
ERROR HY000: Table 'db' was not locked with LOCK TABLES
ERROR HY000: Table 'global_priv' was not locked with LOCK TABLES
INSERT INTO t2 VALUES ("GRANT USAGE ON *.* TO test_2 with table locked");
REVOKE ALL PRIVILEGES ON f2 FROM test_2@localhost;
ERROR HY000: Table 'tables_priv' was not locked with LOCK TABLES
......@@ -176,7 +176,7 @@ REVOKE ALL PRIVILEGES ON t1 FROM test_2@localhost;
ERROR HY000: Table 'tables_priv' was not locked with LOCK TABLES
INSERT INTO t2 VALUES ("REVOKE ALL PRIVILEGES on table to user with table locked");
REVOKE USAGE ON *.* FROM test_2@localhost;
ERROR HY000: Table 'db' was not locked with LOCK TABLES
ERROR HY000: Table 'global_priv' was not locked with LOCK TABLES
INSERT INTO t2 VALUES ("REVOKE USAGE ON *.* TO test_2 with table locked");
RENAME USER test_2@localhost TO test_3@localhost;
ERROR HY000: Table 'db' was not locked with LOCK TABLES
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment