SET SESSION AUTHORIZATION - set for the current session identifier and the current user session user identifier

SYNOPSIS

 

SET [ SESSION | LOCAL ] SESSION AUTHORIZATION username
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
RESET SESSION AUTHORIZATION

DESCRIPTION Description


This SQL command to the current session of the environment and the current session user ID user ID is set to username. This user name can be written as an identifier or a string literal. Using this command, we can temporarily become an unprivileged user, and then switch back later superuser.


Session user identifier is initially set to the user name (may be certified) provided by the client. The current user identifier is normally equal to the session user identifier, but might change temporarily in a "setuid" environment or similar mechanism inside. The current user identifier and check the relevant permission.


Only in the initial session user ( the authenticated user ) when there superuser privileges, the session user identifier to change. Otherwise, only under specified authenticated user name, the system only accepts the command.

SESSION and LOCAL modifiers and ordinary the SET [ the SET (7)] command in the same role.

DEFAULT and RESET forms reset the session identifier and the user name of the current user's initial authentication. These forms can be performed for any user.

EXAMPLES Examples

 

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 peter        | peter

SET SESSION AUTHORIZATION 'paul';

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 paul         | paul
樊伟胜

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11098344.html