mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-22166 CONVERT PARTITION: move out partition into a table
Syntax for CONVERT keyword ALTER TABLE tbl_name [alter_option [, alter_option] ...] | [partition_options] partition_option: { ... | CONVERT PARTITION partition_name TO TABLE tbl_name } Examples: ALTER TABLE t1 CONVERT PARTITION p2 TO TABLE tp2; New ALTER_PARTITION_CONVERT_OUT command for fast_alter_partition_table() is done in alter_partition_convert_out() function which basically does ha_rename_table(). Partition to extract is marked with the same flag as dropped partition: PART_TO_BE_DROPPED. Note that we cannot have multiple partitioning commands in one ALTER. For DDL logging basically the principle is the same as for other fast_alter_partition_table() commands. The only difference is that it integrates late Atomic DDL functions and introduces additional phase of WFRM_BACKUP_ORIGINAL. That is required for binlog consistency because otherwise we could not revert back after WFRM_INSTALL_SHADOW is done. And before DDL log is complete if we crash or fail the altered table will be already new but binlog will miss that ALTER command. Note that this is different from all other atomic DDL in that it rolls back until the ddl_log_complete() is done even if everything was done fully before the crash. Test cases added to: parts.alter_table \ parts.partition_debug \ versioning.partition \ atomic.alter_partition
This commit is contained in:
committed by
Sergei Golubchik
parent
f6b0e34c38
commit
b7bba721ee
85
mysql-test/suite/versioning/r/partition,heap.rdiff
Normal file
85
mysql-test/suite/versioning/r/partition,heap.rdiff
Normal file
@@ -0,0 +1,85 @@
|
||||
--- partition.result
|
||||
+++ partition,heap.reject
|
||||
@@ -1545,82 +1545,3 @@
|
||||
(PARTITION `p0` HISTORY ENGINE = X,
|
||||
PARTITION `pn` CURRENT ENGINE = X)
|
||||
drop tables t1, tp1;
|
||||
-# Complex table
|
||||
-create or replace table t1 (
|
||||
-x int primary key auto_increment,
|
||||
-t timestamp(6) default '2001-11-11 11:11:11',
|
||||
-b blob(4096) compressed null,
|
||||
-c varchar(1033) character set utf8 not null,
|
||||
-u int,
|
||||
-unique key (x, u),
|
||||
-m enum('a', 'b', 'c') not null default 'a' comment 'absolute',
|
||||
-i1 tinyint, i2 smallint, i3 bigint,
|
||||
-index three(i1, i2, i3),
|
||||
-v1 timestamp(6) generated always as (t + interval 1 day),
|
||||
-v2 timestamp(6) generated always as (t + interval 1 month) stored,
|
||||
-s timestamp(6) as row start,
|
||||
-e timestamp(6) as row end,
|
||||
-period for system_time (s, e),
|
||||
-ps date, pe date,
|
||||
-period for app_time (ps, pe),
|
||||
-constraint check_constr check (u > -1))
|
||||
-with system versioning default charset=ucs2
|
||||
-partition by range(x) (
|
||||
-partition p0 values less than (10),
|
||||
-partition p1 values less than (20),
|
||||
-partition pn values less than maxvalue);
|
||||
-alter table t1 convert partition p1 to table tp1;
|
||||
-show create table tp1;
|
||||
-Table Create Table
|
||||
-tp1 CREATE TABLE `tp1` (
|
||||
- `x` int(11) NOT NULL AUTO_INCREMENT,
|
||||
- `t` timestamp(6) NOT NULL DEFAULT '2001-11-11 11:11:11.000000',
|
||||
- `b` blob /*!100301 COMPRESSED*/ DEFAULT NULL,
|
||||
- `c` varchar(1033) CHARACTER SET utf8mb3 NOT NULL,
|
||||
- `u` int(11) DEFAULT NULL,
|
||||
- `m` enum('a','b','c') NOT NULL DEFAULT 'a' COMMENT 'absolute',
|
||||
- `i1` tinyint(4) DEFAULT NULL,
|
||||
- `i2` smallint(6) DEFAULT NULL,
|
||||
- `i3` bigint(20) DEFAULT NULL,
|
||||
- `v1` timestamp(6) GENERATED ALWAYS AS (`t` + interval 1 day) VIRTUAL,
|
||||
- `v2` timestamp(6) GENERATED ALWAYS AS (`t` + interval 1 month) STORED,
|
||||
- `s` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
- `e` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
- `ps` date NOT NULL,
|
||||
- `pe` date NOT NULL,
|
||||
- PERIOD FOR `app_time` (`ps`, `pe`),
|
||||
- PRIMARY KEY (`x`,`e`),
|
||||
- UNIQUE KEY `x` (`x`,`u`,`e`),
|
||||
- KEY `three` (`i1`,`i2`,`i3`),
|
||||
- PERIOD FOR SYSTEM_TIME (`s`, `e`),
|
||||
- CONSTRAINT `check_constr` CHECK (`u` > -1)
|
||||
-) ENGINE=X DEFAULT CHARSET=ucs2 WITH SYSTEM VERSIONING
|
||||
-show create table t1;
|
||||
-Table Create Table
|
||||
-t1 CREATE TABLE `t1` (
|
||||
- `x` int(11) NOT NULL AUTO_INCREMENT,
|
||||
- `t` timestamp(6) NOT NULL DEFAULT '2001-11-11 11:11:11.000000',
|
||||
- `b` blob /*!100301 COMPRESSED*/ DEFAULT NULL,
|
||||
- `c` varchar(1033) CHARACTER SET utf8mb3 NOT NULL,
|
||||
- `u` int(11) DEFAULT NULL,
|
||||
- `m` enum('a','b','c') NOT NULL DEFAULT 'a' COMMENT 'absolute',
|
||||
- `i1` tinyint(4) DEFAULT NULL,
|
||||
- `i2` smallint(6) DEFAULT NULL,
|
||||
- `i3` bigint(20) DEFAULT NULL,
|
||||
- `v1` timestamp(6) GENERATED ALWAYS AS (`t` + interval 1 day) VIRTUAL,
|
||||
- `v2` timestamp(6) GENERATED ALWAYS AS (`t` + interval 1 month) STORED,
|
||||
- `s` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
- `e` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
- `ps` date NOT NULL,
|
||||
- `pe` date NOT NULL,
|
||||
- PERIOD FOR `app_time` (`ps`, `pe`),
|
||||
- PRIMARY KEY (`x`,`e`),
|
||||
- UNIQUE KEY `x` (`x`,`u`,`e`),
|
||||
- KEY `three` (`i1`,`i2`,`i3`),
|
||||
- PERIOD FOR SYSTEM_TIME (`s`, `e`),
|
||||
- CONSTRAINT `check_constr` CHECK (`u` > -1)
|
||||
-) ENGINE=X DEFAULT CHARSET=ucs2 WITH SYSTEM VERSIONING
|
||||
- PARTITION BY RANGE (`x`)
|
||||
-(PARTITION `p0` VALUES LESS THAN (10) ENGINE = X,
|
||||
- PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X)
|
||||
-drop tables t1, tp1;
|
Reference in New Issue
Block a user