Skip to content

Commit 8ce6e6e

Browse files
committed
Fix #114 - Added trigger scope explanation to G-7740
1 parent a500eed commit 8ce6e6e

File tree

1 file changed

+2
-0
lines changed
  • docs/4-language-usage/7-stored-objects/7-triggers

1 file changed

+2
-0
lines changed

docs/4-language-usage/7-stored-objects/7-triggers/g-7740.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
If a trigger makes assignment to the primary key anywhere in the trigger code, that causes the session firing the trigger to take a lock on any child tables with a foreign key to this primary key. Even if the assignment is in for example an `if inserting` block and the trigger is fired by an `update` statement, such locks still happen unnecessarily. The issue is avoided by having one trigger for the insert containing the primary key assignment, and another trigger for the update. Or even better by handling the insert assignment as ´default on null´ clauses, so that only an `on update` trigger is needed.
1212

13+
This locking of child tables behaviour goes for simple DML triggers as well as compound DML triggers where assignments to primary keys take place. It is not relevant for instead-of triggers on views, as it is not possible to assign `:new` values and therefore no locks on child tables are needed.
14+
1315
## Example (bad)
1416

1517
``` sql

0 commit comments

Comments
 (0)