On Sep 8, 2009, at 7:38 AM, Kevin Grittner wrote:
David Fetter <da...@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. =)
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers