Hi,

Attached is the example script 'repro.sql' which creates two relations tab1 and tab2. It also creates a rule on tab1 which simply does insert into tab2. The insert statement into tab1 is executed afterwards. It responds with 'INSERT 0 1'. However if I would create the same rule with the where clause the response to the same insert statement is 'INSERT 0 0'. The output of the script executed through psql is in 'repro.out'.

Is this a bug? Is there any reason why the second insert should respond 'INSERT 0 0' instead of 'INSERT 0 1'? Thanks.

Cheers

Julo


CREATE TABLE
CREATE TABLE
CREATE RULE
INSERT 0 1
 id  
-----
 100
(1 row)

DROP RULE
CREATE RULE
DELETE 1
 id 
----
(0 rows)

INSERT 0 0
 id  
-----
 100
(1 row)

DROP RULE
DROP TABLE
DROP TABLE
create table tab1 (id int);
create table tab2 (id int);
create rule tab1_insert as on insert to tab1 do instead insert into tab2 values (new.id);

insert into tab1 values (100);
select * from tab2;

drop rule tab1_insert on tab1;
create rule tab1_insert as on insert to tab1 where 1<2 do instead insert into tab2 values (new.id);

delete from tab2;
select * from tab2;

insert into tab1 values (100);
select * from tab2;

drop rule tab1_insert on tab1;
drop table tab2;
drop table tab1;

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to