Rule system - Mailing list pgsql-bugs

From Gena Gurchonok
Subject Rule system
Date
Msg-id 4728.000630@rt.mipt.ru
Whole thread Raw
List pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name               :Gena Gurchonok
Your email address      :gena@rt.mipt.ru


System Configuration
---------------------
  Architecture (example: Intel Pentium)         :Intel Celeroom

  Operating System (example: Linux 2.0.26 ELF)  : Linux 2.2.16 ELF

  PostgreSQL version (example: PostgreSQL-6.5.1):   PostgreSQL-7.0.2

  Compiler used (example:  gcc 2.8.0)           : gss 2.91.66


Please enter a FULL description of your problem:
------------------------------------------------
I've noticed interesting feature in PSQL 7.0.2
when executing insertion rules PSQL does not substitute new.* with
real values - it calculates these fields only as needed



Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

1 I create SEQUENCE ss
2 I create table tt with field (a int4 default NEXTVAL(ss) )
3 I create table t2 with field (i int4)
4 I
    create rule r as on insert to tt do insert into t2(i) values(new.a);

RESULT

For each insertion into tt sequence ss increases by 2. Tables tt and
t2 have DIFFERENT values after insert (for example tt have 2 and t2
have 1)



in rule system when rule executes it uses "non calculated information"
so we have NEXTVAL(ss) called twice:
 first time for rule command
 second time for insert command


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Is it a bug or a feature?


Thanks for support.

Gena

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: \d* won't work in 7.0.2?
Next
From: Paul McGarry
Date:
Subject: Bug: Contrib\fulltextindex\fti.c?