1100
MariaDBERRORCommonDMLHIGH confidence

Table was not locked with LOCK TABLES

Production Risk

Low — query fails; no data is affected.

What this means

ER_TABLE_NOT_LOCKED (1100, SQLSTATE HY000) is raised when a session issues a statement against a table that was not included in a preceding LOCK TABLES statement. Once LOCK TABLES is in effect, only locked tables can be accessed.

Why it happens
  1. 1LOCK TABLES was called but the target table was not listed
  2. 2Query references an additional table (e.g., joined table) that was not locked
How to reproduce
trigger — this will error
trigger — this will error
LOCK TABLES t1 READ;
SELECT * FROM t2; -- t2 was not locked

expected output

ERROR 1100 (HY000): Table 't2' was not locked with LOCK TABLES

Fix

Include all required tables in LOCK TABLES

WHEN Using explicit table locking.

Include all required tables in LOCK TABLES
LOCK TABLES t1 READ, t2 READ;
SELECT * FROM t1 JOIN t2 ON t1.id = t2.id;
UNLOCK TABLES;

Why this works

LOCK TABLES creates an exclusive locking context; every table used in the session must be listed.

What not to do

Use LOCK TABLES in application code as a substitute for transactions

LOCK TABLES is a session-level lock that does not integrate with InnoDB transactions; use BEGIN/COMMIT with SELECT ... FOR UPDATE instead.

Sources
Official documentation ↗

MySQL 8.0 — 1100 ER_TABLE_NOT_LOCKED

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

← All MariaDB errors