Re: Tables cannot have INSTEAD OF triggers - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Tables cannot have INSTEAD OF triggers
Date
Msg-id CA+TgmobcWE8X8qHjbgHRt4jAp2Ysz2pD169SrtdmDRCubzcDDw@mail.gmail.com
Whole thread Raw
In response to Re: Tables cannot have INSTEAD OF triggers  (Andres Freund <andres@anarazel.de>)
Responses Re: Tables cannot have INSTEAD OF triggers
List pgsql-hackers
On Thu, Apr 2, 2015 at 5:02 PM, Andres Freund <andres@anarazel.de> wrote:
>> I think the upshot is that INSTEAD OF triggers work in a particular way
>> because that's what is needed to support updatable views.  If triggers
>> on tables should behave differently, maybe it should be a separate
>> trigger type.  Maybe it would be feasible to extend BEFORE triggers to
>> support RETURNING, for example?
>
> What in the above prohibits extending the behaviour to tables? I have
> yet to see what compatibility or similarity problem that'd pose. It
> seems all mightily handwavy to me.

Yeah.  It's possible there's a better interface here than INSTEAD OF,
and one of the things I didn't like about the OP was that it started
by stating the syntax that would be used rather than by describing the
problem that needed to be solved.  It's generally better to start with
the latter, and then work out the syntax from there.  But having
gotten that gripe out of my system, and especially in view of Dean's
comments, it's not very clear to me what's wrong with using INSTEAD OF
for this purpose.  If you make BEFORE triggers do this via RETURNING,
then you might have a trigger that returns multiple rows, which seems
like it would introduce a bunch of new complexity for no obvious
benefit.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Tables cannot have INSTEAD OF triggers
Next
From: Heikki Linnakangas
Date:
Subject: Re: What exactly is our CRC algorithm?