Hi, There is the Locks During Deletes section in the docs, but it lacks info about triggers. I need a confirmation about row-level BEFORE DELETE trigger firing time: does it fire just after write lock is acquired on the row to be deleted? It would be great if this info was added to that docs section. Thanks. P. s.: sections Locks During Inserts and Locks During Updates are missing info about BEFORE triggers too. asked 05 Oct '21, 04:35 Arthoor |
AFAIK a connection will obtain all necessary locks to permit a SQL operation before any part of that operation is processed.
It would make no sense to allow any part of a trigger to start executing before some other connection obtained a conflicting lock that blocks the lock this connection needs.
Having said that, a statement in the docs (or an example) would be nice.
FWIW, here's an old posting by Glenn Paulley with detailed insights (as expected...) on the internal steps a trigger has to consider - cf. that old NNTP article "Before update trigger and computed column ".
Sigh, the old link does not work currently, the following might help:
https://sybase.public.sqlanywhere.general.narkive.com/ZWtL2C7m/before-update-trigger-and-computed-column
Note: It does not tell about locks but shows when the different kind of triggers are fired, in this case for INSERT. As Breck has stated, apparently locks must be placed before any data is modified, including the trigger's action.