Re: Triggers and Multiple Schemas.

From: Richard Huxton <dev(at)archonet(dot)com>
To: Paul Newman <paul(dot)newman(at)tripoint(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Triggers and Multiple Schemas.
Date: 2006-03-08 20:25:37
Message-ID: 440F3DC1.4030907@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Paul Newman wrote:
> Hi,
>
> We run with multiple identical schemas in our db. Each schema actually
> represents a clients db. What we'd like to do is have a common schema
> where trigger functions and the like are held whilst each trigger
> defined against the tables is in there own particular schema. This would
> mean that there is one function per trigger type to maintain.
>
>
>
> However at the moment we are placing the trigger functions within each
> schema along with trigger itself. The reason is that we don't know of a
> function or a variable that says "Give me the schema of the trigger that
> is calling this function".

You can pass a parameter into the function from the trigger definition.
That's probably the easiest way. In plpgsql, parameters appear in
TG_ARGV[]. Or, you could reverse-engineer the schema-name from TG_RELID.

http://www.postgresql.org/docs/8.1/static/plpgsql-trigger.html

HTH
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2006-03-08 20:29:52 Re: Tsearch2 cache lookup problem
Previous Message Scott Marlowe 2006-03-08 20:22:03 Re: Triggers and Multiple Schemas.