Re: Triggers on columns

Поиск
Список
Период
Сортировка
От James Pye
Тема Re: Triggers on columns
Дата
Msg-id C3B0F6DC-50B7-495C-8ED3-33401ACD01BE@jwp.name
обсуждение исходный текст
Ответ на Re: Triggers on columns  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Список pgsql-hackers
On Sep 8, 2009, at 7:38 AM, Kevin Grittner wrote:

> David Fetter <david@fetter.org> wrote:
>
>> CREATE TRIGGER trig BEFORE UPDATE ON tbl FOR EACH ROW
>>    WHEN (NEW.col IS DISTINCT FROM OLD.col)
>>        EXECUTE PROCEDURE trigger_func();
>
> How much does that buy you versus including this at the start of
> trigger_func:

On the face, it buys nothing, IMO. ISTM, looking at the examples, that  
the above syntax would lead to redundant logic if the particular  
trigger_func() were used by multiple TRIGGERs. That is, assuming the  
precondition is necessary for proper functionality, it would have to  
be repeated on all the TRIGGERs that trigger_func() would be executed  
by.

[..moving away from the isolated use-case of the example]

However, if trigger_func() were a generalized trigger function, which  
would likely be the case if it were used by multiple TRIGGERs[;)]. The  
necessary precondition would probably be inconsistent across the  
TRIGGERs, and thus the feature could be quite useful.
Currently, such a generalized trigger function *could* be crafted  
using trigger arguments, but I'd be inclined to think that that would  
require more exercise than it would be worth( that is, I'm imagining  
something that would be dirty, and much less convenient than WHEN =).


Personally, I think WHEN () would be pretty sweet. =)


В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: CTE bug?
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Triggers on columns