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

From Pavel Stehule
Subject Re: proposal: psql: show current user in prompt
Date
Msg-id CAFj8pRBAS6SV48eOkDv+GgdD=Pw-iTKSg+X4ZN9Th55oDfiHeA@mail.gmail.com
Whole thread Raw
In response to Re: proposal: psql: show current user in prompt  (Jelte Fennema <postgres@jeltef.nl>)
Responses Re: proposal: psql: show current user in prompt
List pgsql-hackers


čt 10. 8. 2023 v 16:31 odesílatel Jelte Fennema <postgres@jeltef.nl> napsal:
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 different creatures.

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

yes

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).

I have to recheck it

Regards

Pavel
 

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: logical decoding and replication of sequences, take 2
Next
From: Peter Smith
Date:
Subject: logicalrep_worker_launch -- counting/checking the worker limits