User Functions

Several of the included functions in PostgreSQL deal with user and session issues. The following sections discuss user-related functions.

CURRENT_USER

Description

The CURRENT_USER function returns the user ID being used for permission checking.

Inputs

None.

Example
SELECT CURRENT_USER; 
--------------
webuser 
Notes

Currently, CURRENT_USER and SESSION_USER are the same, but in the future, there might be a distinction as needed for programs running in a setuid mode.

Notice that the preceding function is not called with the trailing parentheses “()”. This is to maintain SQL compatibility.

SESSION_USER

Description

The SESSION_USER function returns the user ID that is currently logged into PostgreSQL.

Inputs

None.

Example ...

Get PostgreSQL Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.