Re: BUG #2857: Sequence and table partitioning - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #2857: Sequence and table partitioning
Date
Msg-id 25794.1167079826@sss.pgh.pa.us
Whole thread Raw
In response to BUG #2857: Sequence and table partitioning  ("Tomislav Karastojkovic" <karastojko@gmail.com>)
List pgsql-bugs
"Tomislav Karastojkovic" <karastojko@gmail.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #2861: when backup UTF-8 database,pgdump add comments not encoded in UTF-8
Next
From: Tom Lane
Date:
Subject: Re: bug: Mac OS X 10.4.8 Intel