============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================
Your name : Enrico Scholz
Your email address : enrico.scholz@informatik.tu-chemnitz.de
System Configuration
---------------------
Architecture (example: Intel Pentium) : i686
Operating System (example: Linux 2.0.26 ELF) : Linux 2.2.12 ELF
PostgreSQL version (example: PostgreSQL-6.5.1): PostgreSQL-6.5.1
Compiler used (example: gcc 2.8.0) : egcs-2.91.66
Please enter a FULL description of your problem:
------------------------------------------------
The following statements
----------------------------------
create table foo ( id serial, data text );
create table foo1 ( id int );
create rule rule_ins as on insert to foo do insert into foo1 (id) values(NEW.id);
insert into foo(data) values('test');
select * from foo,foo1;
---------------------------------
are producing the unexpected result
id|data|id
--+----+--
2|test| 1
(both id's differ).
The thing I wanted to do is to insert an empty dataset into
foo1 for each new "id" in foo, so the result should be
"1|test|1".
I guess the default-value "nextval('foo_id_seq')" implicated
by the "serial" datatype will be used as a literal and not be
evaluated. So both NEW.id and the plain insert into foo will
call nextval(...).
Enrico