Re: proposal: psql: psql variable BACKEND_PID

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: proposal: psql: psql variable BACKEND_PID
Дата
Msg-id CADkLM=d2NXhWeGkQnksAiabuxM4m6q9oM6JMM8NTs6hB=h=9+w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: proposal: psql: psql variable BACKEND_PID  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: proposal: psql: psql variable BACKEND_PID  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: proposal: psql: psql variable BACKEND_PID  ("Daniel Verite" <daniel@manitou-mail.org>)
Re: proposal: psql: psql variable BACKEND_PID  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
with doc and unsetting variable

Regards

Pavel


Patch applies.

Manually testing confirms that it works, at least for the connected state. I don't actually know how get psql to invoke DISCONNECT, so I killed the dev server and can confirm

[222281:14:57:01 EST] corey=# \echo :BACKEND_PID
222281
[222281:14:57:04 EST] corey=# select 1;
FATAL:  terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
Time: 1.554 ms
[:15:02:31 EST] !> \echo :BACKEND_PID
:BACKEND_PID

Clearly, it is hard to write a regression test for an externally volatile value. `SELECT sign(:BACKEND_PID)` would technically do the job, if we're striving for completeness.

The inability to easily DISCONNECT via psql, and the deleterious effect that would have on other regression tests tells me that we can leave that one untested. 

Notes:

This effectively makes the %p prompt (which I use in the example above) the same as %:BACKEND_PID: and we may want to note that in the documentation.

Do we want to change %p to pull from this variable and save the snprintf()? Not a measurable savings, more or a don't-repeat-yourself thing.

In the varlistentry, I suggest we add "This variable is unset when the connection is lost." after "but can be changed or unset.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: proposal: psql: show current user in prompt
Следующее
От: Andrey Borodin
Дата:
Сообщение: Re: How to implement read operations for my own access method?