Triggers for MariaDB Xpand
This page is part of MariaDB's MariaDB Documentation.
The parent of this page is: Triggers
Topics on this page:
Overview
The Xpand implementation for triggers is intended to provide compatibility with the MySQL implementation of triggers. For general semantics and operation of triggers refer to the MySQL documentation for triggers.
Caveats for triggers
Xpand does not perform create-time checks on triggers. If a trigger is defined with access errors (permissions, modifying table the trigger is defined on, etc.), MySQL will generate an error on the
CREATE TRIGGERstatement, however, Xpand will generate an error when the trigger is executed (i.e. onINSERT/UPDATE/DELETE).NOT NULLcolumns within aBEFOREtrigger do not retain theNOT NULLproperty while within the trigger. In MySQL, aNOT NULLcolumn set toNULLwithin a trigger will immediately generate an error. In Xpand, however, the column will be set toNULL. Unless changed toNOT NULLlater in the trigger, an error will occur when the DML is executed.NOT NULL AUTO_INCREMENTcolumns are an exception. In MySQL,NOT NULL AUTO_INCREMENTcolumns set toNULLwithin a trigger are immediately and silently converted to0. In Xpand the column will be set toNULL. After a trigger finishes executing, but before the subsequent DML operation, anyNOT NULL AUTO_INCREMENTcolumns withNULLvalues will be silently converted to0, allowing auto increment to work correctly.
Xpand does not support triggers that modify columns with the
ENUMdata type. No error message will be given when creating or executing triggers that modifyENUMtypes, but the results are undefined. For example, if a table has aENUMcolumnstate, then the effects of the statementNEW.state = NEW.state + 1are undefined. Use explicit values instead, likeNEW.state = "RUNNING".Xpand supports the
TRIGGERpermission, but theSUPERpermission also grants all abilities associated with the trigger permission.Query logs from
BEFOREandAFTERtriggers will appear before the logs for the statement invoking the trigger.
