Re: passing linux user to PG server as a variable ?

From: Ian Barwick <ian(dot)barwick(at)2ndquadrant(dot)com>
To: David Gauthier <davegauthierpg(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: passing linux user to PG server as a variable ?
Date: 2020-08-18 01:02:48
Message-ID: eeb0a551-98b3-cf49-5e80-46fa95c9c547@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2020/08/18 4:52, David Gauthier wrote:

> Thanks in advance for any replies/ideas !

You could hackily repurpose the "application_name" connection parameter:

$ whoami
ibarwick
$ psql -d "host=localhost dbname=postgres user=postgres application_name=$USER"
psql (14devel)
Type "help" for help.

postgres=# SELECT application_name FROM pg_stat_activity WHERE pid=pg_backend_pid();
application_name
------------------
ibarwick
(1 row)

Disclaimer: I have not applied any thought to any possible pitfalls and side
effects resulting from this approach.

Regards

Ian Barwick

--
Ian Barwick https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-08-18 01:03:11 Re: passing linux user to PG server as a variable ?
Previous Message David Gauthier 2020-08-18 00:46:06 Re: passing linux user to PG server as a variable ?