Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: BUG #2857: Sequence and table partitioning



"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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group