Received: from Main.eurocom.od.ua (root@Main.EuroCom.Od.UA [212.15.128.6]) by hub.org (8.9.3/8.9.3) with ESMTP id CAA59951 for ; Sun, 30 Apr 2000 02:03:08 -0400 (EDT) (envelope-from gsmith@eurocom.od.ua) Received: from eurocom.od.ua (FarHost.EuroCom.Od.UA [212.15.128.42]) by Main.eurocom.od.ua (8.10.0/8.10.0) with ESMTP id e3U62xU16481 for ; Sun, 30 Apr 2000 09:03:00 +0300 Message-ID: <390BCCB2.84926FA4@eurocom.od.ua> Date: Sun, 30 Apr 2000 09:03:30 +0300 From: "Vladimir V. Zolotych" X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: rules bug Content-Type: multipart/alternative; boundary="------------32059002BAADDB73FFAB3D97" X-Archive-Number: 200004/100 --------------32059002BAADDB73FFAB3D97 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Hello all, Have the problem with using RULEs (is it a RULE's bug?): Do the following: 1) Create table 'num' with column of a type SERIAL, e.g. CREATE TABLE num (id SERIAL, num INT4); 2) Create table 'num_log' (for logging insertions in table 'num'), e.g. CREATE TABLE num_log (num_id INT4, num_val INT4); 3) Create rule 'num_rule' (that makes logging), e.g. CREATE RULE num_rule AS ON INSERT TO num DO INSERT INTO num_log VALUES (NEW.id, NEW.num); 4) Insert into 'num', e.g. INSERT INTO num (num) VALUES (123); 5) SELECT * FROM num; id|num ------ 2|123 6) SELECT * FROM num_log; num_id|num_val -------------- 1| 123 The problem is id != num_id, e.g. the 'id' logged with RULE differs from real 'id' of the inserted (into table 'num') row. Did anybody encountered the same problem, if so how it were solved? Is it a bug? Thanks! -- Vladimir Zolotych gsmith@eurocom.od.ua --------------32059002BAADDB73FFAB3D97 Content-Type: text/html; charset=koi8-r Content-Transfer-Encoding: 7bit   Hello all,

Have the problem with using RULEs (is it a RULE's bug?):

Do the following:

1) Create table 'num' with column of a type SERIAL, e.g.

   CREATE TABLE num (id SERIAL, num INT4);

2) Create table 'num_log' (for logging insertions
   in table 'num'), e.g.

   CREATE TABLE num_log (num_id INT4, num_val INT4);
 
3) Create rule 'num_rule' (that makes logging), e.g.

   CREATE RULE num_rule AS
     ON INSERT TO num
     DO INSERT INTO num_log VALUES (NEW.id, NEW.num);

4) Insert into 'num', e.g.

   INSERT INTO num (num) VALUES (123);

5) SELECT * FROM num;

   id|num
   ------
    2|123

6) SELECT * FROM num_log;

   num_id|num_val
   --------------
        1|    123

The problem is id != num_id, e.g. the 'id' logged with
RULE differs from real 'id' of the inserted (into table 'num')
row.

Did anybody encountered the same problem, if so how it were solved?
Is it a bug?

Thanks!
 

-- 
Vladimir Zolotych                         gsmith@eurocom.od.ua
  --------------32059002BAADDB73FFAB3D97--