From: | David Gauthier <davegauthierpg(at)gmail(dot)com> |
---|---|
To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | passing linux user to PG server as a variable ? |
Date: | 2020-08-17 19:52:53 |
Message-ID: | CAMBRECCo03UqbEdKLbgzq7UpApOLNjiHrGx+iumcT5OqMtQNSA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
9.6.7 on linux
I need to insert the linux username of a user on the client side into a col
using an insert statement. I realize that the server knows nothing about
who the linux user was on a client, but I was thinking that I might be able
to pass that in somehow through a variable.
Looking at psql command line options, I see "-v" (lowercase) which is
described as...
-v assignment
--set=assignment
--variable=assignment
Perform a variable assignment, like the \set meta-command. Note that you
must separate name and value, if any, by an equal sign on the command line.
To unset a variable, leave off the equal sign. To set a variable with an
empty value, use the equal sign but leave off the value. These assignments
are done during a very early stage of start-up, so variables reserved for
internal purposes might get overwritten later.
So I tried that without success. "-v sysinfo.osuser=foo" failed the
connect with..."psql: could not set variable "sysinfo.osuser""
Next I tried..."-v osuser=foo"This didn't fail the connect, but once I got
in..."show osuser" gave... "ERROR: unrecognized configuration parameter
"osuser""
I don't even know if this approach has any legs or not given what I want to
do. I'm just trying ideas hoping something will work. But if it might
work, is this setting a variable like this something that can be run
unconditionally whenever a linux user connects to the DB on a client server
? If so, where would this be inserved in the connect process ? TO get the
linux user, I would just tap $USER or backtick `whoami` or something like
that.
Of course if there is another way to accomplish my goal, I'm all ears :-)
Thanks in advance for any replies/ideas !
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Clarke | 2020-08-17 20:05:52 | Re: passing linux user to PG server as a variable ? |
Previous Message | David G. Johnston | 2020-08-16 17:45:36 | Re: Bytea Example |