mirror of
https://github.com/MariaDB/server.git
synced 2025-12-06 05:42:06 +03:00
153 lines
3.9 KiB
Plaintext
153 lines
3.9 KiB
Plaintext
### check System Versioning and conventional partitioning
|
|
|
|
create table t1 (x int)
|
|
with system versioning
|
|
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;
|
|
select * from t1 partition (p0);
|
|
select * from t1 partition (p1);
|
|
|
|
delete from t1;
|
|
select * from t1;
|
|
select * from t1 for system_time all;
|
|
select * from t1 partition (p0) for system_time all;
|
|
select * from t1 partition (p1) for system_time all;
|
|
|
|
### check server-level partitioning
|
|
|
|
# create errors
|
|
--error ER_VERSIONING_REQUIRED
|
|
create or replace table t1 (x int)
|
|
partition by system_time (
|
|
partition p0 versioning,
|
|
partition pn as of now);
|
|
|
|
create or replace table t1 (x int);
|
|
--error ER_VERSIONING_REQUIRED
|
|
alter table t1
|
|
partition by system_time (
|
|
partition p0 versioning,
|
|
partition pn as of now);
|
|
|
|
--error ER_VERS_WRONG_PARAMS
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 as of now);
|
|
|
|
--error ER_VERS_WRONG_PARAMS
|
|
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 ER_VERS_WRONG_PARAMS
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 versioning,
|
|
partition p1 versioning);
|
|
|
|
--error ER_VERS_WRONG_PARAMS
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition pn as of now,
|
|
partition p0 versioning);
|
|
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 versioning,
|
|
partition pn as of now);
|
|
|
|
# alter table
|
|
--error ER_VERS_WRONG_PARAMS
|
|
alter table t1 add partition (
|
|
partition p1 as of now);
|
|
|
|
alter table t1 add partition (
|
|
partition p1 versioning);
|
|
|
|
--replace_result InnoDB ${INNODB_OR_MYISAM} MyISAM ${INNODB_OR_MYISAM} "bigint(20) unsigned" ${SYS_TRX_TYPE} timestamp(6) ${SYS_TRX_TYPE}
|
|
show create table t1;
|
|
|
|
--error ER_VERS_WRONG_PARAMS
|
|
alter table t1 drop partition pn;
|
|
alter table t1 drop partition p1;
|
|
--error ER_VERS_WRONG_PARAMS
|
|
alter table t1 drop partition p0;
|
|
|
|
# insertion, deletion
|
|
insert into t1 values (1);
|
|
select * from t1;
|
|
select * from t1 partition (p0);
|
|
select * from t1 partition (pn);
|
|
|
|
delete from t1;
|
|
select * from t1 partition (p0) for system_time all;
|
|
select * from t1 partition (pn) for system_time all;
|
|
|
|
# rotation by LIMIT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time limit 1 (
|
|
partition p0 versioning,
|
|
partition p1 versioning,
|
|
partition pn as of now);
|
|
|
|
insert into t1 values (1), (2);
|
|
select * from t1 partition (pn);
|
|
delete from t1;
|
|
select * from t1 partition (p0) for system_time all;
|
|
select * from t1 partition (p1) for system_time all;
|
|
|
|
insert into t1 values (3);
|
|
delete from t1;
|
|
select * from t1 partition (p1) for system_time all;
|
|
|
|
# rotation by INTERVAL
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time interval 1 second (
|
|
partition p0 versioning,
|
|
partition p1 versioning,
|
|
partition pn as of now);
|
|
|
|
insert into t1 values (1), (2), (3);
|
|
select * from t1 partition (pn);
|
|
delete from t1;
|
|
select * from t1 partition (p0) for system_time all;
|
|
|
|
--sleep 2
|
|
insert into t1 values (4);
|
|
delete from t1;
|
|
select * from t1 partition (p1) for system_time all;
|
|
|
|
# Subpartitions
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time limit 1
|
|
subpartition by key (x)
|
|
subpartitions 2 (
|
|
partition p0 versioning,
|
|
partition p1 versioning,
|
|
partition pn as of now);
|
|
|
|
insert into t1 (x) values (1), (2), (3);
|
|
select * from t1 partition (pnsp0);
|
|
select * from t1 partition (pnsp1);
|
|
|
|
delete from t1;
|
|
select * from t1 partition (p0sp0) for system_time all;
|
|
select * from t1 partition (p0sp1) for system_time all;
|
|
select * from t1 partition (p1sp0) for system_time all;
|
|
select * from t1 partition (p1sp1) for system_time all;
|
|
|
|
drop table t1;
|