On Fri, Dec 27, 2019 at 10:29:15PM -0500, Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> > While noodling around with an upcoming patch to remove user-modifiable
> > RULEs, I noticed that WHEN conditions were disallowed from INSTEAD OF
> > triggers for no discernible reason. This patch removes that
> > restriction.
>
> This seems like a remarkably bad idea. The point of an INSTEAD OF
> trigger is that it is guaranteed to handle the operation. What's
> the system supposed to do with rows the trigger doesn't handle?
Nothing. Why would it be different from the other forms of WHEN in
triggers?
> I notice that your patch doesn't even bother to test what happens,
> but I'd argue that whatever it is, it's wrong. If you think that
> "do nothing" or "throw an error" is appropriate, you can code that
> inside the trigger. It's not PG's charter to make such a decision.
If that's the case, why do we have WHEN for triggers at all? I'm just
working toward make them more consistent. From a UX perspective, it's
a lot simpler and clearer to do this in the trigger declaration than
it is in the body.
> PS: I think your chances of removing rules are not good, either.
I suspect I have a lot of company in my view of user-modifiable
rewrite rules as an experiment we can finally discontinue in view of
its decisive results.
Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate