Re: Trigger to run @ connection time?

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Kynn Jones <kynnjo(at)gmail(dot)com>
Cc: "pgsql-general General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger to run @ connection time?
Date: 2008-03-10 23:47:05
Message-ID: BEFA5FEC-376E-45DA-A1C8-37E0FCE2AD86@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mar 10, 2008, at 9:07 PM, Kynn Jones wrote:

> 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().

You can't define triggers on system tables.

> 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.)

I'm afraid not, although there's been mention on this ML of on
connect triggers before. Not sure whether that got solved though...

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

Closest thing I can think of is defining a table that you insert a
record in as soon as you connect and put a trigger on that.

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,47d5c63d233091216612506!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Kempter 2008-03-11 00:02:34 PostgreSQL and MOLAP ?
Previous Message John Cartwright 2008-03-10 23:15:27 Re: php pg_connect fails, pgsql works - RESOLVED