Re: get username of user calling function?

Поиск
Список
Период
Сортировка
От George Nychis
Тема Re: get username of user calling function?
Дата
Msg-id 45E70B04.9040206@cmu.edu
обсуждение исходный текст
Ответ на Re: get username of user calling function?  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Ответы Re: get username of user calling function?  ("David Legault" <legault.david@gmail.com>)
Список pgsql-general

A. Kretschmer wrote:
> You can use the current_user - variable. Select current_user;

I'm trying to create a function in which users can only kill their own processes, it works
perfectly if i hardcode a username in such as this:
CREATE FUNCTION kill_process(integer) RETURNS boolean
AS 'select pg_cancel_backend(procpid)
     FROM (SELECT procpid FROM pg_stat_activity WHERE procpid=$1 and usename=''gnychis'')
AS kill;'
LANGUAGE SQL SECURITY DEFINER;

But if i try to replace usename=''gnychis'' with usename=current_user it no longer works.

Any ideas?

- George

В списке pgsql-general по дате отправления:

Предыдущее
От: Vivek Khera
Дата:
Сообщение: Re: How often do I need to reindex tables?
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: US Highschool database in postgres