Re: Tables cannot have INSTEAD OF triggers

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, 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-01 17:07:04
Message-ID: 20150401170704.GA17586@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-04-01 12:46:05 -0400, Robert Haas wrote:
> On Wed, Apr 1, 2015 at 12:04 PM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> > On 2015-04-01 11:40:13 -0400, Robert Haas wrote:
> > Without INSTEAD OF you can't, to my knowledge, return a valid tuple from
> > the top level table without also inserting into it. Returning NULL after
> > redirecting the tuple into a child table will break RETURNING; not
> > returning NULL will insert the tuple in the top level table.
> >
> > So the only way to do redirection that doesn't break RETURNING without
> > rules is to insert the tuple in the child in the BEFORE trigger return
> > NEW and delete the top level table row in an AFTER trigger. That sucks.
>
> So, the idea is that INSTEAD OF would behave like BEFORE but the tuple
> it returns wouldn't actually be inserted? That wasn't clear to me
> from the OP, but I guess it would be a reasonable way to go.

I'm not sure what the OP intended, but to me that's pretty much the only
reasonable definition of INSTEAD OF for tables that I can think of.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-04-01 17:15:26 Re: Tables cannot have INSTEAD OF triggers
Previous Message Stephen Frost 2015-04-01 17:05:27 Re: [ADMIN] Permission select pg_stat_replication