Обсуждение: SQL call to get pid of current connection

Поиск
Список
Период
Сортировка

SQL call to get pid of current connection

От
"David Parker"
Дата:
Is there a function call that will return the pid of the postgres process associated with the current client connection?

- DAP
----------------------------------------------------------------------------------
David Parker    Tazz Networks    (401) 709-5130
 

 

Re: SQL call to get pid of current connection

От
Bruno Wolff III
Дата:
On Thu, Jun 02, 2005 at 17:04:22 -0400,
  David Parker <dparker@tazznetworks.com> wrote:
> Is there a function call that will return the pid of the postgres
> process associated with the current client connection?

I thought I remembered seeing one, but I looked through the development
docs and didn't see a function or a GUC variable with that information.
It wouldn't be too hard to write a C or Perl function to get that
information.

Re: SQL call to get pid of current connection

От
"David Parker"
Дата:
Yeah, simple enough. I just wanted to make sure I wasn't duplicating
something that was already there.

Thanks.

- DAP

>-----Original Message-----
>From: Bruno Wolff III [mailto:bruno@wolff.to]
>Sent: Thursday, June 02, 2005 6:02 PM
>To: David Parker
>Cc: postgres general
>Subject: Re: SQL call to get pid of current connection
>
>On Thu, Jun 02, 2005 at 17:04:22 -0400,
>  David Parker <dparker@tazznetworks.com> wrote:
>> Is there a function call that will return the pid of the postgres
>> process associated with the current client connection?
>
>I thought I remembered seeing one, but I looked through the
>development docs and didn't see a function or a GUC variable
>with that information.
>It wouldn't be too hard to write a C or Perl function to get
>that information.
>

Re: SQL call to get pid of current connection

От
Michael Fuhr
Дата:
On Thu, Jun 02, 2005 at 05:02:14PM -0500, Bruno Wolff III wrote:
> On Thu, Jun 02, 2005 at 17:04:22 -0400,
>   David Parker <dparker@tazznetworks.com> wrote:
> > Is there a function call that will return the pid of the postgres
> > process associated with the current client connection?
>
> I thought I remembered seeing one, but I looked through the development
> docs and didn't see a function or a GUC variable with that information.

Are you looking for pg_backend_pid()?  It's documented in the
"Statistics Collector" section of the "Monitoring Database Activity"
chapter; it's been around since 7.3:

http://www.postgresql.org/docs/7.3/interactive/release-7-3.html
http://www.postgresql.org/docs/7.3/interactive/monitoring-stats.html
http://www.postgresql.org/docs/7.4/interactive/monitoring-stats.html
http://www.postgresql.org/docs/8.0/interactive/monitoring-stats.html

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

Re: SQL call to get pid of current connection

От
Tom Lane
Дата:
"David Parker" <dparker@tazznetworks.com> writes:
> Is there a function call that will return the pid of the postgres
> process associated with the current client connection?

libpq makes this available as PQbackendPID().  Dunno about other
client libraries.

            regards, tom lane

Re: SQL call to get pid of current connection

От
"David Parker"
Дата:
That certainly looks like it! Thanks!

- DAP

>-----Original Message-----
>From: Michael Fuhr [mailto:mike@fuhr.org]
>Sent: Thursday, June 02, 2005 8:47 PM
>To: Bruno Wolff III; David Parker; postgres general
>Subject: Re: [GENERAL] SQL call to get pid of current connection
>
>On Thu, Jun 02, 2005 at 05:02:14PM -0500, Bruno Wolff III wrote:
>> On Thu, Jun 02, 2005 at 17:04:22 -0400,
>>   David Parker <dparker@tazznetworks.com> wrote:
>> > Is there a function call that will return the pid of the postgres
>> > process associated with the current client connection?
>>
>> I thought I remembered seeing one, but I looked through the
>> development docs and didn't see a function or a GUC variable
>with that information.
>
>Are you looking for pg_backend_pid()?  It's documented in the
>"Statistics Collector" section of the "Monitoring Database Activity"
>chapter; it's been around since 7.3:
>
>http://www.postgresql.org/docs/7.3/interactive/release-7-3.html
>http://www.postgresql.org/docs/7.3/interactive/monitoring-stats.html
>http://www.postgresql.org/docs/7.4/interactive/monitoring-stats.html
>http://www.postgresql.org/docs/8.0/interactive/monitoring-stats.html
>
>--
>Michael Fuhr
>http://www.fuhr.org/~mfuhr/
>