Re: [GENERAL] INSTEAD rule bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] INSTEAD rule bug?
Date: 2003-07-16 17:33:58
Message-ID: 23587.1058376838@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

I said:
> Dmitry Tkach <dmitry(at)openratings(dot)com> writes:
>> I thought you said it was only complaining about references to new and
>> old, not about *any* union clause...

> I don't see a need to reject "any" union clause. AFAIK the cases that
> don't work are just the ones where NEW or OLD are referenced.

After further study I've realized that the problem is that we have no
support for attaching qual conditions directly to a UNION node, and
thus INSERT ... SELECT ... UNION in a rule will misbehave if either
the rule's own WHERE condition or the WHERE of the invoking query is
nonempty. This is a separate problem from the question of whether there
is a reference to OLD or NEW.

For 7.4 I've added code to reject such cases. CVS tip will now do this,
given your example test and test_view:

regression=# create rule z2 as on update to test_view where false
regression-# do instead insert into test (select null, null union select 1,2);
ERROR: Conditional UNION/INTERSECT/EXCEPT statements are not implemented
regression=# create rule z2 as on update to test_view
regression-# do instead insert into test (select null, null union select 1,2);
CREATE RULE
regression=# update test_view set y = 1 where x is null;
ERROR: Conditional UNION/INTERSECT/EXCEPT statements are not implemented
regression=# update test_view set y = 1 ;
ERROR: ExecInsert: Fail to add null value in not null attribute x

Further down the pike we should try to support the cases that can be
made to work, but that sounds too much like a new feature to me to
consider for 7.4 at this stage.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-07-16 17:53:11 Re: Vacuum going -D; crash or just impatience?
Previous Message Josh Berkus 2003-07-16 16:06:44 Vacuum going -D; crash or just impatience?

Browse pgsql-general by date

  From Date Subject
Next Message Luis Magaña 2003-07-16 17:36:34 Re: ODBC query problem
Previous Message Maksim Likharev 2003-07-16 17:23:50 Re: ODBC query problem