1520
MariaDBERRORNotablePartitioningHIGH confidence

New partitions must have the correct number of subpartitions

Production Risk

Low — the ALTER TABLE fails; no data is affected.

What this means

ER_ADD_PARTITION_SUBPART_ERROR (1520, SQLSTATE HY000) is raised when adding a partition to a subpartitioned table with the wrong number of subpartitions.

Why it happens
  1. 1ADD PARTITION defines subpartitions that do not match the existing subpartition count
  2. 2Omitting subpartition definitions when the table uses explicit subpartitions
How to reproduce
trigger — this will error
trigger — this will error
-- Table has 2 subpartitions per partition
ALTER TABLE t ADD PARTITION (
  PARTITION p_new VALUES LESS THAN (2025) (
    SUBPARTITION sp0  -- Only 1 defined, but 2 expected
  )
);

expected output

ERROR 1520 (HY000): Trying to add partition(s) with wrong number of subpartitions

Fix

Define the correct number of subpartitions in the new partition

Define the correct number of subpartitions in the new partition
ALTER TABLE t ADD PARTITION (
  PARTITION p_new VALUES LESS THAN (2025) (
    SUBPARTITION sp0,
    SUBPARTITION sp1  -- Matches existing count of 2
  )
);

Why this works

New partitions must define the same number of subpartitions as existing partitions.

Sources
Official documentation ↗

MySQL 8.0 — 1520 ER_ADD_PARTITION_SUBPART_ERROR

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

← All MariaDB errors