1179
MySQLERRORCommonTransactionHIGH confidence
Command not allowed inside a transaction
Production Risk
Medium — accidental implicit commits break transaction atomicity.
What this means
ER_CANT_DO_THIS_DURING_AN_TRANSACTION (1179, SQLSTATE 25000) is returned when a command that causes an implicit or explicit COMMIT is attempted inside an active transaction. Commands like CREATE TABLE, DROP TABLE, ALTER TABLE, LOCK TABLES, and UNLOCK TABLES all cause implicit commits.
Why it happens
- 1Running DDL (CREATE/DROP/ALTER TABLE) inside an explicit START TRANSACTION block
- 2Using LOCK TABLES or FLUSH TABLES inside a transaction
How to reproduce
trigger — this will error
trigger — this will error
START TRANSACTION; UPDATE accounts SET balance = 100 WHERE id = 1; CREATE TABLE temp_table (id INT); -- implicit commit + error
expected output
ERROR 1179 (25000): You are not allowed to execute this command in a transaction
Fix
Move DDL outside the transaction
Move DDL outside the transaction
-- Create the table before starting the transaction CREATE TABLE IF NOT EXISTS temp_table (id INT); START TRANSACTION; UPDATE accounts SET balance = 100 WHERE id = 1; COMMIT;
Why this works
DDL statements always cause an implicit commit. Running them before or after the transaction keeps the transaction boundaries clean.
Sources
Official documentation ↗
MySQL 8.0 — 1179 ER_CANT_DO_THIS_DURING_AN_TRANSACTION
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev