sys.ps_thread_account(thread_id)
ps_thread_account is a stored function available with the Sys Schema that returns the account (username@hostname) associated with the given thread_id.
Returns NULL if the thread_id is not found.
SELECT sys.ps_thread_account(sys.ps_thread_id(CONNECTION_ID())); +----------------------------------------------------------+ | sys.ps_thread_account(sys.ps_thread_id(CONNECTION_ID())) | +----------------------------------------------------------+ | msandbox@localhost | +----------------------------------------------------------+ SELECT sys.ps_thread_account(sys.ps_thread_id(2042)); +-----------------------------------------------+ | sys.ps_thread_account(sys.ps_thread_id(2042)) | +-----------------------------------------------+ | NULL | +-----------------------------------------------+ SELECT sys.ps_thread_account(sys.ps_thread_id(NULL)); +-----------------------------------------------+ | sys.ps_thread_account(sys.ps_thread_id(NULL)) | +-----------------------------------------------+ | msandbox@localhost | +-----------------------------------------------+
© 2023 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/ps_thread_account/