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

ALTER TABLE IMPORT enhancement for Partitioned tables

    XMLWordPrintable

Details

    Description

      Import tablespace for partitioned tables is a horrible fragile procedure.

      MDEV-26317 implemented for InnoDB the pure ALTER TABLE t2 IMPORT TABLESPACE.

      Extending the partition starts with:

      diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
      index 5b6cbd35e25..ba33526662f 100644
      --- a/sql/ha_partition.cc
      +++ b/sql/ha_partition.cc
      @@ -740,6 +740,12 @@ int ha_partition::create_partitioning_metadata(const char *path,
       }
       
       
      +int ha_partition::discard_or_import_tablespace(my_bool discard)
      +{
      +  if (m_innodb) return 0;
      +  return handler::discard_or_import_tablespace(discard);
      +}
      +
       /*
         Create a partitioned table
       
      diff --git a/sql/ha_partition.h b/sql/ha_partition.h
      index d450f96f4f9..7676b1887bb 100644
      --- a/sql/ha_partition.h
      +++ b/sql/ha_partition.h
      @@ -545,6 +545,7 @@ class ha_partition final :public handler
         */
         int delete_table(const char *from) override;
         int rename_table(const char *from, const char *to) override;
      +  int discard_or_import_tablespace(my_bool discard) override;
         int create(const char *name, TABLE *form,
                    HA_CREATE_INFO *create_info) override;
         int create_partitioning_metadata(const char *name,
      
      

      But there seems to be a bit more to iron out:

      MariaDB [import]> show tables;
       
      +------------------+
      | Tables_in_import |
      +------------------+
      | t1               |
      +------------------+
      1 row in set (0.004 sec)
       
      MariaDB [import]> alter table t2 import tablespace;
      Query OK, 0 rows affected (0.001 sec)
       
      MariaDB [import]> select * from t2;
      ERROR 1814 (HY000): Tablespace has been discarded for table `t2`
       
      MariaDB [import]> show create table t2\G
      *************************** 1. row ***************************
             Table: t2
      Create Table: CREATE TABLE `t2` (
        `employee_id` int(11) DEFAULT NULL,
        `name` varchar(50) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
       PARTITION BY RANGE (`employee_id`)
      (PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB,
       PARTITION `p1` VALUES LESS THAN (11) ENGINE = InnoDB,
       PARTITION `p2` VALUES LESS THAN (16) ENGINE = InnoDB,
       PARTITION `p3` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
      1 row in set (0.000 sec)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              danblack Daniel Black
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.