Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41628

INSERT fails with ERROR 1517 when a new INTERVAL partition gets the name of an existing partition or subpartition

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 13.1, 13.2
    • 13.1
    • Partitioning
    • None

    Description

      --source include/have_partition.inc
       
      SET timestamp= UNIX_TIMESTAMP('2026-05-02 00:00:00');
      --error 0,ER_PARSE_ERROR,ER_PARTITIONS_MUST_BE_DEFINED_ERROR
      CREATE TABLE t1 (c DATE) PARTITION BY RANGE COLUMNS (c) INTERVAL 1 DAY (PARTITION P1 VALUES LESS THAN ('2026-04-30'));
      if ($mysql_errno)
      {
        --skip Needs RANGE COLUMNS ... INTERVAL partitioning
      }
      # The row fits P1. The INSERT adds the partitions up to the current date
      --error 0,ER_SAME_NAME_PARTITION
      INSERT INTO t1 VALUES ('2026-04-25');
      if ($mysql_errno)
      {
        --die An INSERT fails with a duplicate partition name: the new INTERVAL partition p1 has the name of the existing partition P1
      }
      DROP TABLE t1;
       
      CREATE TABLE t1 (c DATE) PARTITION BY RANGE COLUMNS (c) INTERVAL 1 DAY SUBPARTITION BY KEY (c) (PARTITION p0 VALUES LESS THAN ('2026-04-30') (SUBPARTITION p1sp0, SUBPARTITION p1sp1));
      --error 0,ER_SAME_NAME_PARTITION
      INSERT INTO t1 VALUES ('2026-04-25');
      if ($mysql_errno)
      {
        --die An INSERT fails with a duplicate partition name: a subpartition of the new INTERVAL partition p1 has the name of the existing subpartition p1sp0
      }
      DROP TABLE t1;

      Leads to:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Debug, Clang 22.1.8-20260622) Build 06/10/2026

      mysqltest: At line 15: An INSERT fails with a duplicate partition name: the new INTERVAL partition p1 has the name of the existing partition P1

      The INSERT fails with ERROR 1517 (HY000): Duplicate partition name p1 and no row is added. Every later INSERT that needs a new partition fails the same way. With a lowercase p1, the new partitions are p2 to p4 and the INSERT works. Optimized builds give the same result.

      The second table, with the first gate passing, fails at its own gate:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Debug, Clang 22.1.8-20260622) Build 06/10/2026

      mysqltest: At line 24: An INSERT fails with a duplicate partition name: a subpartition of the new INTERVAL partition p1 has the name of the existing subpartition p1sp0

      From the code it seems that range_interval_next_part_no() in sql/sql_partition_auto_interval.cc picks the number for the new names from the partition names that start with a lowercase p only, and does not look at subpartition names. find_duplicate_name() in sql/partition_info.cc compares partition and subpartition names together and without case.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Time Spent - 1h Remaining Estimate - 1.5d
                  1.5d
                  Logged:
                  Time Spent - 1h Remaining Estimate - 1.5d
                  1h

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.