3380
MariaDBERRORNotableReplicationHIGH confidence
CREATE TEMPORARY TABLE in transaction is unsafe with GTIDs
Production Risk
High — transaction will be rejected; application must handle the error.
How to reproduce
trigger — this will error
trigger — this will error
START TRANSACTION; INSERT INTO t VALUES (1); CREATE TEMPORARY TABLE tmp (id INT); COMMIT;
expected output
ERROR 3380 (HY000): Cannot create temporary table inside a transaction when GTID mode is enabled.
Fix
Separate temporary table creation from DML transactions
Separate temporary table creation from DML transactions
CREATE TEMPORARY TABLE tmp (id INT); START TRANSACTION; INSERT INTO t VALUES (1); COMMIT;
Why this works
Temporary table creation is outside the transaction, satisfying GTID replication constraints.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3380 ER_GTID_UNSAFE_CREATE_TEMPORARY_TABLE_IN_TRANSACTION
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev