Re: Customize psql prompt to show current_role

2024-11-27 Thread Dominique Devienne
On Wed, Nov 27, 2024 at 3:14 PM Raphael Salguero Aragón wrote: > Am 23.09.2024 um 17:37 schrieb Dominique Devienne : > > I'd be glad to use Pavel's proposed %N. —DD > I just wanted to add that we are also supporting a larger customer with > exactly the same request. > Perhaps this increases the v

Re: Customize psql prompt to show current_role

2024-11-27 Thread Raphael Salguero Aragón
Am 23.09.2024 um 17:37 schrieb Dominique Devienne : > > On Mon, Sep 23, 2024 at 5:16 PM Adrian Klaver > 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. > >>

Re: Customize psql prompt to show current_role

2024-09-23 Thread Tom Lane
Adrian Klaver writes: > 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. Worse than tha

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 5:16 PM Adrian Klaver 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

Re: Customize psql prompt to show current_role

2024-09-23 Thread Adrian Klaver
On 9/23/24 08:07, Dominique Devienne wrote: On Mon, Sep 23, 2024 at 4:55 PM Tom Lane wrote: Laurenz Albe writes: To get the current role, psql would have to query the database whenever it displays the prompt. That would be rather expensive... See previous discussion: https://www.postgresql

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 4:55 PM Tom Lane wrote: > Laurenz Albe writes: > > To get the current role, psql would have to query the database whenever > > it displays the prompt. That would be rather expensive... > > See previous discussion: > https://www.postgresql.org/message-id/flat/CAFj8pRBFU-Wz

Re: Customize psql prompt to show current_role

2024-09-23 Thread Tom Lane
Laurenz Albe writes: > To get the current role, psql would have to query the database whenever > it displays the prompt. That would be rather expensive... See previous discussion: https://www.postgresql.org/message-id/flat/CAFj8pRBFU-WzzQhNrwRHn67N0Ug8a9-0-9BOo69PPtcHiBDQMA%40mail.gmail.com At

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 3:05 PM Laurenz Albe wrote: > On Mon, 2024-09-23 at 14:59 +0200, Dominique Devienne wrote: > > On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold wrote: > > > You could instead use this: > > > > > > SELECT current_role \gset > > > \set PROMPT1 '%n@%/ (%:current_role:)=%

Re: Customize psql prompt to show current_role

2024-09-23 Thread Laurenz Albe
On Mon, 2024-09-23 at 14:59 +0200, Dominique Devienne wrote: > On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold wrote: > > You could instead use this: > > > > SELECT current_role \gset > > \set PROMPT1 '%n@%/ (%:current_role:)=%# ' > > > > But that won't work with subsequent SET ROLE comman

Re: Customize psql prompt to show current_role

2024-09-23 Thread Greg Sabino Mullane
On Mon, Sep 23, 2024 at 8:22 AM Asad Ali wrote: > There is no direct prompt escape sequence like %n for displaying the > current_role in the psql prompt. However, you can work around this by using > a \set command to define a custom prompt that includes the result of > current_role. > Please do

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold 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

Re: Customize psql prompt to show current_role

2024-09-23 Thread Erik Wienhold
On 2024-09-23 14:22 +0200, Asad Ali wrote: > There is no direct prompt escape sequence like %n for displaying the > current_role in the psql prompt. However, you can work around this by using > a \set command to define a custom prompt that includes the result of > current_role. > You can use the fo

Re: Customize psql prompt to show current_role

2024-09-23 Thread gparc
- Mail original - > De: "Dominique Devienne" > À: "Asad Ali" > Cc: pgsql-gene...@postgresql.org > Envoyé: Lundi 23 Septembre 2024 14:34:39 > Objet: Re: Customize psql prompt to show current_role > On Mon, Sep 23, 2024 at 2:22 PM Asad Ali wrot

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 2:22 PM Asad Ali wrote: > There is no direct prompt escape sequence like %n for displaying the > current_role in the psql prompt. > However, you can work around this by using a \set command to define a custom > prompt that includes the result of current_role. Hi Ali. Doe

Re: Customize psql prompt to show current_role

2024-09-23 Thread Asad Ali
Hi Dominique, There is no direct prompt escape sequence like %n for displaying the current_role in the psql prompt. However, you can work around this by using a \set command to define a custom prompt that includes the result of current_role. You can use the following command to set your psql PROMP