Re: proposal: psql: psql variable BACKEND_PID

From: Andres Freund <andres(at)anarazel(dot)de>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: proposal: psql: psql variable BACKEND_PID
Date: 2023-02-11 21:03:01
Message-ID: 20230211210301.mfz3vwk5qe2ln22y@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2023-02-11 21:03:56 Re: refactoring relation extension and BufferAlloc(), faster COPY
Previous Message Vladimir Churyukin 2023-02-11 20:47:04 Re: Improving inferred query column names