Re: Generalized trigger function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gang Cheng" <cg1101(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Generalized trigger function
Date: 2006-06-17 16:16:59
Message-ID: 15606.1150561019@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Gang Cheng" <cg1101(at)gmail(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-06-17 16:44:49 Re: cannot access directory /pg_tblspc/*
Previous Message Gang Cheng 2006-06-17 13:08:54 Generalized trigger function