Re: Auto-updated fields - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Auto-updated fields
Date
Msg-id 498AF451.4090601@dunslane.net
Whole thread Raw
In response to Re: Auto-updated fields  (Christopher Browne <cbbrowne@gmail.com>)
Responses Re: Auto-updated fields
List 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


pgsql-hackers by date:

Previous
From: "K, Niranjan (NSN - IN/Bangalore)"
Date:
Subject: Re: Synch Replication
Next
From: Simon Riggs
Date:
Subject: Re: Hot standby, recovery infra