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=assignmentPerform 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 !