Re: bug in delete rule ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: bug in delete rule ?
Дата
Msg-id 12432.1080233946@sss.pgh.pa.us
обсуждение исходный текст
Ответ на bug in delete rule ?  (sferriol <sylvain.ferriol@imag.fr>)
Список pgsql-general
sferriol <sylvain.ferriol@imag.fr> writes:
> and i create a rule for deleting using the view:
> CREATE RULE ALL_CENTERS_DEL AS ON DELETE TO all_centers
> DO INSTEAD (
>     DELETE FROM center_var WHERE
>     center_id = OLD.center_id;
>     DELETE FROM center WHERE
>     center_id = OLD.center_id;
> );

> but i this rule delete only line in center_var
> and do not remove the line in center table

Once you delete the center_var row, there is no row in the view that
matches the id, so the comparison against OLD.center_id fails.

You could possibly make the view use an outer join, and be careful to
delete the dependent row first in the rule.  Or maybe one of the tables
can be given a foreign-key dependency on the other, with ON DELETE CASCADE
behavior, and then the view rule need only delete explicitly from the
master table.

            regards, tom lane

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

Предыдущее
От: "Uwe C. Schroeder"
Дата:
Сообщение: Re: Memory usage during vacuum
Следующее
От: Shelby Cain
Дата:
Сообщение: Re: Memory usage during vacuum