New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger order on delete cascade [CORE1541] #797
Comments
Modified by: Valdir Stiebe Junior (ogecrom)Attachment: trigger order test case.sql [ 10631 ] |
Commented by: Smirnoff Serg (wildsery) I think this is not a bug. |
Commented by: Valdir Stiebe Junior (ogecrom) It is the same behaviour as if in a first transaction we insert detail records and in a second transaction we try to delete the master. The "Foreign key references are present for the record" exception is raised. But I agree that if I first tried to delete the master, this operation must have more priority than the inserts in other transactions. I've filled this issue because of the trigger order and the visibility of the master record in the before delete detail trigger. |
Commented by: @hvlad It's as designed and not a bug |
Modified by: @pcisarWorkflow: jira [ 13349 ] => Firebird [ 13923 ] |
Commented by: Philip Williams (unordained) Is the suggested work-around, then, that rather than relying on on-delete-cascade, you should put a before-delete trigger on the master record which deletes any detail records, thus allowing the detail table's before-delete triggers to still see the master record? |
Submitted by: Valdir Stiebe Junior (ogecrom)
Attachments:
trigger order test case.sql
In a master-detail relationship with a cascade delete FK, the detail table before delete trigger can't see the master table record. It looks like the database is in an inconsistent state (a detail without a master record) at this time.
Correct me if I am wrong but the correct trigger order in a cascade delete would be:
1. before delete master
2. before delete detail
3. delete detail
4. after delete detail
5. delete master
6. after delete master
The actual order is:
1. before delete master
2. delete master
3. after delete master
4. before delete detail
5. delete detail
4. after delete detail
The text was updated successfully, but these errors were encountered: