Re: Q: Executing functions at connect/disconnect?

From: Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Q: Executing functions at connect/disconnect?
Date: 2003-07-03 18:29:28
Message-ID: 200307032029.28638.darko.prenosil@finteh.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday 03 July 2003 17:28, Mattias Kregert wrote:
> 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?
>
I had same question before about two months, but I'm afraid, there is no
simple way. I tried to add some code to the "backend", but have broken all my
teeth trying to get it work. Such code goes deeply into PostgreSQL internals,
and I'm afraid only few people can do it(Tom,Bruce,Jan...).
Hoverer if You succeed ,please let me know because I'm interested in this
feature too.

Regards !

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darko Prenosil 2003-07-03 18:33:07 Re: Q: Executing functions at connect/disconnect?
Previous Message Nitish Korla 2003-07-03 17:48:00 Unsubscribe