WL#12098: MySQL system users

Affects: Server-8.0   —   Status: Complete

Executive Summary
=================
The aim of the worklog is:

A-1: Introduce two categories for users: Power users and regular users. In turn 
     regular users can not modify any properties of power users - even if DDL 
     privileges are granted.

    - The worklog will introduce a new dynamic privilege 'SYSTEM_USER'.
      The users granted this privilege will be power users.
    
A-2: Introduce a way to restrict DDL/DML operations on one or more databases
     even if user has required global privileges.
  
    - The worklog will introduce a new feature 'partial_revokes' to restrict
      access to one or more databases. A new global system variable with the 
      same name will be introduce in order to turn ON/OFF this feature.

High-Level Description
======================
At present 'CREATE USER' privilege grants us the ability to drop, create and 
modify any user account, including root. That means a user who has 
'CREATE USER' privilege can modify or drop any account including root.
If the user has the UPDATE privilege then (s)he can modify the record in
the grant table.
If the user has DELETE privilege then (s)he can modify the record in the grant
tables. 

For instance-  
mysql@root> CREATE USER foo;
mysql@root> GRANT CREATE USER,UPDATE,DELETE ON *.* TO foo WITH GRANT OPTION;
mysql@root> GRANT SELECT ON mysql.* TO foo with grant option;

Now, foo has the ability to do the following:

mysql@foo>CREATE USER bar;
mysql@foo>ALTER USER root@localhost IDENTIFIED BY 'gibberish';
mysql@foo>DROP USER root@localhost;
mysql@foo>DELETE FROM mysql.user WHERE user = 'root';
mysql@foo>UPDATE mysql.user SET authentication_string = 'gibberish'
          WHERE user='root';

User foo will not be able to perform above last four operations
(Unless authorized to do so) once this worklog will be implemented.