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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Shmidt 2002-08-30 20:25:04 Please, help me!
Previous Message Tom Lane 2002-08-30 14:50:51 Re: Please, help me!