RULE ON INSERT and DEFAULT nextval('...')

From: falcon <falcon(at)intercable(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: RULE ON INSERT and DEFAULT nextval('...')
Date: 2005-04-05 16:00:55
Message-ID: 522442943.20050405200055@intercable.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello pgsql-bugs,

Excuse my English. I'm from Russia.
I understood, that following is implementation behavior,
but this is really not what i'm expecting to see.

--Start test--
create table try1
(
id serial PRIMARY KEY, -- same with DEFAULT nextval('some_sequence')
info varchar(30)
)
without oids;

create table handle_try1
(
id_try1 int PRIMARY KEY,
inf int NOT NULL DEFAULT 0
)
without oids;

create rule try1_insert as
on insert to try1 do insert into handle_try1 (id_try1)
values (new.id);

insert into try1(info) values ('hello');
insert into try1(id,info) values(3,'hell'); -- later one'll see the reason for id=3

select * from try1;
/*
returns
id | info
----+-------
1 | hello
3 | hell
(2 rows)
*/
select * from handle_try1;
/*
returns
id_try1 | inf
---------+-------
2 | 0
3 | 0
(2 rows)
but I really expected
id_try1 | inf
---------+-------
1 | 0
3 | 0
(2 rows)
*/
-- Finish Test

Cause of this I ought to use trigger, what I really do not want to do.
And, i think, same behavior takes the place with other volatile function defaults.

mailto:falcon(at)intercable(dot)ru

Browse pgsql-bugs by date

  From Date Subject
Next Message Marcus v. Scotti 2005-04-05 17:09:25 BUG #1581: Problem with capitalised DB names...
Previous Message David Elliott 2005-04-04 22:22:46 BUG #1580: pg_dumpall aborts when cwd is unreadable