Re: proposal: psql: psql variable BACKEND_PID - Mailing list pgsql-hackers

From Andres Freund
Subject Re: proposal: psql: psql variable BACKEND_PID
Date
Msg-id 20230211210301.mfz3vwk5qe2ln22y@awork3.anarazel.de
Whole thread Raw
In response to Re: proposal: psql: psql variable BACKEND_PID  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Hi,

On 2023-02-09 10:11:21 +0100, Pavel Stehule wrote:
> first and main (for me) - I can use psql variables tab complete - just
> :B<tab> - it is significantly faster
> second - I can see all connection related information by \set
> third - there is not hook on reconnect in psql - so if you implement
> BACKEND_PID by self, you ensure to run query with pg_backend_pid() after
> any reconnect or connection change.
> 
> It is clean so you can run "select pg_backend_pid() AS "BACKEND_PID" \gset"
> and you can store it to .psqlrc. But most of the time I am in customer's
> environment, and I have the time, possibility to do a complete setup of
> .psqlrc. It looks (for me) like a generally useful feature to be
> everywhere.

I personally just solved this by using %p in PROMPT*. Not that that serves
quite the same niche.

I guess the fact that we have %p is a minor precedent of psql special casing
backend pid in psql.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Vladimir Churyukin
Date:
Subject: Re: Improving inferred query column names
Next
From: Heikki Linnakangas
Date:
Subject: Re: refactoring relation extension and BufferAlloc(), faster COPY