Re: Help with distinctly non-intuitive rule behaviour

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Help with distinctly non-intuitive rule behaviour
Дата
Msg-id 16903.1141595978@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Help with distinctly non-intuitive rule behaviour  ("Simon Kinsella" <simon@bluefiresystems.co.uk>)
Список pgsql-sql
"Simon Kinsella" <simon@bluefiresystems.co.uk> writes:
> CREATE RULE rule_soft_delete_user AS ON DELETE TO users
>   WHERE user_departed > now()
>   DO INSTEAD 
>     UPDATE users SET user_departed = now()
>       WHERE user_id = OLD.user_id;

This is run before the delete.  However, since it's a conditional rule,
the delete is still run, with the added where-condition
NOT(user_departed > now()).  Since the UPDATE has caused that to be
true, the delete happens.  You should reconsider whether this is to be
conditional or not.
        regards, tom lane


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

Предыдущее
От: "Simon Kinsella"
Дата:
Сообщение: Help with distinctly non-intuitive rule behaviour
Следующее
От: Greg Stark
Дата:
Сообщение: Re: functions in WHERE clause