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

CONVERT PARTITION ... TO TABLE loses the PAGE_COMPRESSED or CONNECTION option of the partition

    XMLWordPrintable

Details

    Description

      Likely cause: MDEV-22166, which added CONVERT PARTITION ... TO TABLE in CS 10.7. The definition of the new table is made from the options of the partitioned table, so the options set on the partition itself are lost.

      --source include/have_partition.inc
      --source include/have_innodb.inc
      CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (10) PAGE_COMPRESSED=1, PARTITION p1 VALUES LESS THAN MAXVALUE);
      INSERT INTO t1 VALUES (1), (11);
      ALTER TABLE t1 CONVERT PARTITION p0 TO TABLE t2;
      CREATE TABLE t3 LIKE t2;
      --let $f= `SELECT FLAG FROM information_schema.INNODB_SYS_TABLES WHERE NAME = 'test/t2'`
      --let $g= `SELECT FLAG FROM information_schema.INNODB_SYS_TABLES WHERE NAME = 'test/t3'`
      if ($f != $g)
      {
        --die The table made from a partition with PAGE_COMPRESSED=1 is page compressed, but its definition has no PAGE_COMPRESSED, InnoDB flags $f and $g
      }
      DROP TABLE t1, t2, t3;

      Leads to:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026

      mysqltest: At line 11: The table made from a partition with PAGE_COMPRESSED=1 is page compressed, but its definition has no PAGE_COMPRESSED, InnoDB flags 1697 and 33

      information_schema.INNODB_SYS_TABLES shows flags 1697 (page compressed) for t2, and 33 for t3, made with CREATE TABLE t3 LIKE t2. SHOW CREATE TABLE t2 has no PAGE_COMPRESSED, and after ALTER TABLE t2 FORCE the data of t2 is no longer page compressed. Debug builds give the same result.

      A table with PAGE_COMPRESSED=1 and a partition with PAGE_COMPRESSED=0 gives the opposite: the definition of t2 has PAGE_COMPRESSED, while its data is not page compressed. PAGE_COMPRESSION_LEVEL and ENCRYPTED=YES on a partition are also missing from the definition of t2.

      A FederatedX partition with its own CONNECTION gives a table that cannot be read. In the federated suite:

      --source have_federatedx.inc
      --source include/have_partition.inc
      --source include/federated.inc
      connection slave;
      CREATE TABLE federated.t1 (a INT) ENGINE=MyISAM;
      INSERT INTO federated.t1 VALUES (1);
      connection master;
      --replace_result $SLAVE_MYPORT SLAVE_PORT
      eval CREATE TABLE t1 (a INT) ENGINE=FEDERATED PARTITION BY LIST (a) (PARTITION p0 VALUES IN (1) CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1', PARTITION p1 VALUES IN (2) CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1');
      ALTER TABLE t1 CONVERT PARTITION p0 TO TABLE t2;
      --disable_abort_on_error
      SELECT a FROM t2;
      --enable_abort_on_error
      if ($mysql_errno)
      {
        --die The table made from a FederatedX partition with its own CONNECTION cannot be read
      }
      DROP TABLE t1, t2;
      connection slave;
      DROP TABLE federated.t1;
      connection master;
      --source include/federated_cleanup.inc

      Leads to:

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

      mysqltest: At line 16: The table made from a FederatedX partition with its own CONNECTION cannot be read
      SELECT a FROM t2;
      ERROR HY000: server name: '' doesn't exist!

      From the code it seems that mysql_write_frm() with WFRM_WRITE_CONVERTED_TO (sql/sql_table.cc) builds the definition of the new table from the create_info of the partitioned table, without the options of the converted partition. The other direction, CONVERT TABLE ... TO PARTITION, is in MDEV-33153.

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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