If the trigger only reads from the other table, that table will be read locked. If the trigger writes to the other table, it will be write locked. If a table is read-locked for reading via
LOCK TABLES, but needs to be write-locked because it could be modified by a trigger, a write lock is taken.
All locks are acquired together when the
LOCK TABLES statement is issued and they are released together on
LOCK TABLE table1 WRITE
table1 contains the following trigger:
CREATE TRIGGER trigger1 AFTER INSERT ON table1 FOR EACH ROW BEGIN INSERT INTO table2 VALUES (1); UPDATE table3 SET writes = writes+1 WHERE id = NEW.id AND EXISTS (SELECT id FROM table4); END;
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.