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

From Jelte Fennema
Subject Re: proposal: psql: show current user in prompt
Date
Msg-id CAGECzQQOxQC-Zix5rDj7tc1AiAGy8RJOc3cOwmKcH_kKzfZ0+g@mail.gmail.com
Whole thread Raw
In response to Re: proposal: psql: show current user in prompt  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: psql: show current user in prompt
List pgsql-hackers
On Thu, 10 Aug 2023 at 14:44, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> čt 10. 8. 2023 v 14:05 odesílatel Jelte Fennema <postgres@jeltef.nl> napsal:
>> That it is not rolled-back
>> in a case like this?
>>
>> BEGIN;
>> \set PROMPT '%N'
>> ROLLBACK;
>
>
> surely not.
>
> \set is client side setting, and it is not transactional. Attention - "\set" and "set" commands are absolutely
differentcreatures. 

To clarify: I agree it's the desired behavior that \set is not rolled back.

> It Would be strange (can be very messy) if I had a message like "cannot set a prompt, because you should do ROLLBACK
first"

This was a very helpful sentence for my understanding. To double check
that I'm understanding you correctly. This is the kind of case that
you're talking about.

postgres=# BEGIN;
postgres=# SELECT some syntax error;
ERROR:  42601: syntax error at or near "some"
postgres=# \set PROMPT '%N'
ERROR:  25P02: current transaction is aborted, commands ignored until
end of transaction block

I agree that it should not throw an error like that. So indeed a
dedicated message type is needed for psql too. Because any query will
cause that error.

But afaict there's no problem with using pqParseInput3() and
PQexecFinish() even if the message isn't handled as part of the
transaction. Some other messages that pqParseInput3 handles which are
not part of the transaction are 'N' (Notice) and 'K' (secret key).



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [PoC] pg_upgrade: allow to upgrade publisher node
Next
From: Nazir Bilal Yavuz
Date:
Subject: Add PG CI to older PG releases