How to get the session user in a C user defined function

Started by John Leiseboerover 10 years ago2 messagesgeneral
Jump to latest
#1John Leiseboer
jleiseboer@bigpond.com

I would like to get the session_user into a C char[] in a C language UDF. I have found what appears to be a function returning a Datum type called session_user, but I'm having trouble working out how to call it from within my C function. Can anyone provide some advice on how to do this?

John
Email: jleiseboer@bigpond.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Michael Paquier
michael@paquier.xyz
In reply to: John Leiseboer (#1)
Re: How to get the session user in a C user defined function

On Thu, Oct 15, 2015 at 2:38 PM, John Leiseboer <jleiseboer@bigpond.com> wrote:

I would like to get the session_user into a C char[] in a C language UDF. I have found what appears to be a function returning a Datum type called session_user, but I'm having trouble working out how to call it from within my C function. Can anyone provide some advice on how to do this?

What you are looking for is in miscadmin.h:
username = GetUserNameFromId(GetSessionUserId());
Regards,
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general