RULE ON INSERT and INSERT INTO ... SELECT - Mailing list pgsql-bugs

From falcon
Subject RULE ON INSERT and INSERT INTO ... SELECT
Date
Msg-id 8110271129.20050405223440@intercable.ru
Whole thread Raw
List pgsql-bugs
Hello pgsql-bugs,

I'm here again. I'm using PostgreSQL 8.0.1 on Windows and Linux Slackware 10.0

--Start test--
create sequence try3_seq;
create table try3
(
        id int PRIMARY KEY,
        info varchar(30)
)
without oids;
create table try4
(
        id int,
        info varchar(30)
)
without oids;

create table handle_try3
(
        id serial PRIMARY KEY,
        info varchar(30) NOT NULL DEFAULT 0
)
without oids;

-- /*
create rule try4_insert as
    on insert to try4 do instead
    (
        insert into try3(id,info) values (nextval('try3_seq'),new.info);
        insert into handle_try3(info) vales (new.info);
     );
-- */
/* -- same result with
create rule try4_insert as
    on insert to try4 do instead
        insert into try3(id,info) values (nextval('try3_seq'),new.info);
create rule try4_insert_also
    on insert to try4 do
        insert into handle_try3(info) values (new.info);
*/
insert into try4(info) values ('hello'); -- simple inserts works well
insert into try4(info) values ('hell');

insert into try4(info) select info from try3;

select * from handle_try3;
/*
returns
 id|info
---+---
1  |hello
2  |hell
3  |hello
4  |hell
5  |hello
6  |hell

but it seems to me, there must be only 4 rows.
*/
-- Finish Test

mailto:falcon@intercable.ru

pgsql-bugs by date:

Previous
From: "Marcus v. Scotti"
Date:
Subject: BUG #1581: Problem with capitalised DB names...
Next
From: falcon
Date:
Subject: Repeat RULE ON INSERT and DEFAULT nextval('...')