Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Dean Rasheed
On 2 April 2015 at 22:23, Robert Haas wrote: > On Thu, Apr 2, 2015 at 5:02 PM, Andres Freund 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

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Robert Haas
On Thu, Apr 2, 2015 at 5:02 PM, Andres Freund 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

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Andres Freund
On 2015-04-02 16:42:43 -0400, Peter Eisentraut wrote: > On 4/2/15 11:50 AM, Dean Rasheed wrote: > > Well actually the fact that the code is structured that way is > > somewhat academic. INSTEAD OF triggers on views don't support WHEN > > conditions -- deliberately so, since it would be difficult to

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Peter Eisentraut
On 4/2/15 11:50 AM, Dean Rasheed wrote: > Well actually the fact that the code is structured that way is > somewhat academic. INSTEAD OF triggers on views don't support WHEN > conditions -- deliberately so, since it would be difficult to know in > general what to do if the trigger didn't fire. So E

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Dean Rasheed
On 2 April 2015 at 14:59, Tom Lane wrote: > Robert Haas writes: >> On Wed, Apr 1, 2015 at 1:56 PM, Tom Lane wrote: >>> It would absolutely *not* be reasonable for WHEN conditions for triggers >>> on tables to work completely differently than they do for triggers on >>> views. That ship's sailed

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Tom Lane
Robert Haas writes: > On Wed, Apr 1, 2015 at 1:56 PM, Tom Lane wrote: >> It would absolutely *not* be reasonable for WHEN conditions for triggers >> on tables to work completely differently than they do for triggers on >> views. That ship's sailed. > Clue me in, because I'm confused. If no tri

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Robert Haas
On Wed, Apr 1, 2015 at 1:56 PM, Tom Lane wrote: > Andres Freund writes: >> On 2015-04-01 13:29:33 -0400, Tom Lane wrote: >>> WHEN won't help; if there are any INSTEAD OF triggers, no insert will >>> happen, whether the triggers actually fire or not. > >> Well, right now it doesn't work at all. It

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-02 Thread Aliouii Ali
nd Cc: Tom Lane ; Robert Haas ; Aliouii Ali ; pgsql-hackers Sent: Wed, Apr 1, 2015 8:01 pm Subject: Re: [HACKERS] Tables cannot have INSTEAD OF triggers On 1 April 2015 at 18:37, Andres Freund wrote: > On 2015-04-01 13:29:33 -0400, Tom Lane wrote: >> As for partitioning, you c

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Dean Rasheed
On 1 April 2015 at 18:37, Andres Freund wrote: > On 2015-04-01 13:29:33 -0400, Tom Lane wrote: >> As for partitioning, you could do this: >> >> create table parent(...); >> create table child(...) inherits(parent); -- repeat as needed >> create view v as select * from parent; >> attach INSTEAD OF

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Tom Lane
Andres Freund writes: > On 2015-04-01 13:29:33 -0400, Tom Lane wrote: >> WHEN won't help; if there are any INSTEAD OF triggers, no insert will >> happen, whether the triggers actually fire or not. > Well, right now it doesn't work at all. It seems pretty reasonable to > define things so that the

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Andres Freund
On 2015-04-01 13:29:33 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2015-04-01 13:15:26 -0400, Tom Lane wrote: > >> If you have such a trigger, it's impossible to insert any rows, which > >> means the table doesn't need storage, which means it may as well be a > >> view, no? So this stil

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Tom Lane
Andres Freund writes: > On 2015-04-01 13:15:26 -0400, Tom Lane wrote: >> If you have such a trigger, it's impossible to insert any rows, which >> means the table doesn't need storage, which means it may as well be a >> view, no? So this still seems to me like a wart not a useful feature. >> I thi

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Alvaro Herrera
Tom Lane wrote: > Andres Freund writes: > > On 2015-04-01 12:46:05 -0400, Robert Haas wrote: > >> 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 wa

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Andres Freund
On 2015-04-01 13:15:26 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2015-04-01 12:46:05 -0400, Robert Haas wrote: > >> 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 gue

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Tom Lane
Andres Freund writes: > On 2015-04-01 12:46:05 -0400, Robert Haas wrote: >> 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 w

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Andres Freund
On 2015-04-01 12:46:05 -0400, Robert Haas wrote: > On Wed, Apr 1, 2015 at 12:04 PM, Andres Freund 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. Returni

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Robert Haas
On Wed, Apr 1, 2015 at 12:04 PM, Andres Freund wrote: > On 2015-04-01 11:40:13 -0400, Robert Haas wrote: >> I don't see how this helps. The problem with partitioning is that you >> need a way to redirect the INSERT to another table, and there's no >> built-in way to do that, so you have to simula

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Andres Freund
On 2015-04-01 11:40:13 -0400, Robert Haas wrote: > On Tue, Mar 31, 2015 at 8:49 AM, Aliouii Ali wrote: > I don't see how this helps. The problem with partitioning is that you > need a way to redirect the INSERT to another table, and there's no > built-in way to do that, so you have to simulate it

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2015-04-01 Thread Robert Haas
On Tue, Mar 31, 2015 at 8:49 AM, Aliouii Ali wrote: > hi all, > back in > 2011(http://www.postgresql.org/message-id/1305138588.8811.3.ca...@vanquo.pezone.net), > an question the same as this one was asked > the anwser was : > > I think they're very useful on views, but I > couldn't think of a use-

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2011-05-12 Thread Dean Rasheed
On 11 May 2011 19:51, Tom Lane wrote: > Peter Eisentraut writes: >> Why not?  Is there a fundamental problem, or just that no one wanted to >> make it work? > More the latter really. I think they're very useful on views, but I couldn't think of a use-case for having them on tables. ISTM that any

Re: [HACKERS] Tables cannot have INSTEAD OF triggers

2011-05-11 Thread Tom Lane
Peter Eisentraut writes: > Why not? Is there a fundamental problem, or just that no one wanted to > make it work? I'm fairly sure there was a substantive issue, but memory fails as to what it was. You could try removing the error check and see what breaks ... regards, t