Re: Feature: psql - display current search_path in prompt

From: Florents Tselai <florents(dot)tselai(at)gmail(dot)com>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: Lauri Siltanen <lauri(dot)siltanen(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Feature: psql - display current search_path in prompt
Date: 2025-06-09 15:54:16
Message-ID: 5CBFB667-3EB3-4AF8-9E18-36B3AF79BBB8@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 8 Jun 2025, at 2:36 AM, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:
>
> On Sat, 7 Jun 2025 at 20:52, Lauri Siltanen <lauri(dot)siltanen(at)gmail(dot)com> wrote:
>> I need to switch search_paths often. It would be tremendously helpful to see the current search_path in the prompt.
>
> That feature should be pretty easy to implement, now that search_path
> is marked as GUC_REPORT in PG18. Basically you need to use
> PQparameterStatus like we do for session_authorization[1][2].
>
> [1]: https://github.com/postgres/postgres/blob/73e26cbeb5927053eea4e209e5eda34a30c353f1/src/bin/psql/prompt.c#L166-L169
> [2]: https://github.com/postgres/postgres/blob/73e26cbeb5927053eea4e209e5eda34a30c353f1/src/bin/psql/common.c#L2508-L2520
>
>

Here’s a quick attempt that makes %S substitue for a search_path
Like
\set PROMPT1 'user:%n search_path: %S'

Attachment Content-Type Size
0001-Make-S-available-in-psql-PROMPTs-to-indicate-the-cur.patch application/octet-stream 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vitaly Davydov 2025-06-09 16:09:58 Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
Previous Message Michael Banck 2025-06-09 15:40:50 Re: Cleaning up historical portability baggage