proposal: psql: show current user in prompt - Mailing list pgsql-hackers

From Pavel Stehule
Subject proposal: psql: show current user in prompt
Date
Msg-id CAFj8pRBFU-WzzQhNrwRHn67N0Ug8a9-0-9BOo69PPtcHiBDQMA@mail.gmail.com
Whole thread Raw
Responses Re: proposal: psql: show current user in prompt
List pgsql-hackers
Hi

one visitor of p2d2 (Prague PostgreSQL Developer Day) asked if it is possible to show the current role in psql's prompt. I think it is not possible, but fortunately (with some limits) almost all necessary work is done, and the patch is short.

In the assigned patch I implemented a new prompt placeholder %N, that shows the current role name.

(2023-02-03 15:52:28) postgres=# \set PROMPT1 '%n as %N at '%/%=%#
pavel as pavel at postgres=#set role to admin;
SET
pavel as admin at postgres=>set role to default;
SET
pavel as pavel at postgres=#

Comments, notes are welcome.

Regards

Pavel

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Make EXPLAIN generate a generic plan for a parameterized query
Next
From: Laurenz Albe
Date:
Subject: Re: Make EXPLAIN generate a generic plan for a parameterized query