Re: Trigger to run @ connection time? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Trigger to run @ connection time?
Date
Msg-id F9628CE2-56A5-4EFA-9281-E834904DD5B6@solfertje.student.utwente.nl
Whole thread Raw
In response to Re: Trigger to run @ connection time?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Trigger to run @ connection time?
List pgsql-general
On Mar 11, 2008, at 10:28 PM, Tom Lane wrote:

> An ON CONNECT trigger enforced by the database seems a bit scary to
> me.
> If it's broken, how you gonna get into the DB to fix it?
>
>             regards, tom lane

If creating the trigger wouldn't be possible from within the database
that it's defined for (which would be strange anyway as far as I'm
concerned, since you are already connected at that point and thus
missed an opportunity to fire that trigger) this shouldn't be a problem.

To put that into an SQL statement, something like:
#template1 $ CREATE TRIGGER my_database_connect_trg BEFORE CONNECT ON
my_database EXECUTE PROCEDURE my_database_setup()

Although of course that begs the question where that procedure would
be stored; Rather not in template1, I suppose! This points to another
problem with ON CONNECT triggers, you'll likely need to be connected
to reach the stored procedure that the trigger calls! A nice chicken
and egg problem, with some scope issues on the horizon...

Regards,
Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,47d85f64233091819183316!



pgsql-general by date:

Previous
From: "Tri Quach"
Date:
Subject: Re: Relocation error:/usr/lib/libpq.so.5:undefinedsymbol: krb5_cc_get_principal
Next
From: Berend Tober
Date:
Subject: Re: Trigger to run @ connection time?