Re: passing linux user to PG server as a variable ?
| От | Daniel Verite |
|---|---|
| Тема | Re: passing linux user to PG server as a variable ? |
| Дата | |
| Msg-id | e5dd8836-4eb0-4b4a-a33e-228b487a653f@manitou-mail.org обсуждение исходный текст |
| Ответ на | Re: passing linux user to PG server as a variable ? (David Gauthier <davegauthierpg@gmail.com>) |
| Список | 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 по дате отправления: