Re: BUG #1676: Statment order in rules

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #1676: Statment order in rules
Дата
Msg-id 3985.1116517713@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #1676: Statment order in rules  ("Olleg Samoylov" <olleg@mipt.ru>)
Ответы Re: BUG #1676: Statment order in rules  (Olleg Samoylov <olleg@mipt.ru>)
Список pgsql-bugs
"Olleg Samoylov" <olleg@mipt.ru> writes:
> create rule delete_first as on delete to v do instead (delete from a where
> a=old.a;update c set c=c-1);

> delete from v where a=0;
> select * from a;
> -- 0 row, as expected :-)
> select * from c;
> -- 1, this is incorrect

This isn't a bug.  The DELETE causes the a=0 row to disappear from the
view, so the subsequent statement (which is implicitly conditional on
there being an a=0 row) doesn't do anything.  If it did do something,
then a "delete from v" that didn't delete any rows would still decrement
c, which is not what you want, eh?

            regards, tom lane

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

Предыдущее
От: "Mohan, Ross"
Дата:
Сообщение: Re: [PORTS] Bug Report with Postgres 7.4 on AIX 5.3
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: BUG #1675: very slow work