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

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: John Leiseboer <jleiseboer(at)bigpond(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to get the session user in a C user defined function
Date: 2015-10-15 05:39:06
Message-ID: CAB7nPqQdMGbY+WEWp684gpz9pz8YzhBmSoL-+hA=ys4OZwKRmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 15, 2015 at 2:38 PM, John Leiseboer <jleiseboer(at)bigpond(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lele Gaifax 2015-10-15 06:48:35 Re: Understanding "seq scans"
Previous Message John Leiseboer 2015-10-15 05:38:13 How to get the session user in a C user defined function