Skip to content
Permalink
Browse files
MDEV-17554 history partitioning cleanups
* Fixed missed warning on condition boundary
* REORGANIZE cases
* vers_utils.h removed
* test cases cleanup
  • Loading branch information
midenok committed Dec 3, 2019
1 parent 8ed646f commit 9ed8d36
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 230 deletions.
@@ -1,3 +1,4 @@
call mtr.add_suppression("need more HISTORY partitions");
create table t (a int);
delete history from t before system_time now();
ERROR HY000: Table `t` is not system-versioned
@@ -56,16 +57,15 @@ select * from t for system_time all;
a
drop procedure truncate_sp;
# Truncate partitioned
create or replace table t (a int)
with system versioning
partition by system_time limit 1 (
partition p0 history,
partition p1 history,
partition pn current);
create or replace table t (a int) with system versioning
partition by system_time limit 1 partitions 3;
insert into t values (1);
update t set a= 2;
update t set a= 3;
delete history from t;
Warnings:
Warning 4114 Versioned table `test`.`t`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# The above warning is one command late (MDEV-20345) ^^^
select * from t for system_time all;
a
3
@@ -121,6 +121,28 @@ 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
@@ -267,13 +289,6 @@ x
6
7
8
### 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);
## rotation by INTERVAL
create or replace table t1 (x int)
with system versioning
@@ -282,6 +297,47 @@ 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'
## Subpartitions
create or replace table t1 (x int)
with system versioning
@@ -302,49 +358,62 @@ x
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
3
5
select * from t1 partition (p0sp1);
x
2
4
select * from t1 partition (p1sp0);
x
3
5
select * from t1 partition (p1sp1);
x
create or replace table t1 (
a bigint,
row_start SYS_DATATYPE as row start invisible,
row_end SYS_DATATYPE as row end invisible,
period for system_time(row_start, row_end))
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,
row_start SYS_DATATYPE as row start invisible,
row_end SYS_DATATYPE as row end invisible,
period for system_time(row_start, row_end)
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
#
# 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 column row_start SYS_DATATYPE as row start invisible,
add column row_end SYS_DATATYPE as row end invisible,
add period for system_time(row_start, row_end),
add system versioning;
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);
@@ -354,7 +423,9 @@ 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);
@@ -363,14 +434,18 @@ 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;
@@ -379,7 +454,9 @@ 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;
@@ -389,54 +466,18 @@ partition p2 history,
partition pn current);
delete from t1 where x = 1;
delete from t1 where x = 2;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions
#
# 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;
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'
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'
#
# MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
#
@@ -452,7 +493,9 @@ 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;
@@ -461,14 +504,18 @@ 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
@@ -480,7 +527,9 @@ ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical qu
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
@@ -2,6 +2,8 @@
--source include/have_partition.inc
--source suite/versioning/engines.inc

call mtr.add_suppression("need more HISTORY partitions");

create table t (a int);
--error ER_VERS_NOT_VERSIONED
delete history from t before system_time now();
@@ -56,16 +58,13 @@ select * from t for system_time all;
drop procedure truncate_sp;

--echo # Truncate partitioned
create or replace table t (a int)
with system versioning
partition by system_time limit 1 (
partition p0 history,
partition p1 history,
partition pn current);
create or replace table t (a int) with system versioning
partition by system_time limit 1 partitions 3;
insert into t values (1);
update t set a= 2;
update t set a= 3;
delete history from t;
--echo # The above warning is one command late (MDEV-20345) ^^^
select * from t for system_time all;

--echo # VIEW

0 comments on commit 9ed8d36

Please sign in to comment.