Re: Customize psql prompt to show current_role

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Dominique Devienne <ddevienne(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Erik Wienhold <ewie(at)ewie(dot)name>, Asad Ali <asadalinagri(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Customize psql prompt to show current_role
Date: 2024-09-23 15:36:47
Message-ID: 3085360.1727105807@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> 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 that: what it reports is libpq's PQuser(), that is the
name that was used to log in with. But if what you want is the
session_user, psql prompts already have %n for that.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dominique Devienne 2024-09-23 15:37:58 Re: Customize psql prompt to show current_role
Previous Message Adrian Klaver 2024-09-23 15:16:53 Re: Customize psql prompt to show current_role