mirror of
https://github.com/MariaDB/server.git
synced 2025-04-01 04:45:37 +02:00

ADD default history partitions generates wrong partition name, f.ex. p2 instead of p1. Gap in sequence of partition names leads to ha_partition::open_read_partitions() fail on inexistent name. Manual fixing such broken table requires: 1. create empty table by any name (t_empty) with correct number of partitions; 2. stop the server; 3. rename data files (.myd, .myi or .ibd) of broken table to t_empty fixing the partition sequence (#p2 to #p1, #p3 to #p2); 4. start the server; 5. drop the broken table; 6. rename t_empty to correct table name.
1046 lines
38 KiB
Text
1046 lines
38 KiB
Text
call mtr.add_suppression("need more HISTORY partitions");
|
|
set system_versioning_alter_history=keep;
|
|
# Check conventional partitioning on temporal tables
|
|
create or replace table t1 (
|
|
x int,
|
|
row_start SYS_DATATYPE as row start invisible,
|
|
row_end SYS_DATATYPE as row end invisible,
|
|
period for system_time(row_start, row_end))
|
|
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;
|
|
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 partition (p0);
|
|
x
|
|
select * from t1 partition (p1);
|
|
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
|
|
# Engine change native <-> non-native versioning prohibited
|
|
create or replace table t1 (
|
|
i int,
|
|
row_start SYS_DATATYPE as row start invisible,
|
|
row_end SYS_DATATYPE as row end invisible,
|
|
period for system_time(row_start, row_end))
|
|
engine=DEFAULT_ENGINE
|
|
with system versioning partition by hash(i);
|
|
alter table t1 engine=NON_DEFAULT_ENGINE;
|
|
ERROR HY000: Not allowed for system-versioned `test`.`t1`. Change to/from native system versioning engine is not supported.
|
|
## CREATE TABLE
|
|
create or replace table t1 (x int)
|
|
partition by system_time (
|
|
partition p0 history,
|
|
partition pn current);
|
|
ERROR HY000: Table `t1` is not system-versioned
|
|
create or replace table t1 (x int);
|
|
alter table t1
|
|
partition by system_time (
|
|
partition p0 history,
|
|
partition pn current);
|
|
ERROR HY000: Table `t1` is not system-versioned
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 current);
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 current,
|
|
partition p1 current);
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 history,
|
|
partition p1 history);
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition pn current,
|
|
partition p0 history);
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0,
|
|
partition pn current);
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time (
|
|
partition p0 history,
|
|
partition pn current);
|
|
## ALTER TABLE
|
|
alter table t1 add partition (
|
|
partition p1 current);
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
alter table t1 add partition (
|
|
partition p1 history);
|
|
Warnings:
|
|
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
(PARTITION `p0` HISTORY ENGINE = DEFAULT_ENGINE,
|
|
PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
|
|
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
|
|
insert into t1 values (1), (2);
|
|
alter table t1 drop partition pn;
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
alter table t1 drop partition p1;
|
|
alter table t1 drop partition p0;
|
|
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
|
|
select x from t1;
|
|
x
|
|
1
|
|
2
|
|
# rename works
|
|
create or replace table t1 (x int) with system versioning
|
|
partition by system_time;
|
|
alter table t1 reorganize partition p0 into
|
|
(partition custom_name history);
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
(PARTITION `custom_name` HISTORY ENGINE = DEFAULT_ENGINE,
|
|
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
|
|
# merge and split doesn't (MDEV-19938)
|
|
create or replace table t1 (x int) with system versioning
|
|
partition by system_time partitions 3;
|
|
Warnings:
|
|
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
|
|
alter table t1 reorganize partition p0, p1 into (partition p00 history);
|
|
ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
|
|
alter table t1 reorganize partition p1 into (partition p1 history, partition p2 history);
|
|
ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
|
|
# Bug tempesta-tech/mariadb#260: incorrect IB partitioning warning
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time limit 1;
|
|
alter table t1 change x big int;
|
|
create or replace table t1 (i int) engine myisam partition by hash(i) partitions 2;
|
|
alter table t1 add partition (partition px history);
|
|
ERROR HY000: Wrong partitioning type, expected type: `SYSTEM_TIME`
|
|
## INSERT, UPDATE, DELETE
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time;
|
|
set @now= now(6);
|
|
insert into t1 values (1);
|
|
set @str= concat('select x, row_start < @now as A, row_end > @now as B from t1 partition (p0)');
|
|
prepare select_p0 from @str;
|
|
set @str= concat('select x, row_start > @now as C, row_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
|
|
prepare select_pn from @str;
|
|
execute select_p0;
|
|
x A B
|
|
execute select_pn;
|
|
x C D
|
|
1 1 1
|
|
set @str= concat('select row_start from t1 partition (pn) into @ts0');
|
|
prepare stmt from @str;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
execute stmt;
|
|
drop prepare stmt;
|
|
set @now= now(6);
|
|
delete from t1;
|
|
execute select_p0;
|
|
x A B
|
|
1 1 1
|
|
execute select_pn;
|
|
x C D
|
|
set @str= concat('select row_start from t1 partition (p0) into @ts1');
|
|
prepare stmt from @str;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
execute stmt;
|
|
drop prepare stmt;
|
|
select @ts0 = @ts1;
|
|
@ts0 = @ts1
|
|
1
|
|
set @now= now(6);
|
|
insert into t1 values (2);
|
|
execute select_p0;
|
|
x A B
|
|
1 1 0
|
|
execute select_pn;
|
|
x C D
|
|
2 1 1
|
|
set @str= concat('select row_start from t1 partition (pn) into @ts0');
|
|
prepare stmt from @str;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
execute stmt;
|
|
drop prepare stmt;
|
|
set @now= now(6);
|
|
update t1 set x = x + 1;
|
|
execute select_p0;
|
|
x A B
|
|
1 1 0
|
|
2 1 1
|
|
execute select_pn;
|
|
x C D
|
|
3 1 1
|
|
drop prepare select_p0;
|
|
drop prepare select_pn;
|
|
set @str= concat('select row_start from t1 partition (p0) where x = 2 into @ts1');
|
|
prepare stmt from @str;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
execute stmt;
|
|
drop prepare stmt;
|
|
set @str= concat('select row_end from t1 partition (p0) where x = 2 into @ts2');
|
|
prepare stmt from @str;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
execute stmt;
|
|
drop prepare stmt;
|
|
set @str= concat('select row_start from t1 partition (pn) into @ts3');
|
|
prepare stmt from @str;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
execute stmt;
|
|
drop prepare stmt;
|
|
select @ts0 = @ts1;
|
|
@ts0 = @ts1
|
|
1
|
|
select @ts2 = @ts3;
|
|
@ts2 = @ts3
|
|
1
|
|
## rotation by LIMIT
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time limit 0 partitions 3;
|
|
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT'
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time limit 2 partitions 3;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME LIMIT 2
|
|
PARTITIONS 3
|
|
alter table t1 drop partition non_existent;
|
|
ERROR HY000: Error in list of partitions to DROP
|
|
insert into t1 values (1), (2), (3), (4), (5), (6);
|
|
select * from t1 partition (pn);
|
|
x
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
delete from t1 where x < 4;
|
|
delete from t1;
|
|
select * from t1 partition (p0);
|
|
x
|
|
1
|
|
2
|
|
3
|
|
select * from t1 partition (p1);
|
|
x
|
|
4
|
|
5
|
|
6
|
|
insert into t1 values (7), (8);
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
|
|
### warn about full partition
|
|
delete from t1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
|
|
select * from t1 partition (p1) order by x;
|
|
x
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
## rotation by INTERVAL
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time interval 0 second partitions 3;
|
|
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
|
|
create table t1 (i int) with system versioning
|
|
partition by system_time interval 6 day limit 98;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'limit 98' at line 2
|
|
create or replace table t1 (pk int) with system versioning
|
|
partition by system_time interval 10 year partitions 3;
|
|
ERROR 22003: TIMESTAMP value is out of range in 'INTERVAL'
|
|
# INTERVAL and ALTER TABLE
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 hour;
|
|
set @ts=(select partition_description from information_schema.partitions
|
|
where table_schema='test' and table_name='t1' and partition_name='p0');
|
|
alter table t1 add column b int;
|
|
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
|
|
p0 1 SYSTEM_TIME 00:00:00.000000
|
|
pn 2 SYSTEM_TIME NULL
|
|
Warnings:
|
|
Warning 1292 Incorrect time value: 'CURRENT'
|
|
alter table t1 add partition (partition p1 history, partition p2 history);
|
|
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
|
|
p0 1 SYSTEM_TIME 00:00:00.000000
|
|
p1 2 SYSTEM_TIME 01:00:00.000000
|
|
p2 3 SYSTEM_TIME 02:00:00.000000
|
|
pn 4 SYSTEM_TIME NULL
|
|
Warnings:
|
|
Warning 1292 Incorrect time value: 'CURRENT'
|
|
alter table t1 drop partition p0;
|
|
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
|
|
p1 1 SYSTEM_TIME 01:00:00.000000
|
|
p2 2 SYSTEM_TIME 02:00:00.000000
|
|
pn 3 SYSTEM_TIME NULL
|
|
Warnings:
|
|
Warning 1292 Incorrect time value: 'CURRENT'
|
|
alter table t1 drop partition p2;
|
|
ERROR HY000: Can only drop oldest partitions when rotating by INTERVAL
|
|
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
|
|
p1 1 SYSTEM_TIME 01:00:00.000000
|
|
p2 2 SYSTEM_TIME 02:00:00.000000
|
|
pn 3 SYSTEM_TIME NULL
|
|
Warnings:
|
|
Warning 1292 Incorrect time value: 'CURRENT'
|
|
set timestamp=unix_timestamp('2001-02-03 10:20:30');
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day
|
|
subpartition by key (i) subpartitions 2
|
|
(partition p1 history, partition pn current);
|
|
set timestamp=unix_timestamp('2001-02-03 10:20:40');
|
|
insert t1 values (1);
|
|
delete from t1;
|
|
set timestamp=unix_timestamp('2001-02-04 10:20:50');
|
|
insert t1 values (2);
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
delete from t1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
select subpartition_name,partition_description,table_rows from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
subpartition_name partition_description table_rows
|
|
p1sp0 2001-02-04 00:00:00 1
|
|
p1sp1 2001-02-04 00:00:00 1
|
|
pnsp0 CURRENT 0
|
|
pnsp1 CURRENT 0
|
|
set timestamp=unix_timestamp('2001-02-04 10:20:55');
|
|
alter table t1 add partition (partition p0 history, partition p2 history);
|
|
set timestamp=unix_timestamp('2001-02-04 10:30:00');
|
|
insert t1 values (4),(5);
|
|
set timestamp=unix_timestamp('2001-02-04 10:30:10');
|
|
update t1 set i=6 where i=5;
|
|
select subpartition_name,partition_description,table_rows from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
subpartition_name partition_description table_rows
|
|
p1sp0 2001-02-04 00:00:00 1
|
|
p1sp1 2001-02-04 00:00:00 0
|
|
p0sp0 2001-02-05 00:00:00 1
|
|
p0sp1 2001-02-05 00:00:00 1
|
|
p2sp0 2001-02-06 00:00:00 0
|
|
p2sp1 2001-02-06 00:00:00 0
|
|
pnsp0 CURRENT 0
|
|
pnsp1 CURRENT 2
|
|
## pruning check
|
|
set @ts=(select partition_description from information_schema.partitions
|
|
where table_schema='test' and table_name='t1' and partition_name='p0' limit 1);
|
|
select * from t1;
|
|
i
|
|
4
|
|
6
|
|
explain partitions select * from t1;
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL # Using where
|
|
explain partitions select * from t1 for system_time as of '2001-02-04 10:20:30';
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p2_p2sp0,p2_p2sp1,pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL # Using where
|
|
set @ts=(select row_end from t1 for system_time all where i=1);
|
|
select * from t1 for system_time all where row_end = @ts;
|
|
i
|
|
1
|
|
explain partitions select * from t1 for system_time all where row_end = @ts;
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 p1_p1sp0,p1_p1sp1 # NULL NULL NULL NULL # #
|
|
## INTERVAL ... STARTS
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts 'a';
|
|
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '00:00:00';
|
|
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '2000-00-01 00:00:00';
|
|
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts 946684800;
|
|
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '2000-01-01 00:00:00';
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
|
|
PARTITIONS 2
|
|
# Test STARTS warning
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
|
|
PARTITIONS 2
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '2000-01-01 00:00:01';
|
|
Warnings:
|
|
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
|
|
# Test default STARTS rounding
|
|
set timestamp= unix_timestamp('1999-12-15 13:33:33');
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 second;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 SECOND STARTS TIMESTAMP'1999-12-15 13:33:33'
|
|
PARTITIONS 2
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 minute;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 MINUTE STARTS TIMESTAMP'1999-12-15 13:33:00'
|
|
PARTITIONS 2
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 hour;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR STARTS TIMESTAMP'1999-12-15 13:00:00'
|
|
PARTITIONS 2
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'1999-12-15 00:00:00'
|
|
PARTITIONS 2
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 month;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 MONTH STARTS TIMESTAMP'1999-12-15 00:00:00'
|
|
PARTITIONS 2
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 year;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 YEAR STARTS TIMESTAMP'1999-12-15 00:00:00'
|
|
PARTITIONS 2
|
|
# seconds equivalent of 1 day does not round:
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 86400 second;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 86400 SECOND STARTS TIMESTAMP'1999-12-15 13:33:33'
|
|
PARTITIONS 2
|
|
# STARTS value is in local time_zone:
|
|
set time_zone="+03:00";
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '2000-01-01 00:00:00';
|
|
Warnings:
|
|
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
|
create or replace table t2 (i int) with system versioning
|
|
partition by system_time interval 1 day;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
|
|
PARTITIONS 2
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
|
|
PARTITIONS 2
|
|
set time_zone="+00:00";
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'1999-12-31 21:00:00'
|
|
PARTITIONS 2
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`i` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'1999-12-31 21:00:00'
|
|
PARTITIONS 2
|
|
# Test rotation
|
|
set timestamp= unix_timestamp('2001-01-01 00:00:00');
|
|
# it's ok to add partitions for past:
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '2000-01-01 00:00:00'
|
|
partitions 3;
|
|
# we are warned when we push to present:
|
|
insert into t1 values (0);
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
set timestamp= unix_timestamp('2001-01-01 00:00:01');
|
|
update t1 set i= i + 1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
set timestamp= unix_timestamp('2001-01-01 00:00:02');
|
|
update t1 set i= i + 1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
select *, row_end from t1 partition (p0);
|
|
i row_end
|
|
select *, row_end from t1 partition (p1);
|
|
i row_end
|
|
0 2001-01-01 00:00:01.000000
|
|
1 2001-01-01 00:00:02.000000
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
|
# now we "overflow" first partition a bit:
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day starts '2000-01-03 00:00:00'
|
|
partitions 3;
|
|
Warnings:
|
|
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
|
|
insert into t1 values (0);
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:01');
|
|
update t1 set i= i + 1;
|
|
set timestamp= unix_timestamp('2000-01-02 00:00:01');
|
|
update t1 set i= i + 1;
|
|
set timestamp= unix_timestamp('2000-01-03 00:00:01');
|
|
update t1 set i= i + 1;
|
|
set timestamp= unix_timestamp('2000-01-04 00:00:01');
|
|
update t1 set i= i + 1;
|
|
select *, row_end from t1 partition (p0);
|
|
i row_end
|
|
0 2000-01-01 00:00:01.000000
|
|
1 2000-01-02 00:00:01.000000
|
|
2 2000-01-03 00:00:01.000000
|
|
select *, row_end from t1 partition (p1);
|
|
i row_end
|
|
3 2000-01-04 00:00:01.000000
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:00');
|
|
# and this is how it usually goes:
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day
|
|
partitions 3;
|
|
insert into t1 values (0);
|
|
set timestamp= unix_timestamp('2000-01-01 00:00:01');
|
|
update t1 set i= i + 1;
|
|
set timestamp= unix_timestamp('2000-01-02 00:00:01');
|
|
update t1 set i= i + 1;
|
|
set timestamp= unix_timestamp('2000-01-03 00:00:01');
|
|
update t1 set i= i + 1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
set timestamp= unix_timestamp('2000-01-04 00:00:01');
|
|
update t1 set i= i + 1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of INTERVAL, need more HISTORY partitions
|
|
alter table t1 add partition (partition p2 history, partition p3 history);
|
|
select *, row_end from t1 partition (p0);
|
|
i row_end
|
|
0 2000-01-01 00:00:01.000000
|
|
select *, row_end from t1 partition (p1);
|
|
i row_end
|
|
1 2000-01-02 00:00:01.000000
|
|
select *, row_end from t1 partition (p2);
|
|
i row_end
|
|
2 2000-01-03 00:00:01.000000
|
|
select *, row_end from t1 partition (p3);
|
|
i row_end
|
|
3 2000-01-04 00:00:01.000000
|
|
drop tables t1, t2;
|
|
## Subpartitions
|
|
create or replace table t1 (x int)
|
|
with system versioning
|
|
partition by system_time limit 2 partitions 3
|
|
subpartition by key (x)
|
|
subpartitions 2;
|
|
insert into t1 (x) values (1), (2), (3), (4), (5);
|
|
select * from t1 partition (pnsp0);
|
|
x
|
|
1
|
|
3
|
|
5
|
|
select * from t1 partition (pnsp1);
|
|
x
|
|
2
|
|
4
|
|
### warn about full partition
|
|
delete from t1 where x < 3;
|
|
delete from t1;
|
|
delete from t1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
|
|
select * from t1 partition (p0sp0);
|
|
x
|
|
1
|
|
select * from t1 partition (p0sp1);
|
|
x
|
|
2
|
|
select * from t1 partition (p1sp0);
|
|
x
|
|
3
|
|
5
|
|
select * from t1 partition (p1sp1);
|
|
x
|
|
4
|
|
# check implicit sys fields for implicit engine of partitioned table
|
|
create or replace table t1 (a bigint)
|
|
with system versioning
|
|
partition by range (a)
|
|
(partition p0 values less than (20) engine innodb,
|
|
partition p1 values less than maxvalue engine innodb);
|
|
insert into t1 values (1);
|
|
select * from t1 partition (p0);
|
|
a
|
|
1
|
|
# check for partition engine
|
|
create or replace table t1 (
|
|
f_int1 integer default 0
|
|
) with system versioning
|
|
partition by range(f_int1)
|
|
subpartition by hash(f_int1)
|
|
( partition part1 values less than (1000)
|
|
(subpartition subpart11 storage engine = 'innodb',
|
|
subpartition subpart12 storage engine = 'innodb'));
|
|
insert into t1 values (1);
|
|
select * from t1 partition (part1);
|
|
f_int1
|
|
1
|
|
#
|
|
# TRX_ID versioning (moved from partition_innodb.test)
|
|
#
|
|
# MDEV-15951 system versioning by trx id doesn't work with partitioning
|
|
# currently trx_id does not support partitioning by system_time
|
|
create or replace table t1(
|
|
i int,
|
|
row_start bigint unsigned generated always as row start,
|
|
row_end bigint unsigned generated always as row end,
|
|
period for system_time(row_start, row_end)
|
|
) engine=InnoDB with system versioning partition by system_time (
|
|
partition p0 history,
|
|
partition pn current
|
|
);
|
|
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
|
|
create or replace table t1(
|
|
i int,
|
|
row_start bigint unsigned generated always as row start,
|
|
row_end bigint unsigned generated always as row end,
|
|
period for system_time(row_start, row_end)
|
|
) engine=InnoDB with system versioning;
|
|
alter table t1 partition by system_time (
|
|
partition p0 history,
|
|
partition pn current
|
|
);
|
|
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
|
|
drop table t1;
|
|
create or replace table t (
|
|
a int primary key,
|
|
row_start bigint unsigned as row start invisible,
|
|
row_end bigint unsigned as row end invisible,
|
|
period for system_time(row_start, row_end)
|
|
) engine=innodb with system versioning
|
|
partition by key() (
|
|
partition p1,
|
|
partition p2
|
|
);
|
|
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
|
|
create or replace table t (
|
|
a int primary key,
|
|
row_start bigint unsigned as row start invisible,
|
|
row_end bigint unsigned as row end invisible,
|
|
period for system_time(row_start, row_end)
|
|
) engine=innodb with system versioning
|
|
partition by key(a, row_start) (
|
|
partition p1,
|
|
partition p2
|
|
);
|
|
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
|
|
create or replace table t (
|
|
a int primary key,
|
|
row_start bigint unsigned as row start invisible,
|
|
row_end bigint unsigned as row end invisible,
|
|
period for system_time(row_start, row_end)
|
|
) engine=innodb with system versioning
|
|
partition by hash(a + row_end * 2) (
|
|
partition p1,
|
|
partition p2
|
|
);
|
|
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
|
|
create or replace table t (
|
|
a int primary key,
|
|
row_start bigint unsigned as row start invisible,
|
|
row_end bigint unsigned as row end invisible,
|
|
period for system_time(row_start, row_end)
|
|
) engine=innodb with system versioning
|
|
partition by range columns (a, row_start) (
|
|
partition p1 values less than (100, 100)
|
|
);
|
|
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
|
|
#
|
|
# Assertion in ALTER on warning from partitioning LIMIT [#446]
|
|
#
|
|
create or replace table t1 (x int) with system versioning;
|
|
insert into t1 values (1), (2);
|
|
delete from t1;
|
|
alter table t1 partition by system_time limit 1 (
|
|
partition p1 history,
|
|
partition pn current);
|
|
#
|
|
# MDEV-14649 Assertion `t->mysql_col_len == 8' failed in row_insert_for_mysql
|
|
#
|
|
create or replace table t1 (i int) engine=innodb partition by key(i);
|
|
alter table t1 add system versioning;
|
|
insert into t1 values();
|
|
#
|
|
# MDEV-14722 Assertion in ha_commit_trans for sub-statement
|
|
#
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 day;
|
|
create or replace table t2 (f int);
|
|
create or replace trigger tr before insert on t2
|
|
for each row select table_rows from information_schema.tables
|
|
where table_name = 't1' into @a;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
insert into t2 values (1);
|
|
#
|
|
# MDEV-14740 Locking assertion for system_time partitioning
|
|
#
|
|
create or replace table t1 (i int) with system versioning
|
|
partition by system_time interval 1 week;
|
|
create or replace table t2 (f int);
|
|
create or replace trigger tr before insert on t2
|
|
for each row select count(*) from t1 into @a;
|
|
Warnings:
|
|
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
|
insert into t2 values (1);
|
|
#
|
|
# MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES
|
|
#
|
|
create or replace table t1 (x int) with system versioning;
|
|
lock table t1 write;
|
|
alter table t1 partition by system_time interval 1 week (
|
|
partition p1 history,
|
|
partition pn current);
|
|
unlock tables;
|
|
#
|
|
# MDEV-14748 Assertion in ha_myisammrg::attach_children()
|
|
#
|
|
create or replace table t1 (x int) engine=myisam with system versioning
|
|
partition by system_time interval 1 month (partition p1 history, partition pn current);
|
|
create or replace table t2 (x int) engine=myisam;
|
|
create or replace table t3 (x int) engine=merge union=(t2);
|
|
create or replace table t4 (x int) engine=myisam;
|
|
create or replace trigger tr after insert on t4 for each row insert into t2
|
|
( select x from t3 ) union ( select x from t1 );
|
|
insert into t4 values (1);
|
|
#
|
|
# MDEV-14821 Assertion failure
|
|
#
|
|
create or replace table t1 (x int) with system versioning;
|
|
insert into t1 values (0), (1);
|
|
update t1 set x= x + 1;
|
|
alter table t1 partition by system_time limit 1 (
|
|
partition p1 history,
|
|
partition p2 history,
|
|
partition pn current);
|
|
delete from t1 where x = 1;
|
|
delete from t1 where x = 2;
|
|
#
|
|
# MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
|
|
#
|
|
create or replace table t1 (x int) with system versioning
|
|
partition by system_time;
|
|
lock table t1 write;
|
|
alter table t1 add partition (partition p0 history);
|
|
ERROR HY000: Duplicate partition name p0
|
|
insert into t1 values (1);
|
|
unlock tables;
|
|
#
|
|
# MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
|
|
#
|
|
create or replace table t1 (pk int primary key, f int) with system versioning
|
|
partition by system_time limit 100;
|
|
insert into t1 values (1,10), (2,20);
|
|
create or replace view v1 as select * from t1;
|
|
update v1 set f= 30;
|
|
#
|
|
# MDEV-15168 Unexpected ER_VERS_ENGINE_UNSUPPORTED upon dropping versioning on a partitioned table
|
|
#
|
|
create or replace table t (a int) with system versioning
|
|
partition by system_time;
|
|
alter table t drop system versioning;
|
|
ERROR HY000: Can not DROP SYSTEM VERSIONING for table `t` partitioned BY SYSTEM_TIME
|
|
#
|
|
# MDEV-15191 Assertion `bit < (map)->n_bits' failed in bitmap_is_set upon INSERT
|
|
#
|
|
create or replace table t1 (i int) with system versioning;
|
|
insert into t1 values (1), (2);
|
|
update t1 set i= 3;
|
|
alter table t1 partition by system_time interval 1 month (partition p1 history, partition pn current);
|
|
lock table t1 write;
|
|
alter table t1 add partition (partition p2 history);
|
|
insert into t1 values (4);
|
|
unlock tables;
|
|
#
|
|
# MDEV-15036 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' in Diagnostics_area::set_ok_status or unexpected ER_RANGE_NOT_INCREASING_ERROR
|
|
#
|
|
create or replace table t1 (a int) with system versioning
|
|
partition by system_time limit 2 partitions 4;
|
|
insert into t1 values (1),(2),(3);
|
|
update t1 set a = 4;
|
|
delete from t1;
|
|
delete from t1 where a is not null;
|
|
#
|
|
# MDEV-14823 Wrong error message upon selecting from a system_time partition
|
|
#
|
|
create or replace table t1 (i int) with system versioning partition by system_time limit 10;
|
|
select * from t1 partition (p0) for system_time all;
|
|
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
|
|
# MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED
|
|
create or replace procedure sp()
|
|
select * from t1 partition (p0) for system_time all;
|
|
call sp;
|
|
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
|
|
call sp;
|
|
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
|
|
drop procedure sp;
|
|
#
|
|
# MDEV-15380 Index for versioned table gets corrupt after partitioning and DELETE
|
|
#
|
|
create or replace table t1 (pk int primary key)
|
|
engine=myisam
|
|
with system versioning
|
|
partition by key() partitions 3;
|
|
set timestamp=1523466002.799571;
|
|
insert into t1 values (11),(12);
|
|
set timestamp=1523466004.169435;
|
|
delete from t1 where pk in (11, 12);
|
|
Same test but for Aria storage engine
|
|
create or replace table t1 (pk int primary key)
|
|
engine=aria
|
|
with system versioning
|
|
partition by key() partitions 3;
|
|
set timestamp=1523466002.799571;
|
|
insert into t1 values (11),(12);
|
|
set timestamp=1523466004.169435;
|
|
delete from t1 where pk in (11, 12);
|
|
#
|
|
# MDEV-18136 Server crashes in Item_func_dyncol_create::prepare_arguments
|
|
#
|
|
create or replace table t1 (pk int) with system versioning
|
|
partition by system_time interval 7 second;
|
|
alter table t1
|
|
partition by system_time interval column_get(column_create(7,7), 7 as int) second (
|
|
partition ver_p1 history,
|
|
partition ver_pn current);
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`pk` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME INTERVAL 7 SECOND STARTS TIMESTAMP'2018-04-11 17:00:04'
|
|
(PARTITION `ver_p1` HISTORY ENGINE = DEFAULT_ENGINE,
|
|
PARTITION `ver_pn` CURRENT ENGINE = DEFAULT_ENGINE)
|
|
#
|
|
# MDEV-19175 Server crashes in ha_partition::vers_can_native upon INSERT DELAYED into versioned partitioned table
|
|
#
|
|
create or replace table t1 (f int) with system versioning partition by hash(f);
|
|
insert delayed into t1 values (1);
|
|
#
|
|
# MDEV-20068 History partition rotation is not done under LOCK TABLES
|
|
#
|
|
create or replace table t1 (x int) with system versioning partition by system_time limit 1
|
|
(partition p1 history, partition pn current);
|
|
lock tables t1 write;
|
|
insert into t1 values (0), (1), (2), (3);
|
|
delete from t1 where x < 3;
|
|
delete from t1;
|
|
Warnings:
|
|
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
|
|
unlock tables;
|
|
#
|
|
# MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table
|
|
#
|
|
create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current);
|
|
execute immediate 'select * from t1 for update';
|
|
pk
|
|
#
|
|
# MDEV-19903 Setup default partitions for system versioning
|
|
#
|
|
create or replace table t1 (x int) with system versioning partition by system_time;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
PARTITIONS 2
|
|
# 2 partitions are created: p0 and pn
|
|
select PARTITION_NAME, PARTITION_METHOD, PARTITION_DESCRIPTION from information_schema.partitions where table_name = 't1' order by PARTITION_NAME;
|
|
PARTITION_NAME PARTITION_METHOD PARTITION_DESCRIPTION
|
|
p0 SYSTEM_TIME NULL
|
|
pn SYSTEM_TIME CURRENT
|
|
create or replace table t1 (x int) with system versioning partition by system_time partitions 4;
|
|
Warnings:
|
|
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
PARTITIONS 4
|
|
# 4 partitions are created: p0, p1, p2 and pn
|
|
select PARTITION_NAME, PARTITION_METHOD, PARTITION_DESCRIPTION from information_schema.partitions where table_name = 't1' order by PARTITION_NAME;
|
|
PARTITION_NAME PARTITION_METHOD PARTITION_DESCRIPTION
|
|
p0 SYSTEM_TIME NULL
|
|
p1 SYSTEM_TIME NULL
|
|
p2 SYSTEM_TIME NULL
|
|
pn SYSTEM_TIME CURRENT
|
|
# Test cleanup
|
|
drop view v1;
|
|
drop tables t, t1, t2, t3, t4;
|
|
#
|
|
# MDEV-18957 UPDATE with LIMIT clause is wrong for versioned partitioned tables
|
|
#
|
|
create or replace table t1 (
|
|
x int,
|
|
a varchar(255)
|
|
) with system versioning partition by system_time (partition p1 history, partition pn current);
|
|
insert into t1 (x) values (1), (2), (3), (4);
|
|
update t1 set a= 'foo' limit 3;
|
|
update t1 set a= 'bar' limit 4;
|
|
select * from t1;
|
|
x a
|
|
1 bar
|
|
2 bar
|
|
3 bar
|
|
4 bar
|
|
drop table t1;
|
|
#
|
|
# MDEV-21011 Table corruption reported for versioned partitioned table after DELETE: "Found a misplaced row"
|
|
#
|
|
create table t1 (a int) with system versioning
|
|
partition by system_time limit 3
|
|
(partition p1 history, partition p2 history, partition pn current);
|
|
insert into t1 values (1),(2),(3),(4);
|
|
delete from t1;
|
|
delete from t1;
|
|
check table t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 check note Not supported for non-INTERVAL history partitions
|
|
test.t1 check note The storage engine for the table doesn't support check
|
|
drop table t1;
|
|
#
|
|
# MDEV-21233 Assertion `m_extra_cache' failed in ha_partition::late_extra_cache
|
|
#
|
|
create table t1 (id int, a varchar(8)) with system versioning partition by key (id) partitions 2;
|
|
insert into t1 values (1,'foo'),(2,'bar');
|
|
create table t2 (b int);
|
|
insert into t2 values (1),(2);
|
|
update t1, t2 set a = 1;
|
|
drop table t1, t2;
|
|
#
|
|
# MDEV-22153 ALTER add default history partitions breaks table
|
|
#
|
|
create or replace table t1 (x int) with system versioning partition by system_time;
|
|
alter table t1 add partition partitions 1;
|
|
Warnings:
|
|
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
PARTITIONS 3
|
|
alter table t1 add partition partitions 2;
|
|
Warnings:
|
|
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
PARTITIONS 5
|
|
alter table t1 add partition partitions 3;
|
|
Warnings:
|
|
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`x` int(11) DEFAULT NULL
|
|
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
PARTITION BY SYSTEM_TIME
|
|
PARTITIONS 8
|
|
drop tables t1;
|