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

From Laurenz Albe
Subject Re: Customize psql prompt to show current_role
Date
Msg-id f65faa53285ca29541356809ee1c49b7ed04a33a.camel@cybertec.at
Whole thread Raw
In response to Re: Customize psql prompt to show current_role  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: Customize psql prompt to show current_role
Re: Customize psql prompt to show current_role
List pgsql-general
On Mon, 2024-09-23 at 14:59 +0200, Dominique Devienne wrote:
> On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold <ewie@ewie.name> wrote:
> > You could instead use this:
> >
> >     SELECT current_role \gset
> >     \set PROMPT1 '%n@%/ (%:current_role:)=%# '
> >
> > But that won't work with subsequent SET ROLE commands.
>
> Bummer... That was kinda the point, that it updates automatically.
>
> Then I'd like to respectfully request a small enhancement to psql
> to support a new \r (or some other letter) for current_role in the prompt.

To get the current role, psql would have to query the database whenever
it displays the prompt.  That would be rather expensive...

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Greg Sabino Mullane
Date:
Subject: Re: Customize psql prompt to show current_role
Next
From: Dominique Devienne
Date:
Subject: Re: Customize psql prompt to show current_role