v.19.14New Feature

Created a Function Currentuser(), Returning Login of Authorized User

Created a function currentUser(), returning login of authorized user. Added alias user() for compatibility with MySQL. #6470 (Alex Krash)
Introduced the currentUser() function in ClickHouse, which returns the login name of the authorized user. An alias user() has also been added for compatibility with MySQL.

Why it matters

This feature allows users to retrieve the currently authorized user's login within queries, facilitating auditing, access control, and session-specific logic execution. The alias user() ensures smoother migration and compatibility for users coming from MySQL environments.

How to use it

Use the function currentUser() within your SQL queries to get the login of the authorized user. For compatibility, you can also use user(). Example usage:

SELECT currentUser();
-- or equivalently
SELECT user();