1488
MariaDBERRORNotablePartitioningHIGH confidence

Mismatch with number of subpartitions

Production Risk

Low — DDL error; the table will not be created.

What this means

ER_PARTITION_SUBPARTITION_ERROR (1488, SQLSTATE HY000) is raised when the number of explicitly defined subpartitions does not match the expected count.

Why it happens
  1. 1SUBPARTITIONS N set but a different number of subpartitions explicitly defined
  2. 2Some partitions have subpartitions defined and others do not
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (id INT, created DATE)
PARTITION BY RANGE(YEAR(created))
SUBPARTITION BY HASH(id) SUBPARTITIONS 2 (
  PARTITION p0 VALUES LESS THAN (2020) (
    SUBPARTITION sp0  -- Only 1 defined, expected 2
  )
);

expected output

ERROR 1488 (HY000): Mismatch in number of subpartitions

Fix

Define the correct number of subpartitions

Define the correct number of subpartitions
CREATE TABLE t (id INT, created DATE)
PARTITION BY RANGE(YEAR(created))
SUBPARTITION BY HASH(id) SUBPARTITIONS 2 (
  PARTITION p0 VALUES LESS THAN (2020) (
    SUBPARTITION sp0,
    SUBPARTITION sp1  -- Matches SUBPARTITIONS 2
  )
);

Why this works

The number of explicitly defined subpartitions must match the SUBPARTITIONS N count.

Sources
Official documentation ↗

MySQL 8.0 — 1488 ER_PARTITION_SUBPARTITION_ERROR

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

← All MariaDB errors