src/backend/utils/init/miscinit.c
/*
 * Change session auth ID while running
 *
 * Only a superuser may set auth ID to something other than himself.  Note
 * that in case of multiple SETs in a single session, the original userid's
 * superuserness is what matters.  But we set the GUC variable is_superuser
 * to indicate whether the *current* session userid is a superuser.
 *
 * Note: this is not an especially clean place to do the permission check.
 * It's OK because the check does not require catalog access and can't
 * fail during an end-of-transaction GUC reversion, but we may someday
 * have to push it up into assign_session_authorization.
 */
Change session auth ID while running
Only a superuser may set auth ID to something other than himself.  Note
that in case of multiple SETs in a single session, the original userid's
superuserness is what matters.  But we set the GUC variable is_superuser
to indicate whether the *current* session userid is a superuser.

this is not an especially clean place to do the permission check.
It's OK because the check does not require catalog access and can't
fail during an end-of-transaction GUC reversion, but we may someday
have to push it up into assign_session_authorization.
Change session auth ID while running Only a superuser may set auth ID to something other than himself . Note that in case of multiple SETs in a single session the original userid ' s superuserness is what matters . But we set the GUC variable is_superuser to indicate whether the * current * session userid is a superuser . this is not an especially clean place to do the permission check . It ' s OK because the check does not require catalog access and can ' t fail during an end - of - transaction GUC reversion but we may someday have to push it up into assign_session_authorization .
void
SetSessionAuthorization(Oid userid, bool is_superuser)
{
	AssertState(OidIsValid(AuthenticatedUserId));
	if (userid != AuthenticatedUserId &&
		!AuthenticatedUserIsSuperuser)
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 errmsg("permission denied to set session authorization")));
	SetSessionUserId(userid, is_superuser);
	if ((Gp_role == GP_ROLE_DISPATCH || Gp_role == GP_ROLE_EXECUTE) && IsResQueueEnabled())
	{
		SetResQueueId();
	}
	SetConfigOption("is_superuser",
					is_superuser ? "on" : "off",
					PGC_INTERNAL, PGC_S_OVERRIDE);
}
void SetSessionAuthorization ( Oid userid , bool is_superuser ) { AssertState ( OidIsValid ( AuthenticatedUserId ) ) ; if ( userid != AuthenticatedUserId && ! AuthenticatedUserIsSuperuser ) ereport ( ERROR , ( errcode ( ERRCODE_INSUFFICIENT_PRIVILEGE ) , errmsg ( " " ) ) ) ; SetSessionUserId ( userid , is_superuser ) ; if ( ( Gp_role == GP_ROLE_DISPATCH || Gp_role == GP_ROLE_EXECUTE ) && IsResQueueEnabled ( ) ) { SetResQueueId ( ) ; } SetConfigOption ( " " , is_superuser ? " " : " " , PGC_INTERNAL , PGC_S_OVERRIDE ) ; }
Change session auth ID while running
 Only a superuser may set auth ID to something other than himself.
Change session auth ID while running Only a superuser may set auth ID to something other than himself .
/* Must have authenticated already, else can't make permission check */ /* If resource scheduling enabled, set the cached queue for the new role.*/