MySQL  8.0.21
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 *thd, TABLE_LIST *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.

Enumeration Type Documentation

◆ ACL_TABLES

enum ACL_TABLES

Enum for ACL tables.

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 thd,
TABLE_LIST tables,
ACL_TABLES  table_no,
bool  drop,
LEX_USER user_from,
LEX_USER user_to 
)

Handle a privilege table.

Parameters
thdThe thead handler
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.

Scan through all records in a grant table and apply the requested operation. For the "user" table, a single index access is sufficient, since there is an unique index on (host, user). 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.