mirror of
https://github.com/MariaDB/server.git
synced 2025-12-07 17:42:39 +03:00
* one `AS OF NOW`, multiple `VERSIONING` partitions; * rotation of `VERSIONING` partitions by record count, time period; * rotation is multi-threaded; * conventional subpartitions as bottom level for versioned partitions; * `DEFAULT` keyword selects first `VERSIONING` partition; * ALTER TABLE ADD/DROP partition; * REBUILD PARTITION basic operation.
238 lines
6.0 KiB
Plaintext
238 lines
6.0 KiB
Plaintext
create table t1 (x int)
|
|
with system versioning
|
|
engine innodb
|
|
partition by range columns (x) (
|
|
partition p0 values less than (100),
|
|
partition p1 values less than (1000));
|
|
insert into t1 values (3), (300);
|
|
select * from t1;
|
|
x
|
|
3
|
|
300
|
|
select * from t1 partition (p0);
|
|
x
|
|
3
|
|
select * from t1 partition (p1);
|
|
x
|
|
300
|
|
delete from t1;
|
|
select * from t1;
|
|
x
|
|
select * from t1 for system_time all;
|
|
x
|
|
3
|
|
300
|
|
select * from t1 partition (p0) for system_time all;
|
|
x
|
|
3
|
|
select * from t1 partition (p1) for system_time all;
|
|
x
|
|
300
|
|
create or replace table t1 (x int)
|
|
partition by system_time (
|
|
partition p0 as of now,
|
|
partition p1 versioning);
|
|
ERROR HY000: System Versioning required: `BY SYSTEM_TIME` partitioning
|
|
create or replace table t1 (x int);
|
|
alter table t1
|
|
partition by system_time (
|
|
partition p0 as of now,
|
|
partition p1 versioning);
|
|
ERROR HY000: System Versioning required: `BY SYSTEM_TIME` partitioning
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 as of now);
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: unexpected number of partitions (expected > 1)
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 as of now,
|
|
partition p1 as of now);
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `AS OF NOW` partitions
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 versioning,
|
|
partition p1 versioning);
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: no `AS OF NOW` partition defined
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 as of now,
|
|
partition p1 versioning);
|
|
alter table t1 add partition (
|
|
partition p2 as of now);
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `AS OF NOW` partitions
|
|
alter table t1 add partition (
|
|
partition p2 versioning default);
|
|
Warnings:
|
|
Warning 4078 Maybe missing parameters: no rotation condition for multiple `VERSIONING` partitions.
|
|
alter table t1 drop partition p0;
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: `AS OF NOW` partition can not be dropped
|
|
alter table t1 drop partition p2;
|
|
alter table t1 drop partition p1;
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: one `AS OF NOW` and at least one `VERSIONING` partition required
|
|
insert into t1 values (1);
|
|
select * from t1;
|
|
x
|
|
1
|
|
select * from t1 partition (p0);
|
|
x
|
|
1
|
|
select * from t1 partition (p1);
|
|
x
|
|
delete from t1;
|
|
select * from t1 partition (p0) for system_time all;
|
|
x
|
|
select * from t1 partition (p1) for system_time all;
|
|
x
|
|
1
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 versioning,
|
|
partition p1 as of now);
|
|
insert into t1 values (1);
|
|
select * from t1;
|
|
x
|
|
1
|
|
select * from t1 partition (p0);
|
|
x
|
|
select * from t1 partition (p1);
|
|
x
|
|
1
|
|
delete from t1;
|
|
select * from t1 partition (p0) for system_time all;
|
|
x
|
|
1
|
|
select * from t1 partition (p1) for system_time all;
|
|
x
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
engine myisam
|
|
partition by system_time limit 1 (
|
|
partition p0 as of now,
|
|
partition p1 versioning,
|
|
partition p2 versioning);
|
|
Warnings:
|
|
Warning 4078 No `DEFAULT` for `VERSIONING` partitions. Setting `p1` as default.
|
|
insert into t1 values (1), (2);
|
|
select * from t1 partition (p0);
|
|
x
|
|
1
|
|
2
|
|
delete from t1;
|
|
Warnings:
|
|
Note 4079 Switching from partition `p1` to `p2`
|
|
select * from t1 partition (p1) for system_time all;
|
|
x
|
|
1
|
|
select * from t1 partition (p2) for system_time all;
|
|
x
|
|
2
|
|
insert into t1 values (3);
|
|
delete from t1;
|
|
Warnings:
|
|
Warning 4077 Using full partition `p2`, need more VERSIONING partitions!
|
|
select * from t1 partition (p2) for system_time all;
|
|
x
|
|
2
|
|
3
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
engine myisam
|
|
partition by system_time interval 1 second (
|
|
partition p0 as of now,
|
|
partition p1 versioning default,
|
|
partition p2 versioning);
|
|
insert into t1 values (1), (2), (3);
|
|
select * from t1 partition (p0);
|
|
x
|
|
1
|
|
2
|
|
3
|
|
delete from t1;
|
|
select * from t1 partition (p1) for system_time all;
|
|
x
|
|
1
|
|
2
|
|
3
|
|
insert into t1 values (4);
|
|
delete from t1;
|
|
Warnings:
|
|
Note 4079 Switching from partition `p1` to `p2`
|
|
select * from t1 partition (p2) for system_time all;
|
|
x
|
|
4
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
engine myisam
|
|
partition by system_time limit 1 (
|
|
partition p0 as of now,
|
|
partition p1 versioning default,
|
|
partition p2 versioning default);
|
|
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `DEFAULT` partitions
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
engine myisam
|
|
partition by system_time limit 1 (
|
|
partition p0 as of now,
|
|
partition p1 versioning,
|
|
partition p2 versioning default);
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL,
|
|
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
|
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
|
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME LIMIT 1
|
|
(PARTITION p0 AS OF NOW ENGINE = MyISAM,
|
|
PARTITION p1 VERSIONING ENGINE = MyISAM,
|
|
PARTITION p2 VERSIONING DEFAULT ENGINE = MyISAM)
|
|
insert into t1 values (4), (5);
|
|
delete from t1;
|
|
Warnings:
|
|
Note 4079 Switching from partition `p2` to `p1`
|
|
select * from t1 partition (p2) for system_time all;
|
|
x
|
|
4
|
|
select * from t1 partition (p1) for system_time all;
|
|
x
|
|
5
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
engine myisam
|
|
partition by system_time limit 1
|
|
subpartition by key (x)
|
|
subpartitions 2 (
|
|
partition p0 as of now,
|
|
partition p1 versioning default,
|
|
partition p2 versioning);
|
|
insert into t1 (x) values (1), (2), (3);
|
|
select * from t1 partition (p0sp0);
|
|
x
|
|
1
|
|
3
|
|
select * from t1 partition (p0sp1);
|
|
x
|
|
2
|
|
delete from t1;
|
|
Warnings:
|
|
Note 4079 Switching from partition `p1` to `p2`
|
|
Warning 4077 Using full partition `p2`, need more VERSIONING partitions!
|
|
select * from t1 partition (p1sp0) for system_time all;
|
|
x
|
|
1
|
|
select * from t1 partition (p1sp1) for system_time all;
|
|
x
|
|
select * from t1 partition (p2sp0) for system_time all;
|
|
x
|
|
3
|
|
select * from t1 partition (p2sp1) for system_time all;
|
|
x
|
|
2
|
|
drop table t1;
|