From: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgresql(dot)org, Tino Wildenhain <tino(at)wildenhain(dot)de>, David Fetter <david(at)fetter(dot)org> |
Subject: | Re: Auto-updated fields |
Date: | 2009-01-22 17:33:20 |
Message-ID: | 200901221233.21340.xzilla@users.sourceforge.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wednesday 21 January 2009 20:21:41 Bruce Momjian wrote:
> Alvaro Herrera wrote:
> > Robert Treat wrote:
> > > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote:
> > > > David Fetter wrote:
> >
> > Ref: http://archives.postgresql.org/pgsql-hackers/2008-05/msg00198.php
> >
> > > > > 1. Create a generic (possibly overloaded) trigger function,
> > > > > bundled with PostgreSQL, which sets a field to some value. For
> > > > > example, a timestamptz version might set the field to now().
> > > >
> > > > Having the pre defined triggers at hand could be useful, especially
> > > > for people not writing triggers so often to get used to it but I'm
> > > > really not happy with the idea of magic preprocessing.
> > >
> > > I have a generic version of this in pagila.
> >
> > Now that we have a specific file in core for generic triggers (right now
> > with a single one), how about adding this one to it?
>
> Any progress on this? TODO?
I think this is a TODO, but not sure who is working on it or what needs to be
done. The generic version in pagila is perhaps not generic enough:
CREATE FUNCTION last_updated() RETURNS trigger
AS $$
BEGIN
NEW.last_update = CURRENT_TIMESTAMP;
RETURN NEW;
END $$
LANGUAGE plpgsql;
It requires you name your column last_update, which is what the naming
convention is in pagila, but might not work for everyone. Can someone work
with that and move forward? Or maybe give a more specific pointer to the
generic trigger stuff (I've not looked at it before)
--
Robert Treat
Conjecture: http://www.xzilla.net
Consulting: http://www.omniti.com
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2009-01-22 18:11:17 | Re: Pluggable Indexes (was Re: rmgr hooks (v2)) |
Previous Message | Peter Eisentraut | 2009-01-22 17:27:55 | pgsql: Automatic view update rules Bernd Helmle |