dbTalk Databases Forums  

[BUGS] RULE ON INSERT and DEFAULT nextval('...')

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] RULE ON INSERT and DEFAULT nextval('...') in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
falcon
 
Posts: n/a

Default [BUGS] RULE ON INSERT and DEFAULT nextval('...') - 04-10-2005 , 02:21 PM






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



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.