Subject Re: On delete cascade and before delete triggers
Author Alexander V.Nevsky
--- In, "Calin Iancu Pirtea"
<pcalin@r...> wrote:
> I noticed today that delete cascade triggers are fired "after
> while I was convinced that they happen before delete.
> Is this a bug?

Calin, no, it is right behaviour. It prevents the next situation,
which will occure if check of details existance will be performed
before master delete:

1. Transaction 1 started delete process
2. Transaction 1 checked existance of details and delete them
3. Transaction 2 inserted new detail for this master record
4. Transaction 1 deleted master and commited

moment of transaction 2 commit is not principial, we have broken
references integrity. Current behaviour (master deleted first)
guarantees that transaction 2 can't insert detail during cascade
delete process.

Best regards, Alexander.