match_grantee
NAME
match_grantee(): Match an existing account based on user+host.TYPE
FunctionDESCRIPTION
MySQL does not provide with identification of logged in accounts. It only provides with user + host:port combination within processlist. Alas, these do not directly map to accounts, as MySQL lists the host:port from which the connection is made, but not the (possibly wildcard) user or host.
This function matches a user+host combination against the known accounts, using the same matching method as the MySQL server, to detect the account which MySQL identifies as the one matching. It is similar in essence to CURRENT_USER(), only it works for all sessions, not just for the current session.
SYNOPSIS
match_grantee(connection_user char(16) CHARSET utf8, connection_host char(70) CHARSET utf8) RETURNS VARCHAR(100) CHARSET utf8
Input:
- connection_user: user login (e.g. as specified by PROCESSLIST)
- connection_host: login host. May optionally specify port number (e.g. webhost:12345), which is discarded by the function. This is to support immediate input from as specified by PROCESSLIST.
EXAMPLES
Find an account matching the given use+host combination:
mysql> SELECT match_grantee('apps', '192.128.0.1:12345') AS grantee; +------------+ | grantee | +------------+ | 'apps'@'%' | +------------+