Re: Server-side hooks for user session start and session end - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Server-side hooks for user session start and session end
Date
Msg-id CAFj8pRAPc=dD4escQDogunekVA4e7Cge99-ShRPDVonP8psRgg@mail.gmail.com
Whole thread Raw
In response to Re: Server-side hooks for user session start and session end  (Nikolai Zhubr <n-a-zhubr@yandex.ru>)
Responses Re: Server-side hooks for user session start and session end
List pgsql-general


2015-09-26 19:53 GMT+02:00 Nikolai Zhubr <n-a-zhubr@yandex.ru>:
Hi Pavel,
26.09.2015 19:26, Pavel Stehule wrote:
[...]
This cannot be solved without patching PostgreSQL source code :( . There
are not good hooks for custom extension. Patch is relative simple, but I
cannot to publish it.

Ok, I see. Creating such a patch might be not very hard actually.
But living with custom-patched server could cause massive pain later...

You have to modify main loop in src/backend/tcop/postgres.c file. Login
point can be immediately before loop. Logout point can be joined to
'X',EOF message.

Thanks for the hint, I've noticed this loop while searching for some more 'regular' methods.

Attention - there are some corner case, what are necessary to solve -
mainly how to handle exceptions in login/logout procedures.

Right. And I'd guess that might be the reason for not implementing such thing in upstream (yet) - the lack of proper context for exceptions and such.

p.s. I understand so this hack is necessary for porting older
application from other databases, but I am not sure if it is a good idea
to use it. Not all tasks can be solved well in database.

No, the application in question has been running on top of postgres almost from its very start and for quite some years successfully now, it definitely does not contain anything foreign to postgres.
And the events of session start and session end would seem quite generic and usefull anyway?

I don't know. I am pretty sceptical - from my experience this request was related to unhappy designed projects.

Pavel

 



Thank you,
Nikolai


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Nikolai Zhubr
Date:
Subject: Re: Server-side hooks for user session start and session end
Next
From: Tom Lane
Date:
Subject: Re: Server-side hooks for user session start and session end