pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vladimir V. Zolotych <gsmith@eurocom.od.ua>
To: pgsql-admin@postgresql.org
Subject: rules bug
Date: Sun, 30 Apr 2000 09:03:30 +0300
Message-ID: <390BCCB2.84926FA4@eurocom.od.ua> (raw)

  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

Message-ID: <390BCCB2.84926FA4@eurocom.od.ua>
Permalink:  ../390BCCB2.84926FA4@eurocom.od.ua/
Also on:    postgresql.org/message-id/390BCCB2.84926FA4@eurocom.od.ua

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: gsmith@eurocom.od.ua
  Subject: Re: rules bug
  In-Reply-To: <390BCCB2.84926FA4@eurocom.od.ua>
  References: <390BCCB2.84926FA4@eurocom.od.ua>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox