SET ROLE and parameter status

Started by Tatsuo Ishiiabout 2 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t50350
psql -h localhost -U postgres

Built from patchset v3 (message #3), July 27, 2026 at 11:19 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t50350_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t50350_3 && git checkout t50350_3

Patchset v3 (message #3) is on t50350_3

Jump to latest
#1Tatsuo Ishii
ishii@postgresql.org

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.

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

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tatsuo Ishii (#1)
Re: SET ROLE and parameter status

Hi

pá 4. 10. 2024 v 15:16 odesílatel Tatsuo Ishii <ishii@postgresql.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

/messages/by-id/CAFj8pRBFU-WzzQhNrwRHn67N0Ug8a9-0-9BOo69PPtcHiBDQMA@mail.gmail.com
/messages/by-id/CAFCRh-_VwScttZi4R8grSd-b=7qguAnSzXp_+jbdpUkp=TfxPQ@mail.gmail.com

Show quoted text

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

#3Tatsuo Ishii
ishii@postgresql.org
In reply to: Pavel Stehule (#2)
Re: SET ROLE and parameter status

Hi

pá 4. 10. 2024 v 15:16 odesílatel Tatsuo Ishii <ishii@postgresql.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

/messages/by-id/CAFj8pRBFU-WzzQhNrwRHn67N0Ug8a9-0-9BOo69PPtcHiBDQMA@mail.gmail.com
/messages/by-id/CAFCRh-_VwScttZi4R8grSd-b=7qguAnSzXp_+jbdpUkp=TfxPQ@mail.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

Attachments:

t50350_3
set_role.patchtext/x-patch; charset=us-asciiDownload+1-1