Re: session id and global storage

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: session id and global storage
Дата
Msg-id 20345.1151590254@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: session id and global storage  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> Rodrigo De Leon wrote:
>> You could do this:
>> 
>> SELECT procpid||' '||backend_start
>> FROM pg_stat_activity
>> WHERE datname = current_database()
>> AND usename = session_user
>> AND client_addr = inet_client_addr()
>> AND client_port = inet_client_port();

> That's pretty roundabout.

Indeed.  Use pg_backend_pid() instead:

SELECT whatever FROM pg_stat_activity WHERE procpid = pg_backend_pid();

A difficulty with this in existing releases is that pg_stat_activity
lags behind reality, so that you won't see your session listed in it
until you've been connected at least half a second or so.  8.2 won't
have that problem.
        regards, tom lane


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

Предыдущее
От: Thomas Hallgren
Дата:
Сообщение: Re: [GENERAL] UUID's as primary keys
Следующее
От: "Hiroshi Saito"
Дата:
Сообщение: Re: Compilatiuon of source code for windows