is it a bug in rule system?

Поиск
Список
Период
Сортировка
От laser
Тема is it a bug in rule system?
Дата
Msg-id 483D1026.2010403@pgsqldb.com
обсуждение исходный текст
Ответы Re: is it a bug in rule system?
Список pgsql-general
hi all,

see query below:

create table ruleTest(id integer, name text);

create or replace rule ruleTest_insert_rule AS on insert to ruleTest
where exists(select 1 from ruleTest where ruleTest.name = NEW.name)
do instead (update ruleTest set id = id+1 where ruleTest.name = NEW.name);

create unique index ruletest_name_uniq_idx on ruletest using btree (name);

laser=# insert into ruletest(id,name) values(1, 'laser0');
INSERT 0 1
laser=# select * from ruletest;
 id |  name
----+--------
  2 | laser0

I think the id should be 1, cause the rule condition should only affect
exist row,
but ISTM the rule act like a DO ALSO rule: insert the row first, then
update it.

any hints?

thanks and best regards

-laser

В списке pgsql-general по дате отправления:

Предыдущее
От: yazicivo@ttmail.com (Volkan Yazıcı)
Дата:
Сообщение: Re: Permission Problem for DELETE
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: is it a bug in rule system?