* 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
| 910 | * to restore a prior value of the ROLE GUC variable.) |
| 911 | */ |
| 912 | void |
| 913 | SetCurrentRoleId(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 | /* |
no test coverage detected