3348
MariaDBERRORNotableDDL / IndexesHIGH confidence
Functional index cannot be used as or contain a PRIMARY KEY
Production Risk
Low — DDL fails; no table is created.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (col VARCHAR(100), PRIMARY KEY ((LOWER(col))));
expected output
ERROR 3348 (HY000): Functional index cannot be used as or contain a primary key.
Fix
Use a column as PK
Use a column as PK
CREATE TABLE t (id INT AUTO_INCREMENT PRIMARY KEY, col VARCHAR(100), INDEX idx ((LOWER(col))));
Why this works
A surrogate integer PK satisfies InnoDB requirements while a functional index serves expression lookups.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3348 ER_FUNCTIONAL_INDEX_PRIMARY_KEY
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev