Re: Customize psql prompt to show current_role - Mailing list pgsql-general

From Dominique Devienne
Subject Re: Customize psql prompt to show current_role
Date
Msg-id CAFCRh-8=zWRpDXiVUUqtFN5F=xhYUqqtieA8Hg0NiCxqe+sESQ@mail.gmail.com
Whole thread Raw
In response to Re: Customize psql prompt to show current_role  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
On Mon, Sep 23, 2024 at 5:16 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
> On 9/23/24 08:07, Dominique Devienne wrote:
> > I often resort to \conninfo, but it's less automatic and
> > harder to visually parse (IMHO) compared to a custom ad-hoc prompt.

> For me that shows the user that connected(session_user) not the current_user.

yeah, sure, I realized that just after sending my last post...
I resort to using both \conninfo *and* `select current_role`.
I used \conninfo to tell me which server I'm on (since not
on the default prompt, before I played with it today), which
session_user I'm connected with (ddevienne or dd_login
in my recent example), and finally `select current_role`
which matters in my use-cases (session_user or dd_admin or dd_user).

I'd like not to have to type those commands/queries all the time,
and have them in the prompt at all time. I get that it's not for everyone,
nor even necessary all the time, but I sincerely think it is definitely useful.

I'd be glad to use Pavel's proposed %N. --DD



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Customize psql prompt to show current_role
Next
From: Justin
Date:
Subject: Re: Logical Replication Delay