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

From Peter Eisentraut
Subject Re: proposal: psql: psql variable BACKEND_PID
Date
Msg-id 1568349c-b6d9-2031-0820-904fa8dbeda3@enterprisedb.com
Whole thread Raw
In response to Re: proposal: psql: psql variable BACKEND_PID  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: psql: psql variable BACKEND_PID
Re: proposal: psql: psql variable BACKEND_PID
List pgsql-hackers
On 09.02.23 10:11, 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.

But what do you need the backend PID for in the first place?

Of course, you might want to use it to find your own session in 
pg_stat_activity or something like that, but then you're already in a 
query and can use pg_backend_pid().  What do you need the backend PID 
for outside of such a query?




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ExecRTCheckPerms() and many prunable partitions (sqlsmith)
Next
From: Tom Lane
Date:
Subject: Re: ERROR: permission info at index 1 ....