4.11. Miscellaneous Functions

Table 4-21. Miscellaneous Functions

NameReturn TypeDescription
current_usernameuser name of current execution context
session_usernamesession user name
usernameequivalent 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.