Re: Q: Executing functions at connect/disconnect?

From: "Darko Prenosil" <Darko(dot)Prenosil(at)finteh(dot)hr>
To: "Mattias Kregert" <mattias(at)kregert(dot)se>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Q: Executing functions at connect/disconnect?
Date: 2003-07-03 18:33:07
Message-ID: 000701c34191$8fef16a0$538abfd5@darko
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


----- Original Message -----
From: "Mattias Kregert" <mattias(at)kregert(dot)se>
To: "Darko Prenosil" <darko(dot)prenosil(at)finteh(dot)hr>
Cc: <pgsql-general(at)postgresql(dot)org>
Sent: Friday, July 04, 2003 6:08 PM
Subject: Re: [GENERAL] Q: Executing functions at connect/disconnect?

Just as i thought...
I have only one solution then; to have a cleanup function which is executed
every now and then...

Cleanup function:
1. Look in the Session table to find out which sessions are registered.
2. Determine if some of these sessions are "dead".
3. Update all those items/objects/rows held by the dead session(s) as
"unused".
4. Unregister the session.

I see two problems with this:
A. How do I know if a session is dead or still connected? I need to get that
information from the postmaster or my backend in some way, but I don't know
how to do that.

You can get backend PID using:
SELECT pg_backend_pid();

and see all active connections using:
SELECT * FROM pg_stat_activity;

Hope that You are using 7.x version of PostgreSQL, I do not know exactly
which version introduced statistic collector.

Regards !

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Darko Prenosil 2003-07-03 18:37:08 Re: Q: Executing functions at connect/disconnect?
Previous Message Darko Prenosil 2003-07-03 18:29:28 Re: Q: Executing functions at connect/disconnect?