From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: proposal: psql: show current user in prompt |
Date: | 2023-02-03 19:57:40 |
Message-ID: | CAFj8pRAzUd+JKDP7isokYZapbvSuXmsh8FaE1qF+Hh8DguRDPg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
pá 3. 2. 2023 v 20:42 odesílatel Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
napsal:
>
>
> On Fri, Feb 3, 2023 at 9:56 AM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
>> 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
>>
>
> This patch is cluttered with the BACKEND_PID patch and some guc_tables.c
> stuff that I don't think is related.
>
I was little bit lazy, I am sorry. I did it in one my experimental branch.
Both patches are PoC, and there are not documentation yet. I will separate
it.
> We'd have to document the %N.
>
> I think there is some value here for people who have to connect as several
> different users (tech support), and need a reminder-at-a-glance whether
> they are operating in the desired role. It may be helpful in audit
> documentation as well.
>
yes, I agree so it can be useful - it is not my idea - and it is maybe
partially deduced from some other databases.
Both patches are very simple - and they use almost already prepared
infrastructure.
Regards
Pavel
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-02-03 20:11:22 | Re: Make EXPLAIN generate a generic plan for a parameterized query |
Previous Message | Corey Huinker | 2023-02-03 19:41:56 | Re: proposal: psql: show current user in prompt |