Re: Auto-updated fields

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Auto-updated fields
Date: 2009-02-05 14:14:41
Message-ID: 498AF451.4090601@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Christopher Browne wrote:
>>>
>>> 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)
>>>
>> Well, I thought it was a good idea, but no one seems to want to do the
>> work.
>>
>
> I'd like to see more options than that, which, it seems to me,
> establishes a need for more design work.
>
>
>

At the very least it should not have a hard-coded field name in it. You
should pass the field name to be set as a parameter in the trigger setup.

That's probably a lot more doable if the trigger is written in C, and in
any case I think any prepackaged triggers we provide should be written in C.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2009-02-05 14:19:51 Re: Hot standby, recovery infra
Previous Message K, Niranjan (NSN - IN/Bangalore) 2009-02-05 13:50:15 Re: Synch Replication