Re: SET ROLE and parameter status

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pavel(dot)stehule(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: SET ROLE and parameter status
Date: 2024-10-05 03:37:34
Message-ID: 20241005.123734.1312021481231892238.ishii@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Hi
>
> pá 4. 10. 2024 v 15:16 odesílatel Tatsuo Ishii <ishii(at)postgresql(dot)org>
> napsal:
>
>> Sorry if this has been discussed before.
>>
>> I wonder why SET ROLE command does not produce a parameter status
>> message noticing the new current_user. Note that SET
>> SESSION_AUTHORIZATION command produces a parameter status message for
>> the new session_authorization value.
>>
>
> This feature was proposed more times
>
> https://www.postgresql.org/message-id/flat/CAFj8pRBFU-WzzQhNrwRHn67N0Ug8a9-0-9BOo69PPtcHiBDQMA(at)mail(dot)gmail(dot)com
> https://www.postgresql.org/message-id/CAFCRh-_VwScttZi4R8grSd-b%3D7qguAnSzXp_%2BjbdpUkp%3DTfxPQ%40mail.gmail.com

Thank you for the link. I have quickly read through the
discussions. If my understanding is correct, most of the conversions
were spent for how to make psql handle current role nicely. However in
my case I just need backend to produce a new parameter status message
when SET ROLE command is executed. Attached one-line patch makes it
possible that (it is essentially the same as your initial patch in the
thread).

This way, older clients including psql is not disturbed because
unknown parameter status messages would be ignored. Of course it
would be possible to change psql (and possibly psql) so that it stores
the new parameter message and use it for nice prompt etc.

One of the concerns is, upon connection time we need to handle one
more parameter status message. To test possible performance
degradation, I ran quick pgbench test with -C option (establish
connection on each transaction). (Actual command line was: -S -C -c 1
-T 30)

Without patch on master:
average connection time = 1.547 ms
average connection time = 1.659 ms
average connection time = 1.657 ms
average: 1.621 ms

With patch on master:
average connection time = 1.656 ms
average connection time = 1.546 ms
average connection time = 1.677 ms
average: 1.626 ms

With patch it was 1.626 - 1.621 = 0.05 ms (0.3%) slower.

So my proposal is, to change backend first, then to change psql/libpq
if necessary.

Best reagards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

Attachment Content-Type Size
set_role.patch text/x-patch 654 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2024-10-05 05:21:14 Re: New PostgreSQL Contributors
Previous Message Tom Lane 2024-10-05 02:28:45 Re: Getting "ERROR: unrecognized node type: 444" while creating an AST