From: | "Mattias Kregert" <mattias(at)kregert(dot)se> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Q: Executing functions at connect/disconnect? |
Date: | 2003-07-03 15:28:48 |
Message-ID: | 002a01c34177$ccf926e0$09000a0a@kregert.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is there a way to automagically execute a function at connect/disconnect?
I was thinking about the possibility to have some kind of automatic cleanup when the client disconnects.
I would like to:
- Register a session id at connect time. (INSERT into sessions(sessId, user, host, ...) ...)
- Use the session id to mark some objects as "in use" (UPDATE tbl SET usedBy=<sessionid> WHERE...).
- Automatically update all rows with this session-id as "unused" when the client disconnects from the backend.
I can not trust the client to exit cleanly all the time, so the cleanup function must be executed by the backend when the connection is lost. The client could exit nicely or crash or have a power failure or whatever. I don't expect bad things to happen very often, but if/when they do i want to be sure that no rows are "in use".
Any ideas?
/Mattias
From | Date | Subject | |
---|---|---|---|
Next Message | andy morrow | 2003-07-03 16:37:57 | Re: problems with pg_restore to 7.3.3 db |
Previous Message | Rory Campbell-Lange | 2003-07-03 14:39:20 | Rollback for aborted function? |