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

REORGANIZE PARTITION gives a LIST table a second DEFAULT partition, and the table can no longer be opened

    XMLWordPrintable

Details

    Description

      Likely cause: MDEV-8348, commit 4ec088f2e76a8004c270d28d042f548c0f81e5f7, which added the DEFAULT partition for LIST partitioning in CS 10.2.2. It refuses a second DEFAULT partition for ADD PARTITION, but not for REORGANIZE PARTITION. CS 10.4.25 gives the same result.

      --source include/have_partition.inc
      CREATE TABLE t1 (a INT) PARTITION BY LIST (a) (PARTITION p1 VALUES IN (1), PARTITION pd DEFAULT);
      INSERT INTO t1 VALUES (1), (2);
      --error 0,ER_PARTITION_DEFAULT_ERROR
      ALTER TABLE t1 REORGANIZE PARTITION p1 INTO (PARTITION p1 VALUES IN (1), PARTITION pd2 DEFAULT);
      --error 0,ER_PARTITION_DEFAULT_ERROR
      SELECT COUNT(*) FROM t1;
      if ($mysql_errno)
      {
        --die The table t1 cannot be opened after REORGANIZE PARTITION gave it a second DEFAULT partition
      }
      DROP TABLE t1;

      Leads to:

      CS 13.1.2 c8e6ab229f030119c19f3208d40f415decb41dae (Debug, Clang 22.1.8-20260622) Build 19/11/2026

      mysqltest: At line 10: The table t1 cannot be opened after REORGANIZE PARTITION gave it a second DEFAULT partition

      The ALTER TABLE succeeds. After it, SELECT, INSERT, SHOW CREATE TABLE, ALTER TABLE t1 DROP PARTITION pd2 and ALTER TABLE t1 REMOVE PARTITIONING all give ERROR 4030 (HY000): Only one DEFAULT partition allowed, and SELECT still does after a restart. CHECK TABLE and REPAIR TABLE report the table as corrupt. DROP TABLE works, but the rows can no longer be read. InnoDB and LIST COLUMNS give the same result. On the table before the REORGANIZE PARTITION, ALTER TABLE t1 ADD PARTITION (PARTITION pd2 DEFAULT) is refused with ERROR 4030.

      MySQL does not have DEFAULT partitions.

      From the code it seems that prep_alter_part_table() in sql/sql_partition.cc refuses a second DEFAULT partition for ADD PARTITION, but its REORGANIZE PARTITION branch has no such check. When the table is opened, partition_info::fix_parser_data() finds the second DEFAULT partition in the partition clause and gives ER_PARTITION_DEFAULT_ERROR.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 20m
                  20m

                  Git Integration

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