unexpected RULE behavior

From: Mathias Palm <mathias(dot)palm(at)stud(dot)hs-wismar(dot)de>
To: pgsql-bugs(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: unexpected RULE behavior
Date: 2008-07-07 10:16:32
Message-ID: fba312351d3d.1d3dfba31235@hs-wismar.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I did the following:

CREATE TABLE data (id SERIAL, title VARCHAR);
CREATE TABLE data_copy(id INT4, title VARCHAR);
CREATE RULE make_copy AS ON INSERT TO data DO INSERT INTO data_copy
(id,title) VALUES (NEW.id, NEW.title);
INSERT INTO data (title) VALUES ('test');

database=# SELECT * FROM data;
id | title
----+-------
1 | test
(1 Zeile)

database=# SELECT * FROM data_copy;
id | title
----+-------
2 | test
(1 Zeile)

and wondered about the result in the table 'data_copy'. I expect the row
with the same values but 'id' is different although only 'data.id' is a
serial but not 'data_copy.id'.
My database is PostgreSQL 8.2.4 and runs on Windows Server 2003.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Davis 2008-07-07 16:34:00 Re: unexpected RULE behavior
Previous Message Ashutosh Kumar S-TLS,Chennai 2008-07-07 05:03:23 Re: error ' Client encoding Mismatch' with Version 8.1.4