Re: Trigger to run @ connection time?

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger to run @ connection time?
Date: 2008-03-12 14:43:15
Message-ID: efb8dced2b33305eceef4fb084e53f92@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

> Hi! I want to set up a trigger (somehow) that, whenever someone connects
> database my_db, will fire and thereby run a stored PLPERL procedure
> perl_setup() in the new connection's environment. (BTW, this procedure adds
> useful definitions, mostly subs, to Perl's main package. This needs to be
> done for each connection, because such modifications of package main do not
> persist from one session to the next.)

I think you are going about this the wrong way. Create a hook in each plperl
func that does the initial setup for you as needed. Simply store a
value in $_SHARED indicating whether it has already run or not for that
session. This also avoid any overhead at all of calling perl_setup() if
the connection in question is never going to use plperl, or even if it is
going to use plperl but does not need perl_setup().

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200803121042
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkfX6+0ACgkQvJuQZxSWSsiFdQCg4WGmB4+InrL7E+7c8Tq82lFy
TFcAn2lQfSXJwO8LUQ9vZPf9ZStLdVHW
=R5fK
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-03-12 15:07:29 Re: ERROR: text search configuration "pg_catalog.english" does not exist
Previous Message Karsten Hilbert 2008-03-12 14:08:50 Re: Trigger to run @ connection time?