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

From Daniel Verite
Subject Re: passing linux user to PG server as a variable ?
Date
Msg-id e5dd8836-4eb0-4b4a-a33e-228b487a653f@manitou-mail.org
Whole thread Raw
In response to Re: passing linux user to PG server as a variable ?  (David Gauthier <davegauthierpg@gmail.com>)
List pgsql-general
    David Gauthier wrote:

> I can avoid the error by just throwing a namespace in there...
> atletx7-reg036:/home/dgauthie[ 214 ] --> setenv PGOPTIONS "-c
> 'os.user=$USER' "
> But once in, "show os.user" is undefined.

It's documented to work [1], but you need to remove these single
quotes. For instance:

$ env PGOPTIONS="-c os.user=$USER" psql -d postgres
psql (12.4 (Debian 12.4-1.pgdg90+1))
Type "help" for help.

postgres=> show "os.user";
 os.user
---------
 daniel
(1 row)

If characters needed to be quoted in the value, backslash
should be used as the quote character. Since it's also
a quote character for the shell, two levels of quoting
are needed:

$ env PGOPTIONS="-c os.user=user\\ is\\ $USER" psql -d postgres
psql (12.4 (Debian 12.4-1.pgdg90+1))
Type "help" for help.

postgres=> show "os.user";
    os.user
----------------
 user is daniel
(1 row)


[1] https://www.postgresql.org/docs/current/config-setting.html


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: https://www.manitou-mail.org
Twitter: @DanielVerite



pgsql-general by date:

Previous
From: Olivier Gautherot
Date:
Subject: Re: "Go" (lang) standard driver
Next
From: Daulat Ram
Date:
Subject: Point in time recovery