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 TRIGGER
statement, however, Xpand will generate an error when the trigger is executed (i.e. onINSERT/UPDATE/DELETE
).NOT NULL
columns within aBEFORE
trigger do not retain theNOT NULL
property while within the trigger. In MySQL, aNOT NULL
column set toNULL
within a trigger will immediately generate an error. In Xpand, however, the column will be set toNULL
. Unless changed toNOT NULL
later in the trigger, an error will occur when the DML is executed.NOT NULL AUTO_INCREMENT
columns are an exception. In MySQL,NOT NULL AUTO_INCREMENT
columns set toNULL
within 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_INCREMENT
columns withNULL
values will be silently converted to0
, allowing auto increment to work correctly.
Xpand does not support triggers that modify columns with the
ENUM
data type. No error message will be given when creating or executing triggers that modifyENUM
types, but the results are undefined. For example, if a table has aENUM
columnstate
, then the effects of the statementNEW.state = NEW.state + 1
are undefined. Use explicit values instead, likeNEW.state = "RUNNING"
.Xpand supports the
TRIGGER
permission, but theSUPER
permission also grants all abilities associated with the trigger permission.Query logs from
BEFORE
andAFTER
triggers will appear before the logs for the statement invoking the trigger.