----- Original Message ----- From: "Mattias Kregert" <[EMAIL PROTECTED]> To: "Darko Prenosil" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> 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 ! ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly