September 26, 2024: PostgreSQL 17 Released!
Unsupported versions: 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

4.11. Miscellaneous Functions

Table 4-21. Miscellaneous Functions

Name Return Type Description
current_user name user name of current execution context
session_user name session user name
user name equivalent to current_user

The session_user is the user that initiated a database connection and is fixed for the duration of that connection. The current_user is the user identifier that is applicable for permission checking. Currently it is always equal to the session user, but in the future there might be "setuid" functions and other facilities to allow the current user to change temporarily. In Unix parlance, the session user is the "real user" and the current user is the "effective user".

Note that these functions have special syntactic status in SQL; they must be called without trailing parentheses.

Deprecated: The function getpgusername() is an obsolete equivalent of current_user.