Re: WIP: Triggers on VIEWs - Mailing list pgsql-hackers

From Tom Lane
Subject Re: WIP: Triggers on VIEWs
Date
Msg-id 7529.1286557416@sss.pgh.pa.us
Whole thread Raw
In response to Re: WIP: Triggers on VIEWs  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: WIP: Triggers on VIEWs
List pgsql-hackers
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> On 8 October 2010 16:50, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I've started looking at this patch now. �I think it would have been best
>> submitted as two patches: one to add the SQL-spec "INSTEAD OF" trigger
>> functionality, and a follow-on to extend INSTEAD OF triggers to views.

> SQL-spec "INSTEAD OF" triggers *are* view triggers. I don't see how
> you can separate the two.

Oh, they're not allowed on tables?  Why not?  AFAICS they'd be exactly
equivalent to a BEFORE trigger that always returns NULL.

> I think that you're confusing 2 different parts of code here. The
> TRIGGER_FIRED_AFTER/TRIGGER_FIRED_BEFORE macros operate on the bits
> from the tg_event field of the TriggerData structure.

Yeah, I'm aware of that.  My point is that all code that deals with
trigger firing times now has to consider three possible states where
before there were two; and it's entirely likely that some places are
testing for the wrong condition once a third state is admitted as a
possibility.

> The scope for user
> code being broken is limited beause they'd have to put one of these
> trigger functions in an INSTEAD OF trigger on a view.

Well, the only reason those tests are being made at all is as
self-defense against being called via an incorrect trigger definition.
So they're worth nothing if they fail to treat the INSTEAD OF case
correctly.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: WIP: Triggers on VIEWs
Next
From: Robert Haas
Date:
Subject: Re: GIN vs. Partial Indexes