Skip site navigation (1) Skip section navigation (2)

Bug #754: Bug with inserts and rules on inserts in Postgres 7.2.1-3

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #754: Bug with inserts and rules on inserts in Postgres 7.2.1-3
Date: 2002-08-30 16:27:49
Message-ID: 20020830162749.67CBF476ACC@postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
Paulo Santos (psantos(at)wit-software(dot)com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Bug with inserts and rules on inserts in Postgres 7.2.1-3

Long Description
Hi!

I've a table (USERS) with three rules created.

What this rules does is to insert other values in an other table (FOLDERS). So when I create a user I insert three (Inbox, Sent, and Base folder) default folders for this user.

This rules use the new.user_id to the FK reference in the table folders to the table users.

I discover that if I insert using something like:
insert into users values (nextval('user_seq'), 'usera'); 
The rules will try to insert nextval('user_seq') as the FK insted of the value that the insert have.
So the insert in the users will get the id=1, and the three rules will have the ids: 2, 3 and 4 that don't exist in the database.

So I can only insert data in the table users using this pseudo code:

int id = select nextval('user_seq');
insert into users (id, 'usera');

This is happening in Postgres 7.2.1-3

If you consider this a real bug and want further informations, please e-mail me and I'll explain this with more details.

Best Regards,
Paulo Santos

Sample Code


No file was uploaded with this report


pgsql-bugs by date

Next:From: Pavel ShmidtDate: 2002-08-30 20:25:04
Subject: Please, help me!
Previous:From: Tom LaneDate: 2002-08-30 14:50:51
Subject: Re: Please, help me!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group