Re: documentation fix for SET ROLE

Поиск
Список
Период
Сортировка
От Bossart, Nathan
Тема Re: documentation fix for SET ROLE
Дата
Msg-id F274DC61-E916-44B0-A927-D7BCADF2CBEE@amazon.com
обсуждение исходный текст
Ответ на Re: documentation fix for SET ROLE  (Joe Conway <mail@joeconway.com>)
Список pgsql-hackers
On 2/17/21, 12:15 PM, "Joe Conway" <mail@joeconway.com> wrote:
> On 2/17/21 2:12 PM, David G. Johnston wrote:
>> On Wednesday, February 17, 2021, Bossart, Nathan <bossartn@amazon.com
>> <mailto:bossartn@amazon.com>> wrote:
>> 
>> 
>>         postgres=# ALTER ROLE test1 SET ROLE test2;
>>         ALTER ROLE
>> 
>> 
>> I would not have expected this to work - “role” isn’t a
>> configuration_parameter.  Its actually cool that it does, but this doc fix
>> should address this oversight as well.
>
>
> I was surprised this worked too.
>
> But the behavior is consistent with other GUCs. In other words, when you "ALTER
> ROLE ... SET ..." you change the default value for the session, and therefore a
> RESET just changes to that value.

Looking further, I noticed that session_authorization does not work
the same way.  AFAICT this is because it's set via SetConfigOption()
in InitializeSessionUserId().  If you initialize role here, it acts
the same as session_authorization.

diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 0f67b99cc5..a201bb3766 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -761,6 +761,7 @@ InitializeSessionUserId(const char *rolename, Oid roleid)
     }

     /* Record username and superuser status as GUC settings too */
+    SetConfigOption("role", rname, PGC_BACKEND, PGC_S_OVERRIDE);
     SetConfigOption("session_authorization", rname,
                     PGC_BACKEND, PGC_S_OVERRIDE);
     SetConfigOption("is_superuser",

Nathan


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Finding cause of test fails on the cfbot site
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: Finding cause of test fails on the cfbot site