Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D6204759C6; Fri, 23 Aug 2002 13:16:43 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id C542647597E; Fri, 23 Aug 2002 13:16:42 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 93C5D38192F; Fri, 23 Aug 2002 13:16:42 -0400 (EDT) From: Dmitry Tkach X-Newsgroups: comp.databases.postgresql.bugs, comp.databases.postgresql.general, comp.databases.postgresql.sql Subject: 'on delete' rule: bug or feature... Date: Fri, 23 Aug 2002 13:09:20 -0400 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 71 Message-ID: <3D666C40.3060908@openratings.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: news@hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7+) Gecko/20020123 X-Accept-Language: en-us To: pgsql-bugs@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/136 X-Sequence-Number: 4242 Hi, everybody! I was wonderring if anyone could help me with this... I have created two tables and a view that joins them together, then I add a rule, that is supposed to delete an entry from both tables, when I am deleting it from the view. That does not work for some reason - it only deletes the row from one of the tables, but not from the other one... Looks like a bug to me... Or am I doing something wrong here? Here is the SQL (I have removed the prompts, and commented out the responses, so that you can just cut and paste this in psql): -- First, create two tables, the view, and the 'on delete' rule: create table x (xx int); -- CREATE create table y (yy int); -- CREATE create view xy as select * from x, y where xx=yy; -- CREATE create rule xy_delete as on delete to xy do instead ( delete from x where xx=old.xx; delete from y where yy=old.yy; ); -- CREATE -- Insert a row into each table: insert into x values (1); -- INSERT 812084785 1 insert into y values (1); -- INSERT 812084786 1 -- Did it work? select * from xy; -- xx | yy -- ----+---- -- 1 | 1 -- (1 row) -- Great! Now delete it: delete from xy where xx=1; -- DELETE 0 select * from xy; -- (No rows) -- Looks good so far - it's gone from the view select * from x; -- (No rows) -- Gone from x too - still OK, BUT: select * from y; -- yy -- ---- -- 1 -- (1 row) OOPS! How come it is still here??? Any ideas? Your help will be greatly appreciated! Thanks a lot! Dima