1422
MariaDBerrorstored-procedureshigh confidence

Explicit or implicit commit not allowed in stored function or trigger

Production Risk

Low — trigger/function fails at runtime.

What this means

A COMMIT or ROLLBACK was used inside a stored function or trigger, or a DDL statement that causes an implicit commit was executed within one.

Why it happens
  1. 1Calling COMMIT or ROLLBACK directly in a trigger or function body
  2. 2Using DDL (CREATE TABLE, ALTER TABLE) inside a function or trigger
How to reproduce
trigger — this will error
trigger — this will error
CREATE TRIGGER t AFTER INSERT ON orders FOR EACH ROW BEGIN COMMIT; END;

expected output

ERROR 1422 (0A000): Explicit or implicit commit is not allowed in stored function or trigger

Fix

Remove COMMIT/ROLLBACK from the trigger/function

Why this works

Transaction control belongs to the calling application layer, not to triggers/functions.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 1422 ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors