Re: BUG #2857: Sequence and table partitioning

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tomislav Karastojkovic" <karastojko(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2857: Sequence and table partitioning
Date: 2006-12-25 20:50:26
Message-ID: 25794.1167079826@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Tomislav Karastojkovic" <karastojko(at)gmail(dot)com> writes:
> CREATE OR REPLACE RULE r AS ON INSERT TO parent WHERE id>=1 AND id <= 100 DO
> INSTEAD INSERT INTO child VALUES(NEW.id, NEW.message);

> then the sequence is increasing by 5 when inserting into 'parent' table.

"id" is basically a macro that gets replaced with the expression being
inserted, ie, the nextval() call. So you're getting bit with multiple
evaluation.

There isn't any very safe way to do this sort of thing with a rule.
Consider using a trigger instead.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-12-25 20:52:00 Re: bug: Mac OS X 10.4.8 Intel
Previous Message Tom Lane 2006-12-25 20:46:39 Re: BUG #2861: when backup UTF-8 database, pgdump add comments not encoded in UTF-8