Re: documentation fix for SET ROLE

From: Joe Conway <mail(at)joeconway(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "Bossart, Nathan" <bossartn(at)amazon(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: documentation fix for SET ROLE
Date: 2021-02-17 20:14:07
Message-ID: e7e64025-0a07-fa6d-665c-1deca762d868@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/17/21 2:12 PM, David G. Johnston wrote:
> On Wednesday, February 17, 2021, Bossart, Nathan <bossartn(at)amazon(dot)com
> <mailto:bossartn(at)amazon(dot)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.

-- login as postgres
nmx=# show work_mem;
work_mem
----------
200MB
(1 row)

nmx=# set work_mem = '42MB';
SET
nmx=# show work_mem;
work_mem
----------
42MB
(1 row)

nmx=# reset work_mem;
RESET
nmx=# show work_mem;
work_mem
----------
200MB
(1 row)

ALTER ROLE test1 SET work_mem = '42MB';

-- login as test1
nmx=> show work_mem;
work_mem
----------
42MB
(1 row)

nmx=> reset work_mem;
RESET
nmx=> show work_mem;
work_mem
----------
42MB
(1 row)

Joe

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-02-17 20:18:02 Re: Finding cause of test fails on the cfbot site
Previous Message Tomas Vondra 2021-02-17 19:36:36 Re: POC: postgres_fdw insert batching