Search Postgresql Archives

Trigger to run @ connection time?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 figured that setting up such a trigger would be possible, based on the naive assumption that all global events of interest (e.g. the opening (or closing) of a connection to a specific database, or the creation of a new database) would correspond to an INSERT, UPDATE, or DELETE event on some system table.

So I tried to find some system table that would get modified whenever a new connection was made, but I was unsuccessful.  The closest I found was the VIEW pg_activity, and the crucial information I need from this view comes from procedures like pg_stat_get_backend_pid().

Is there a bona fide table (not a view!) that I could use to define an "on connect" trigger?  (This table would not only have to undergo some INSERT or UPDATE event at the time of the new connection, but it should also provide enough information to allow my code to determine which database is being connected to.)

If not, is there some other way to set up a trigger that

TIA!

Kynn


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux