1566
MySQLERRORNotablePartitioningHIGH confidence

Partition function is not allowed

Production Risk

Low — the DDL fails; no table is created.

What this means

The expression used as the partitioning function is not permitted.

Why it happens
  1. 1The partition function uses a disallowed expression such as a subquery, stored function, or non-deterministic function.
  2. 2A column used in partitioning is of an unsupported type.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (id INT, val VARCHAR(10))
PARTITION BY HASH(LENGTH(val)) PARTITIONS 4;

expected output

ERROR 1566 (HY000): This partition function is not allowed

Fix

Use a deterministic, allowed expression

Use a deterministic, allowed expression
CREATE TABLE t (id INT)
PARTITION BY HASH(id) PARTITIONS 4;

Why this works

Partitioning functions must be deterministic and use only integer-returning expressions on column values.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 1566 ER_PARTITION_FUNCTION_IS_NOT_ALLOWED

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

← All MySQL errors