Are restrictions performed before or after a custom trigger?

What is the order of triggers and restrictions? For example, if I insert a bad foreign key, will this fk be detected by pgsql before my own trigger (BEFORE or AFTER)?

I know that an exception inside the trigger rolls back any update / insert made inside the same trigger (even for the AFTER trigger), but is it the same for the constraints? Foreign key constraints do roll back all my attachments / updates from my own trigger?

Thank you

+4
source share
2 answers

, Postgres ( ):

( INSERT, UPDATE DELETE); ( , INSERT, UPDATE DELETE ); ( , ). , , ( INSERT UPDATE ). , , , "" .

, "" "" .

+3

, .

, .

+1

Source: https://habr.com/ru/post/1546416/


All Articles