MCPcopy Create free account
hub / github.com/apache/cloudberry / SetCurrentRoleId

Function SetCurrentRoleId

src/backend/utils/init/miscinit.c:912–946  ·  view source on GitHub ↗

* Change Role ID while running (SET ROLE) * * If roleid is InvalidOid, we are doing SET ROLE NONE: revert to the * session user authorization. In this case the is_superuser argument * is ignored. * * When roleid is not InvalidOid, the caller must have checked whether * the session user has permission to become that role. (We cannot check * here because this routine must be able to execut

Source from the content-addressed store, hash-verified

910 * to restore a prior value of the ROLE GUC variable.)
911 */
912void
913SetCurrentRoleId(Oid roleid, bool is_superuser)
914{
915 /*
916 * Get correct info if it's SET ROLE NONE
917 *
918 * If SessionUserId hasn't been set yet, just do nothing --- the eventual
919 * SetSessionUserId call will fix everything. This is needed since we
920 * will get called during GUC initialization.
921 */
922 if (!OidIsValid(roleid))
923 {
924 if (!OidIsValid(SessionUserId))
925 return;
926
927 roleid = SessionUserId;
928 is_superuser = SessionUserIsSuperuser;
929
930 SetRoleIsActive = false;
931 }
932 else
933 SetRoleIsActive = true;
934
935 SetOuterUserId(roleid);
936
937 /* If resource scheduling enabled, set the cached queue for the new role.*/
938 if ((Gp_role == GP_ROLE_DISPATCH || IS_SINGLENODE() || Gp_role == GP_ROLE_EXECUTE) && IsResQueueEnabled())
939 {
940 SetResQueueId();
941 }
942
943 SetConfigOption("is_superuser",
944 is_superuser ? "on" : "off",
945 PGC_INTERNAL, PGC_S_OVERRIDE);
946}
947
948
949/*

Callers 3

PostgresMainFunction · 0.85
assign_roleFunction · 0.85
ParallelWorkerMainFunction · 0.85

Calls 3

SetOuterUserIdFunction · 0.85
SetResQueueIdFunction · 0.85
SetConfigOptionFunction · 0.85

Tested by

no test coverage detected