Re: proposal: psql: show current user in prompt

From: Kirk Wolak <wolakk(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: proposal: psql: show current user in prompt
Date: 2023-03-02 20:45:10
Message-ID: CACLU5mTnGe7FkG511uGQVm8cSk-XHZX=NsnhaaMe4AMGZu2qxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 4, 2023 at 3:33 PM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

> Hi
>
> pá 3. 2. 2023 v 21:43 odesílatel Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> napsal:
>
>>
>>
>> pá 3. 2. 2023 v 21:21 odesílatel Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> napsal:
>>
>>> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>>> > Both patches are very simple - and they use almost already prepared
>>> > infrastructure.
>>>
>>> It's not simple at all to make the psql feature depend on marking
>>> "role" as GUC_REPORT when it never has been before. That will
>>> cause the feature to misbehave when using older servers. I'm
>>> even less impressed by having it fall back on PQuser(), which
>>> would be misleading at exactly the times when it matters.
>>>
>>
>> It is a good note. This can be disabled for older servers, and maybe it
>> can introduce its own GUC (and again - it can be disallowed for older
>> servers).
>>
>
> Here is another version. For older servers it shows the string ERR0A000.
> That is ERR code of "feature is not supported"
>
>
>> My goal at this moment is to get some prototype. We can talk if this
>> feature request is valid or not, and we can talk about implementation.
>>
>> There is another possibility to directly execute "select current_user()"
>> instead of looking at status parameters inside prompt processing. It can
>> work too.
>>
>
> I tested using the query SELECT CURRENT_USER, but I don't think it is
> usable now, because it doesn't work in the broken transaction.
>
> Regards
>
> Pavel
>
>
>
>>
>> Regards
>>
>> Pavel
>>
>>
>>
>>
>>
>>> regards, tom lane
>>>
>>
I've tested this w/regards to psql. Latest commit.
It works as described. 'none' is displayed for the default role. (SET ROLE
DEFAULT), otherwise the specific ROLE is displayed.

I tried this patch on 15.2, but guc_files.c does not exist in that version,
so it did not install.
I also tried applying the %T patch, but since they touch the same file, it
would not install with it, without rebasing, repatching.

The Docs are updated, and it's a relatively contained patch.

Changed status to Ready for Committer. (100% Guessing here...)

Kirk

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-03-02 21:00:31 Re: Evaluate arguments of correlated SubPlans in the referencing ExprState
Previous Message Dean Rasheed 2023-03-02 20:32:26 Re: Add support for unit "B" to pg_size_pretty()