Re: pl/pgsql trigger table attributes - Mailing list pgsql-general

From Tom Lane
Subject Re: pl/pgsql trigger table attributes
Date
Msg-id 28670.1092595843@sss.pgh.pa.us
Whole thread Raw
In response to pl/pgsql trigger table attributes  (Graeme Hinchliffe <graeme.hinchliffe@zeninternet.co.uk>)
List pgsql-general
Graeme Hinchliffe <graeme.hinchliffe@zeninternet.co.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

pgsql-general by date:

Previous
From: Richard Poole
Date:
Subject: Re: PgSQL 8.0.0 - contributed: problem compiling
Next
From: Stephan Szabo
Date:
Subject: Re: (libpq) listen/notify messages are converted to