Re: Need "InBetween" (not just Before and After) Trigger
От | Tom Lane |
---|---|
Тема | Re: Need "InBetween" (not just Before and After) Trigger |
Дата | |
Msg-id | 14399.979445852@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Need "InBetween" (not just Before and After) Trigger (Matt Doucleff <matt@digitalfountain.com>) |
Список | pgsql-general |
Matt Doucleff <matt@digitalfountain.com> writes: > I want a trigger to happen after constraint checking but before row > insertion. In other words, you'd like your trigger to be able to violate the constraints? This does *not* strike me as a good idea. > If I use a "before" trigger, the constraints are checked after I've > already performed my action. Thus I have performed my action yet no > row is inserted (which is inconsistent). > If I use an "after" trigger, the constraints are checked first. If > the row is inserted, I attempt to perform my action. If my action > fails, then I have an inserted row but no action, which is also > inconsistent. Seems to me this is all irrelevant, because in either case, the first action will be rolled back if the second one fails. There might be some marginal amount of time wasted, which you could minimize by arranging things so that the more-likely-to-fail action is done first. But I see no correctness issue. regards, tom lane
В списке pgsql-general по дате отправления: