SET SESSION AUTHORIZATION

Synopsis

Use the SET SESSION AUTHORIZATION statement to set the current user and session user of the current session to be the specified user.

Syntax

set_session_authorization ::= SET [ SESSION | LOCAL ] SESSION 
                              AUTHORIZATION { role_name | DEFAULT }

reset_session_authorization ::= RESET SESSION AUTHORIZATION

set_session_authorization

SETSESSIONLOCALSESSIONAUTHORIZATIONrole_nameDEFAULT

reset_session_authorization

RESETSESSIONAUTHORIZATION

Semantics

Session user can only be changed by superusers. Once the session user is set to role_name, any further SQL commands will use the privileges available to that role.

To reset the session user back to current authenticated user, RESET SESSION AUTHORIZATION or SET SESSION AUTHORIZATION DEFAULT can be used.

Examples

  • Set session user to John.
yugabyte=# select session_user, current_user;
 session_user | current_user
--------------+--------------
 yugabyte     | yugabyte
(1 row)
yugabyte=# set session authorization john;
SET
yugabyte=# select session_user, current_user;
 session_user | current_user
--------------+--------------
 john     | john
(1 row)

See also