Re: pl/pgsql trigger table attributes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Graeme Hinchliffe <graeme(dot)hinchliffe(at)zeninternet(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pl/pgsql trigger table attributes
Date: 2004-08-15 18:50:43
Message-ID: 28670.1092595843@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Graeme Hinchliffe <graeme(dot)hinchliffe(at)zeninternet(dot)co(dot)uk> writes:
> The way I have written the pl/pgsql function is specific to the specific
> table it is attached to, what I would like is a pl/pgsql function which
> could be attached to any table to catch the changes.

> Is there a way that a pl/pgsql function can determine the names of the
> attributes in a table?

This is somewhere between impractical and impossible in plpgsql; that
language is not designed to handle access to fields with
dynamically-determined names and datatypes.

You could probably do it in pltcl, but if I were you I'd skip the PLs
and go straight to coding it in C, because that's likely where you're
going to end up anyway for performance reasons. There are some triggers
in the contrib/ tree that do roughly similar things; perhaps you could
use them as prototypes.

Also consider whether you aren't re-inventing the wheel. It sounds to
me like what you really want is a replication system ... have you looked
at Slony?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2004-08-15 18:51:20 Re: (libpq) listen/notify messages are converted to
Previous Message Richard Poole 2004-08-15 18:45:12 Re: PgSQL 8.0.0 - contributed: problem compiling