SERIAL type in RULES
От | Alex Guryanow |
---|---|
Тема | SERIAL type in RULES |
Дата | |
Msg-id | 18595.000908@nlr.ru обсуждение исходный текст |
Ответы |
Re: SERIAL type in RULES
|
Список | pgsql-general |
HI, I use postgresql-7.0.2. One of my tables contains a field of type SERIAL: CREATE TABLE test2 (id serial, word varchar(100)); another table contains similar fields: CREATE TABLE test3 (test2_id int4, wod varchar(100)); I want to create a rule, that copies into test3 all what user inserts into test2: CREATE RULE rule_insert_test2 AS ON INSERT TO test2 DO INSERT INTO test3 (test2_id, word) VALUES (new.id, new.word); But when I insert into test2 I receive strange results. Here is a dump: test_db=# insert into test2 (word) values ('alex'); INSERT 12706507 1 test_db=# select * from test3; test2_id | word ----------+------ 1 | alex (1 row) test_db=# select * from test2; id | word ----+------ 2 | alex (1 row) As you can see test3.test2_id = 1 while test2.id = 2. It seems that the rule receives the correct value of new.id but after that the sequence for test2 is changed once more. Why this happens? Is this a bug? Regards, Alex
В списке pgsql-general по дате отправления: