Re: Trigger difference in 9.0 and 9.3

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: Trigger difference in 9.0 and 9.3
Дата
Msg-id 1415675087372-5826449.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Trigger difference in 9.0 and 9.3  (Erwan Tanajaya <erwan.tanajaya@gmail.com>)
Ответы Re: Trigger difference in 9.0 and 9.3  (Erwan Tanajaya <erwan.tanajaya@gmail.com>)
Список pgsql-novice
Erwan Tanajaya-2 wrote
> i do as you suggested, i returning null on the initial before delete
> trigger(parrent trigger), but when i returning null no delete action is
> accured.
> am i doing wrong ?
>
> "the trigger can avoid the error by re-issuing the triggering statement
> and
> returning NULL"
> how i re-issuing the triggering statement ?

If you are inside a DELETE trigger you would do something like:

DELETE FROM table_this_trigger_is_on WHERE pk_for_the_table =
OLD.pk_for_the_table;
RETURN NULL;

The returning of NULL prevents the original DELETE action but since you took
care of it manually the final result is that the record in question is still
gone.

That said you need to see if you can introduce logic somewhere that says:
"since my parent record is going to go away anyway I should just avoid
updating it in the first place".

Aside from that a self-contain and reasonably faithful reproduction of your
exact problem might help you either obtain advice or make Kevin et. al.
reconsider the solution put in place to avoid the problem they were facing.

Note that in the two years this patch has been in place this is the first
time I recall seeing a report of this nature...which suggests there is a
correct solution that you are missing.  Though I am also thinking 9.3 hasn't
received as much adoption in the past two years as we would have liked...

David J.




--
View this message in context: http://postgresql.nabble.com/Trigger-difference-in-9-0-and-9-3-tp5818162p5826449.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


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

Предыдущее
От: Erwan Tanajaya
Дата:
Сообщение: Re: Trigger difference in 9.0 and 9.3
Следующее
От: Erwan Tanajaya
Дата:
Сообщение: Re: Trigger difference in 9.0 and 9.3