pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
getting pid of backend
6+ messages / 5 participants
[nested] [flat]

* getting pid of backend
@ 2002-03-05 17:52 Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 18:21 ` Re: getting pid of backend Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Kovacs Zoltan @ 2002-03-05 17:52 UTC (permalink / raw)
  To: pgsql-sql

Is there a way to read the pid of the actual backend from SQL? I know a
dirty workaround: 

setting debug=2, log_pid=yes in postgresql.conf;

writing a function doing this:

executing a 'SELECT a_generated_random_number';
while not found pid
 reading from the postmaster log waiting for a_generated_random_number.

Is there an easier method?

-- 
                         Kov\'acs, Zolt\'an
                         kovacsz@pc10.radnoti-szeged.sulinet.hu
                         http://www.math.u-szeged.hu/~kovzol
                         ftp://pc10.radnoti-szeged.sulinet.hu/home/kovacsz





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: getting pid of backend
  2002-03-05 17:52 getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
@ 2002-03-05 18:21 ` Josh Berkus <josh@agliodbs.com>
  2002-03-05 22:49   ` Re: getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  0 siblings, 1 reply; 6+ messages in thread

From: Josh Berkus @ 2002-03-05 18:21 UTC (permalink / raw)
  To: Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>; pgsql-sql

Kovacs,

> Is there an easier method?

Much easier.  Take a look at $PGDATA/postmaster.pid

-Josh



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: getting pid of backend
  2002-03-05 17:52 getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 18:21 ` Re: getting pid of backend Josh Berkus <josh@agliodbs.com>
@ 2002-03-05 22:49   ` Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 23:34     ` Re: getting pid of backend Bruce Momjian <pgman@candle.pha.pa.us>
  2002-03-05 23:37     ` Re: getting pid of backend Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 6+ messages in thread

From: Kovacs Zoltan @ 2002-03-05 22:49 UTC (permalink / raw)
  To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql

On Tue, 5 Mar 2002, Josh Berkus wrote:

> Kovacs,
> 
> > Is there an easier method?
> 
> Much easier.  Take a look at $PGDATA/postmaster.pid

I mean the current pid number of the actual connection. Not the postmaster
process, I need the pid of the currently running postgres. :-)

Regards,
                         Kov\'acs, Zolt\'an
                         kovacsz@pc10.radnoti-szeged.sulinet.hu
                         http://www.math.u-szeged.hu/~kovzol
                         ftp://pc10.radnoti-szeged.sulinet.hu/home/kovacsz




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: getting pid of backend
  2002-03-05 17:52 getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 18:21 ` Re: getting pid of backend Josh Berkus <josh@agliodbs.com>
  2002-03-05 22:49   ` Re: getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
@ 2002-03-05 23:34     ` Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 6+ messages in thread

From: Bruce Momjian @ 2002-03-05 23:34 UTC (permalink / raw)
  To: Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>; +Cc: Josh Berkus <josh@agliodbs.com>; pgsql-sql

Kovacs Zoltan wrote:
> On Tue, 5 Mar 2002, Josh Berkus wrote:
> 
> > Kovacs,
> > 
> > > Is there an easier method?
> > 
> > Much easier.  Take a look at $PGDATA/postmaster.pid
> 
> I mean the current pid number of the actual connection. Not the postmaster
> process, I need the pid of the currently running postgres. :-)

You are going to love this one:
	
	test=> create function getpid() returns int as '/shlib/libc.so',
 	    'getpid' language c;
	CREATE
	test=> select getpid();
	 getpid 
	--------
	   2971
	(1 row)

You may need to modify the libc.so path.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: getting pid of backend
  2002-03-05 17:52 getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 18:21 ` Re: getting pid of backend Josh Berkus <josh@agliodbs.com>
  2002-03-05 22:49   ` Re: getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
@ 2002-03-05 23:37     ` Tom Lane <tgl@sss.pgh.pa.us>
  2002-03-06 10:46       ` Re: getting pid of backend Laszlo Tibor <ltibor@mail.tiszanet.hu>
  1 sibling, 1 reply; 6+ messages in thread

From: Tom Lane @ 2002-03-05 23:37 UTC (permalink / raw)
  To: Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>; +Cc: Josh Berkus <josh@agliodbs.com>; pgsql-sql

Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu> writes:
> I mean the current pid number of the actual connection. Not the postmaster
> process, I need the pid of the currently running postgres. :-)

I don't believe it's available as a SQL query, but libpq can tell you
what it is.

Probably a more interesting question is "why do you want to know?".
I can't offhand think of a really good reason to use the backend pid
for anything on the client side, other than distinguishing self-notifies
from other notifies, which is not something you can do at the SQL level
anyway.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: getting pid of backend
  2002-03-05 17:52 getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 18:21 ` Re: getting pid of backend Josh Berkus <josh@agliodbs.com>
  2002-03-05 22:49   ` Re: getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2002-03-05 23:37     ` Re: getting pid of backend Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-03-06 10:46       ` Laszlo Tibor <ltibor@mail.tiszanet.hu>
  0 siblings, 0 replies; 6+ messages in thread

From: Laszlo Tibor @ 2002-03-06 10:46 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>; +Cc: Josh Berkus <josh@agliodbs.com>; pgsql-sql

> Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu> writes:
> > I mean the current pid number of the actual connection. Not the
> postmaster
> > process, I need the pid of the currently running postgres. :-)
>
> I don't believe it's available as a SQL query, but libpq can tell you
> what it is.
>
> Probably a more interesting question is "why do you want to know?".
> I can't offhand think of a really good reason to use the backend pid
> for anything on the client side, other than distinguishing self-notifies
> from other notifies, which is not something you can do at the SQL level
> anyway.
>
> 			regards, tom lane

We need the backend's pid in the backend side. The backend's pid is good to
figure out the client ip address and good for logging.

We need to log the connections and the Win32 exe-s to determine the
ownership relations between backends and programs. Unfortunately, there are
backends without programs, eating server resources in our production system.

Plus we need to connect the logs to existing user and system dictionary data
in the database so we want to log into database tables.

Do you think it's a silly thing?


Regards, Tibor Laszlo
ltibor@mail.tiszanet.hu




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-03-06 10:46 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-05 17:52 getting pid of backend Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
2002-03-05 18:21 ` Josh Berkus <josh@agliodbs.com>
2002-03-05 22:49   ` Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
2002-03-05 23:34     ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-03-05 23:37     ` Tom Lane <tgl@sss.pgh.pa.us>
2002-03-06 10:46       ` Laszlo Tibor <ltibor@mail.tiszanet.hu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox