Re: Generalized trigger function - Mailing list pgsql-novice

From Tom Lane
Subject Re: Generalized trigger function
Date
Msg-id 15606.1150561019@sss.pgh.pa.us
Whole thread Raw
In response to Generalized trigger function  ("Gang Cheng" <cg1101@gmail.com>)
List pgsql-novice
"Gang Cheng" <cg1101@gmail.com> writes:
> I'm trying to implement a generalized trigger function that can take as
> arguments the names of columns to be updated with username and timestamp of
> the INSERT/UPDATE event.

This is not possible in plpgsql, primarily because it's a strongly-typed
language and wants to know the datatypes of everything in advance.
You could do it in C for sure, and probably in some of the other PLs
that don't care about datatypes because they convert everything to
strings anyway.  If this trigger is something you intend to apply to all
your tables, for performance reasons you might want to bite the bullet
and do it in C.  There are some examples that do nearly this in
contrib/spi/.

            regards, tom lane

pgsql-novice by date:

Previous
From: "Gang Cheng"
Date:
Subject: Generalized trigger function
Next
From: Christopher Browne
Date:
Subject: Re: uh-oh