Re: Tables cannot have INSTEAD OF triggers

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Aliouii Ali <aliouii(dot)ali(at)aol(dot)fr>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Tables cannot have INSTEAD OF triggers
Date: 2015-04-02 21:23:38
Message-ID: CA+TgmobcWE8X8qHjbgHRt4jAp2Ysz2pD169SrtdmDRCubzcDDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 2, 2015 at 5:02 PM, Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-04-02 21:33:10 Re: What exactly is our CRC algorithm?
Previous Message Andres Freund 2015-04-02 21:02:11 Re: Tables cannot have INSTEAD OF triggers