MySQL 8.4.0
Source Code Documentation
sql_user_table.h File Reference

Go to the source code of this file.

Classes

class  Acl_table_intact
 Class to validate the flawlessness of ACL table before performing ACL operations. More...
 

Typedefs

typedef enum ACL_TABLES ACL_TABLES
 Enum for ACL tables. More...
 

Enumerations

enum  ACL_TABLES {
  TABLE_USER = 0 , TABLE_DB , TABLE_TABLES_PRIV , TABLE_COLUMNS_PRIV ,
  TABLE_PROCS_PRIV , TABLE_PROXIES_PRIV , TABLE_ROLE_EDGES , TABLE_DEFAULT_ROLES ,
  TABLE_DYNAMIC_PRIV , TABLE_PASSWORD_HISTORY , LAST_ENTRY
}
 Enum for ACL tables. More...
 

Functions

int handle_grant_table (THD *, Table_ref *tables, ACL_TABLES table_no, bool drop, LEX_USER *user_from, LEX_USER *user_to)
 Handle a privilege table. More...
 

Typedef Documentation

◆ ACL_TABLES

typedef enum ACL_TABLES ACL_TABLES

Enum for ACL tables.

Keep in sync with Acl_table_names

Enumeration Type Documentation

◆ ACL_TABLES

enum ACL_TABLES

Enum for ACL tables.

Keep in sync with Acl_table_names

Enumerator
TABLE_USER 
TABLE_DB 
TABLE_TABLES_PRIV 
TABLE_COLUMNS_PRIV 
TABLE_PROCS_PRIV 
TABLE_PROXIES_PRIV 
TABLE_ROLE_EDGES 
TABLE_DEFAULT_ROLES 
TABLE_DYNAMIC_PRIV 
TABLE_PASSWORD_HISTORY 
LAST_ENTRY 

Function Documentation

◆ handle_grant_table()

int handle_grant_table ( THD ,
Table_ref tables,
ACL_TABLES  table_no,
bool  drop,
LEX_USER user_from,
LEX_USER user_to 
)

Handle a privilege table.

Parameters
tablesThe array with the four open tables.
table_noThe number of the table to handle (0..4).
dropIf user_from is to be dropped.
user_fromThe the user to be searched/dropped/renamed.
user_toThe new name for the user if to be renamed, NULL otherwise.

This function scans through following tables: mysql.user, mysql.db, mysql.tables_priv, mysql.columns_priv, mysql.procs_priv, mysql.proxies_priv. For all above tables, we do an index scan and then iterate over the found records do following: Delete from grant table if drop is true. Update in grant table if drop is false and user_to is not NULL. Search in grant table if drop is false and user_to is NULL.

Returns
Operation result
Return values
0OK, but no record matched.
<0 Error.
>0 At least one record matched.