Is this a bug? Sequences and rules
| От | Chris Travers |
|---|---|
| Тема | Is this a bug? Sequences and rules |
| Дата | |
| Msg-id | 461C76E7.4020109@metatrontech.com обсуждение исходный текст |
| Ответы |
Re: Is this a bug? Sequences and rules
Re: Is this a bug? Sequences and rules |
| Список | pgsql-general |
Hi; I noticed that rules were not behaving properly. I created a test case, and it looks like the sequence is getting double-incrimented. Is this the way this is supposed to work? I know triggers would be better for something like this but I find these results... surprising.... Version is 8.1.4 postgres=# create table test1 (id serial, test text); NOTICE: CREATE TABLE will create implicit sequence "test1_id_seq" for serial column "test1.id" CREATE TABLE postgres=# create table test2 (id int); CREATE TABLE postgres=# create rule insert as on insert to test1 do also insert into test2 (id) values (new.id); CREATE RULE postgres=# insert into test1 (test) values (1); INSERT 0 1 postgres=# insert into test1 (test) values (1); INSERT 0 1 postgres=# insert into test1 (test) values (1); INSERT 0 1 postgres=# select * from test1; id | test ----+------ 1 | 1 3 | 1 5 | 1 (3 rows) postgres=# select * from test2; id ---- 2 4 6 (3 rows)
Вложения
В списке pgsql-general по дате отправления: