From 5b3ed2cad156205d98b31dfd69e9bab5898df046 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Tue, 7 Sep 2021 20:46:53 +0300 Subject: MDEV-22165 CONVERT TABLE: move in partition from existing table Syntax for CONVERT TABLE ALTER TABLE tbl_name [alter_option [, alter_option] ...] | [partition_options] partition_option: { ... | CONVERT TABLE tbl_name TO PARTITION partition_name partition_spec } Examples: ALTER TABLE t1 CONVERT TABLE tp2 TO PARTITION p2 VALUES LESS THAN MAX_VALUE(); New ALTER_PARTITION_CONVERT_IN command for fast_alter_partition_table() is done in alter_partition_convert_in() function which basically does ha_rename_table(). Table structure and data check is basically the same as in EXCHANGE PARTITION command. And these are done by compare_table_with_partition() and check_table_data(). Atomic DDL is done by the scheme from MDEV-22166 (see the corresponding commit message). The only differnce is that it also has to drop source table frm and that is done by WFRM_DROP_CONVERTED_FROM. --- sql/sql_partition.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/sql_partition.h') diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 04db1036c9e..795b3dbcda9 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -279,6 +279,10 @@ bool verify_data_with_partition(TABLE *table, TABLE *part_table, uint32 part_id); bool compare_partition_options(HA_CREATE_INFO *table_create_info, partition_element *part_elem); +bool compare_table_with_partition(THD *thd, TABLE *table, + TABLE *part_table, + partition_element *part_elem, + uint part_id); bool partition_key_modified(TABLE *table, const MY_BITMAP *fields); bool write_log_replace_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint next_entry, -- cgit v1.2.1