Re: passing linux user to PG server as a variable ? - Mailing list pgsql-general

From Ian Barwick
Subject Re: passing linux user to PG server as a variable ?
Date
Msg-id eeb0a551-98b3-cf49-5e80-46fa95c9c547@2ndquadrant.com
Whole thread Raw
In response to passing linux user to PG server as a variable ?  (David Gauthier <davegauthierpg@gmail.com>)
List 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



pgsql-general by date:

Previous
From: David Gauthier
Date:
Subject: Re: passing linux user to PG server as a variable ?
Next
From: "David G. Johnston"
Date:
Subject: Re: passing linux user to PG server as a variable ?