Re: Q: Executing functions at connect/disconnect? - Mailing list pgsql-general

From Darko Prenosil
Subject Re: Q: Executing functions at connect/disconnect?
Date
Msg-id 000701c34191$8fef16a0$538abfd5@darko
Whole thread Raw
In response to Q: Executing functions at connect/disconnect?  ("Mattias Kregert" <mattias@kregert.se>)
List pgsql-general
----- Original Message -----
From: "Mattias Kregert" <mattias@kregert.se>
To: "Darko Prenosil" <darko.prenosil@finteh.hr>
Cc: <pgsql-general@postgresql.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 !


pgsql-general by date:

Previous
From:
Date:
Subject: ANNOUNCING: Rekall V2.0.0 for Linux/UNIX, Windows, and the Sharpe family of Linux PDAs
Next
From: "Darko Prenosil"
Date:
Subject: Re: Q: Executing functions at connect/disconnect?