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

Partitioning changes the query result after ADD PARTITION or REORGANIZE PARTITION on a LIST table with a DEFAULT partition

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
       
      CREATE TABLE t1 (a INT) PARTITION BY LIST (a) (PARTITION p0 VALUES IN (1), PARTITION pd DEFAULT);
      INSERT INTO t1 VALUES (1),(2);
      # The row 2 is in pd. After this, it belongs in p2
      ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES IN (2));
      --let $c= query_get_value(SELECT COUNT(*) AS c FROM t1 WHERE a=2, c, 1)
      if ($c != 1)
      {
        --die The row 2 is not found by a=2 after ADD PARTITION took the value 2 out of the DEFAULT partition
      }
       
      CREATE TABLE t2 (a INT) PARTITION BY LIST (a) (PARTITION p0 VALUES IN (1), PARTITION pd DEFAULT);
      INSERT INTO t2 VALUES (1),(2);
      ALTER TABLE t2 REORGANIZE PARTITION p0 INTO (PARTITION p0 VALUES IN (1), PARTITION p2 VALUES IN (2));
      --let $c= query_get_value(SELECT COUNT(*) AS c FROM t2 WHERE a=2, c, 1)
      if ($c != 1)
      {
        --die The row 2 is not found by a=2 after REORGANIZE PARTITION took the value 2 out of the DEFAULT partition
      }
      DROP TABLE t1, t2;

      Leads to:

      CS 13.1.0 da18481158c81ca94689702073c3e04aad85a6a3 (Debug, Clang 22.1.8-20260622) Build 18/08/2026

      mysqltest: At line 10: The row 2 is not found by a=2 after ADD PARTITION took the value 2 out of the DEFAULT partition

      Partitioning changes the query result. Without partitioning, a=2 finds the row. After the ADD PARTITION, the row 2 stays in pd and p2 is empty. The t2 part, with REORGANIZE PARTITION, fails in the same way when run on its own. InnoDB and optimized builds give the same result.

      From the code it seems that ADD PARTITION for LIST only adds an empty partition. In prep_alter_part_table() in sql/sql_partition.cc, a RANGE table with MAXVALUE refuses ADD PARTITION. A LIST table with a DEFAULT partition refuses it only when the new partition is a DEFAULT partition as well. MDEV-10760 describes a full rebuild of the table for this case.

      main.partition_default has the same case. After ADD PARTITION (PARTITION p0 VALUES IN (2,3)), its result file shows 0 rows in p0 and 2 rows in pd.

      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 - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 55m
                  55m

                  Git Integration

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