mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-17554 history partitioning cleanups
* Fixed missed warning on condition boundary * REORGANIZE cases * vers_utils.h removed * test cases cleanup
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
call mtr.add_suppression("need more HISTORY partitions");
|
||||||
create table t (a int);
|
create table t (a int);
|
||||||
delete history from t before system_time now();
|
delete history from t before system_time now();
|
||||||
ERROR HY000: Table `t` is not system-versioned
|
ERROR HY000: Table `t` is not system-versioned
|
||||||
@ -56,16 +57,15 @@ select * from t for system_time all;
|
|||||||
a
|
a
|
||||||
drop procedure truncate_sp;
|
drop procedure truncate_sp;
|
||||||
# Truncate partitioned
|
# Truncate partitioned
|
||||||
create or replace table t (a int)
|
create or replace table t (a int) with system versioning
|
||||||
with system versioning
|
partition by system_time limit 1 partitions 3;
|
||||||
partition by system_time limit 1 (
|
|
||||||
partition p0 history,
|
|
||||||
partition p1 history,
|
|
||||||
partition pn current);
|
|
||||||
insert into t values (1);
|
insert into t values (1);
|
||||||
update t set a= 2;
|
update t set a= 2;
|
||||||
update t set a= 3;
|
update t set a= 3;
|
||||||
delete history from t;
|
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;
|
select * from t for system_time all;
|
||||||
a
|
a
|
||||||
3
|
3
|
||||||
|
@ -121,6 +121,28 @@ select x from t1;
|
|||||||
x
|
x
|
||||||
1
|
1
|
||||||
2
|
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
|
# Bug tempesta-tech/mariadb#260: incorrect IB partitioning warning
|
||||||
create or replace table t1 (x int)
|
create or replace table t1 (x int)
|
||||||
with system versioning
|
with system versioning
|
||||||
@ -267,13 +289,6 @@ x
|
|||||||
6
|
6
|
||||||
7
|
7
|
||||||
8
|
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
|
## rotation by INTERVAL
|
||||||
create or replace table t1 (x int)
|
create or replace table t1 (x int)
|
||||||
with system versioning
|
with system versioning
|
||||||
@ -282,124 +297,10 @@ ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
|
|||||||
create table t1 (i int) with system versioning
|
create table t1 (i int) with system versioning
|
||||||
partition by system_time interval 6 day limit 98;
|
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
|
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
|
||||||
## 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;
|
|
||||||
select * from t1 partition (p0sp0);
|
|
||||||
x
|
|
||||||
1
|
|
||||||
3
|
|
||||||
5
|
|
||||||
select * from t1 partition (p0sp1);
|
|
||||||
x
|
|
||||||
2
|
|
||||||
4
|
|
||||||
select * from t1 partition (p1sp0);
|
|
||||||
x
|
|
||||||
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))
|
|
||||||
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);
|
|
||||||
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)
|
|
||||||
) 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);
|
|
||||||
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;
|
|
||||||
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;
|
|
||||||
create or replace table t1 (pk int) with system versioning
|
create or replace table t1 (pk int) with system versioning
|
||||||
partition by system_time interval 10 year partitions 3;
|
partition by system_time interval 10 year partitions 3;
|
||||||
ERROR 22003: TIMESTAMP value is out of range in 'INTERVAL'
|
ERROR 22003: TIMESTAMP value is out of range in 'INTERVAL'
|
||||||
|
# INTERVAL and ALTER TABLE
|
||||||
create or replace table t1 (i int) with system versioning
|
create or replace table t1 (i int) with system versioning
|
||||||
partition by system_time interval 1 hour;
|
partition by system_time interval 1 hour;
|
||||||
set @ts=(select partition_description from information_schema.partitions
|
set @ts=(select partition_description from information_schema.partitions
|
||||||
@ -437,6 +338,146 @@ p2 2 SYSTEM_TIME 02:00:00.000000
|
|||||||
pn 3 SYSTEM_TIME NULL
|
pn 3 SYSTEM_TIME NULL
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1292 Incorrect time value: 'CURRENT'
|
Warning 1292 Incorrect time value: 'CURRENT'
|
||||||
|
## 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
|
||||||
|
#
|
||||||
|
# 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;
|
||||||
|
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;
|
||||||
#
|
#
|
||||||
# MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
|
# 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;
|
partition by system_time;
|
||||||
alter table t drop system versioning;
|
alter table t drop system versioning;
|
||||||
ERROR HY000: Can not DROP SYSTEM VERSIONING for table `t` partitioned BY SYSTEM_TIME
|
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
|
# MDEV-15191 Assertion `bit < (map)->n_bits' failed in bitmap_is_set upon INSERT
|
||||||
|
#
|
||||||
create or replace table t1 (i int) with system versioning;
|
create or replace table t1 (i int) with system versioning;
|
||||||
insert into t1 values (1), (2);
|
insert into t1 values (1), (2);
|
||||||
update t1 set i= 3;
|
update t1 set i= 3;
|
||||||
@ -461,14 +504,18 @@ lock table t1 write;
|
|||||||
alter table t1 add partition (partition p2 history);
|
alter table t1 add partition (partition p2 history);
|
||||||
insert into t1 values (4);
|
insert into t1 values (4);
|
||||||
unlock tables;
|
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
|
# 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
|
create or replace table t1 (a int) with system versioning
|
||||||
partition by system_time limit 2 partitions 4;
|
partition by system_time limit 2 partitions 4;
|
||||||
insert into t1 values (1),(2),(3);
|
insert into t1 values (1),(2),(3);
|
||||||
update t1 set a = 4;
|
update t1 set a = 4;
|
||||||
delete from t1;
|
delete from t1;
|
||||||
delete from t1 where a is not null;
|
delete from t1 where a is not null;
|
||||||
|
#
|
||||||
# MDEV-14823 Wrong error message upon selecting from a system_time partition
|
# 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;
|
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;
|
select * from t1 partition (p0) for system_time all;
|
||||||
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
|
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;
|
call sp;
|
||||||
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
|
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
|
||||||
drop procedure sp;
|
drop procedure sp;
|
||||||
|
#
|
||||||
# MDEV-15380 Index for versioned table gets corrupt after partitioning and DELETE
|
# MDEV-15380 Index for versioned table gets corrupt after partitioning and DELETE
|
||||||
|
#
|
||||||
create or replace table t1 (pk int primary key)
|
create or replace table t1 (pk int primary key)
|
||||||
engine=myisam
|
engine=myisam
|
||||||
with system versioning
|
with system versioning
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
--source include/have_partition.inc
|
--source include/have_partition.inc
|
||||||
--source suite/versioning/engines.inc
|
--source suite/versioning/engines.inc
|
||||||
|
|
||||||
|
call mtr.add_suppression("need more HISTORY partitions");
|
||||||
|
|
||||||
create table t (a int);
|
create table t (a int);
|
||||||
--error ER_VERS_NOT_VERSIONED
|
--error ER_VERS_NOT_VERSIONED
|
||||||
delete history from t before system_time now();
|
delete history from t before system_time now();
|
||||||
@ -56,16 +58,13 @@ select * from t for system_time all;
|
|||||||
drop procedure truncate_sp;
|
drop procedure truncate_sp;
|
||||||
|
|
||||||
--echo # Truncate partitioned
|
--echo # Truncate partitioned
|
||||||
create or replace table t (a int)
|
create or replace table t (a int) with system versioning
|
||||||
with system versioning
|
partition by system_time limit 1 partitions 3;
|
||||||
partition by system_time limit 1 (
|
|
||||||
partition p0 history,
|
|
||||||
partition p1 history,
|
|
||||||
partition pn current);
|
|
||||||
insert into t values (1);
|
insert into t values (1);
|
||||||
update t set a= 2;
|
update t set a= 2;
|
||||||
update t set a= 3;
|
update t set a= 3;
|
||||||
delete history from t;
|
delete history from t;
|
||||||
|
--echo # The above warning is one command late (MDEV-20345) ^^^
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
|
|
||||||
--echo # VIEW
|
--echo # VIEW
|
||||||
|
@ -123,6 +123,23 @@ alter table t1 drop partition p0;
|
|||||||
|
|
||||||
select x from t1;
|
select x from t1;
|
||||||
|
|
||||||
|
--echo # 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);
|
||||||
|
--replace_result $default_engine DEFAULT_ENGINE
|
||||||
|
show create table t1;
|
||||||
|
|
||||||
|
--echo # merge and split doesn't (MDEV-19938)
|
||||||
|
create or replace table t1 (x int) with system versioning
|
||||||
|
partition by system_time partitions 3;
|
||||||
|
--error ER_REORG_HASH_ONLY_ON_SAME_NO
|
||||||
|
alter table t1 reorganize partition p0, p1 into (partition p00 history);
|
||||||
|
--error ER_REORG_HASH_ONLY_ON_SAME_NO
|
||||||
|
alter table t1 reorganize partition p1 into (partition p1 history, partition p2 history);
|
||||||
|
|
||||||
|
|
||||||
--echo # Bug tempesta-tech/mariadb#260: incorrect IB partitioning warning
|
--echo # Bug tempesta-tech/mariadb#260: incorrect IB partitioning warning
|
||||||
create or replace table t1 (x int)
|
create or replace table t1 (x int)
|
||||||
with system versioning
|
with system versioning
|
||||||
@ -224,13 +241,6 @@ insert into t1 values (7), (8);
|
|||||||
delete from t1;
|
delete from t1;
|
||||||
select * from t1 partition (p1) order by x;
|
select * from t1 partition (p1) order by x;
|
||||||
|
|
||||||
--echo ### 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);
|
|
||||||
|
|
||||||
--echo ## rotation by INTERVAL
|
--echo ## rotation by INTERVAL
|
||||||
--error ER_PART_WRONG_VALUE
|
--error ER_PART_WRONG_VALUE
|
||||||
@ -242,6 +252,28 @@ partition by system_time interval 0 second partitions 3;
|
|||||||
create table t1 (i int) with system versioning
|
create table t1 (i int) with system versioning
|
||||||
partition by system_time interval 6 day limit 98;
|
partition by system_time interval 6 day limit 98;
|
||||||
|
|
||||||
|
--error ER_DATA_OUT_OF_RANGE
|
||||||
|
create or replace table t1 (pk int) with system versioning
|
||||||
|
partition by system_time interval 10 year partitions 3;
|
||||||
|
|
||||||
|
--echo # 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';
|
||||||
|
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';
|
||||||
|
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';
|
||||||
|
--error ER_VERS_DROP_PARTITION_INTERVAL
|
||||||
|
alter table t1 drop partition p2;
|
||||||
|
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
|
||||||
|
|
||||||
|
|
||||||
--echo ## Subpartitions
|
--echo ## Subpartitions
|
||||||
create or replace table t1 (x int)
|
create or replace table t1 (x int)
|
||||||
with system versioning
|
with system versioning
|
||||||
@ -262,24 +294,18 @@ select * from t1 partition (p0sp1);
|
|||||||
select * from t1 partition (p1sp0);
|
select * from t1 partition (p1sp0);
|
||||||
select * from t1 partition (p1sp1);
|
select * from t1 partition (p1sp1);
|
||||||
|
|
||||||
--replace_result $sys_datatype_expl SYS_DATATYPE
|
--echo # check implicit sys fields for implicit engine of partitioned table
|
||||||
eval create or replace table t1 (
|
create or replace table t1 (a bigint)
|
||||||
a bigint,
|
|
||||||
row_start $sys_datatype_expl as row start invisible,
|
|
||||||
row_end $sys_datatype_expl as row end invisible,
|
|
||||||
period for system_time(row_start, row_end))
|
|
||||||
with system versioning
|
with system versioning
|
||||||
partition by range (a)
|
partition by range (a)
|
||||||
(partition p0 values less than (20) engine innodb,
|
(partition p0 values less than (20) engine innodb,
|
||||||
partition p1 values less than maxvalue engine innodb);
|
partition p1 values less than maxvalue engine innodb);
|
||||||
insert into t1 values (1);
|
insert into t1 values (1);
|
||||||
|
select * from t1 partition (p0);
|
||||||
|
|
||||||
--replace_result $sys_datatype_expl SYS_DATATYPE
|
--echo # check for partition engine
|
||||||
eval create or replace table t1 (
|
create or replace table t1 (
|
||||||
f_int1 integer default 0,
|
f_int1 integer default 0
|
||||||
row_start $sys_datatype_expl as row start invisible,
|
|
||||||
row_end $sys_datatype_expl as row end invisible,
|
|
||||||
period for system_time(row_start, row_end)
|
|
||||||
) with system versioning
|
) with system versioning
|
||||||
partition by range(f_int1)
|
partition by range(f_int1)
|
||||||
subpartition by hash(f_int1)
|
subpartition by hash(f_int1)
|
||||||
@ -287,17 +313,28 @@ subpartition by hash(f_int1)
|
|||||||
(subpartition subpart11 storage engine = 'innodb',
|
(subpartition subpart11 storage engine = 'innodb',
|
||||||
subpartition subpart12 storage engine = 'innodb'));
|
subpartition subpart12 storage engine = 'innodb'));
|
||||||
insert into t1 values (1);
|
insert into t1 values (1);
|
||||||
|
select * from t1 partition (part1);
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Assertion in ALTER on warning from partitioning LIMIT [#446]
|
||||||
|
--echo #
|
||||||
|
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);
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-14649 Assertion `t->mysql_col_len == 8' failed in row_insert_for_mysql
|
||||||
|
--echo #
|
||||||
create or replace table t1 (i int) engine=innodb partition by key(i);
|
create or replace table t1 (i int) engine=innodb partition by key(i);
|
||||||
--replace_result $sys_datatype_expl SYS_DATATYPE
|
alter table t1 add system versioning;
|
||||||
eval alter table t1
|
|
||||||
add column row_start $sys_datatype_expl as row start invisible,
|
|
||||||
add column row_end $sys_datatype_expl as row end invisible,
|
|
||||||
add period for system_time(row_start, row_end),
|
|
||||||
add system versioning;
|
|
||||||
insert into t1 values();
|
insert into t1 values();
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14722 Assertion in ha_commit_trans for sub-statement
|
--echo # MDEV-14722 Assertion in ha_commit_trans for sub-statement
|
||||||
|
--echo #
|
||||||
create or replace table t1 (i int) with system versioning
|
create or replace table t1 (i int) with system versioning
|
||||||
partition by system_time interval 1 day;
|
partition by system_time interval 1 day;
|
||||||
create or replace table t2 (f int);
|
create or replace table t2 (f int);
|
||||||
@ -306,7 +343,9 @@ for each row select table_rows from information_schema.tables
|
|||||||
where table_name = 't1' into @a;
|
where table_name = 't1' into @a;
|
||||||
insert into t2 values (1);
|
insert into t2 values (1);
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14740 Locking assertion for system_time partitioning
|
--echo # MDEV-14740 Locking assertion for system_time partitioning
|
||||||
|
--echo #
|
||||||
create or replace table t1 (i int) with system versioning
|
create or replace table t1 (i int) with system versioning
|
||||||
partition by system_time interval 1 week;
|
partition by system_time interval 1 week;
|
||||||
create or replace table t2 (f int);
|
create or replace table t2 (f int);
|
||||||
@ -314,7 +353,9 @@ create or replace trigger tr before insert on t2
|
|||||||
for each row select count(*) from t1 into @a;
|
for each row select count(*) from t1 into @a;
|
||||||
insert into t2 values (1);
|
insert into t2 values (1);
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES
|
--echo # MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES
|
||||||
|
--echo #
|
||||||
create or replace table t1 (x int) with system versioning;
|
create or replace table t1 (x int) with system versioning;
|
||||||
lock table t1 write;
|
lock table t1 write;
|
||||||
alter table t1 partition by system_time interval 1 week (
|
alter table t1 partition by system_time interval 1 week (
|
||||||
@ -322,7 +363,9 @@ alter table t1 partition by system_time interval 1 week (
|
|||||||
partition pn current);
|
partition pn current);
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14748 Assertion in ha_myisammrg::attach_children()
|
--echo # MDEV-14748 Assertion in ha_myisammrg::attach_children()
|
||||||
|
--echo #
|
||||||
create or replace table t1 (x int) engine=myisam with system versioning
|
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);
|
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 t2 (x int) engine=myisam;
|
||||||
@ -332,17 +375,22 @@ create or replace trigger tr after insert on t4 for each row insert into t2
|
|||||||
( select x from t3 ) union ( select x from t1 );
|
( select x from t3 ) union ( select x from t1 );
|
||||||
insert into t4 values (1);
|
insert into t4 values (1);
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14821 Assertion failure
|
--echo # MDEV-14821 Assertion failure
|
||||||
|
--echo #
|
||||||
create or replace table t1 (x int) with system versioning;
|
create or replace table t1 (x int) with system versioning;
|
||||||
insert into t1 values (0), (1);
|
insert into t1 values (0), (1);
|
||||||
update t1 set x= x + 1;
|
update t1 set x= x + 1;
|
||||||
alter table t1 partition by system_time limit 1 (
|
alter table t1 partition by system_time limit 1 (
|
||||||
partition p1 history,
|
partition p1 history,
|
||||||
partition p2 history,
|
partition p2 history,
|
||||||
partition pn current);delete from t1 where x = 1;
|
partition pn current);
|
||||||
|
delete from t1 where x = 1;
|
||||||
delete from t1 where x = 2;
|
delete from t1 where x = 2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
|
--echo # MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
|
||||||
|
--echo #
|
||||||
create or replace table t1 (x int) with system versioning
|
create or replace table t1 (x int) with system versioning
|
||||||
partition by system_time;
|
partition by system_time;
|
||||||
lock table t1 write;
|
lock table t1 write;
|
||||||
@ -351,27 +399,6 @@ alter table t1 add partition (partition p0 history);
|
|||||||
insert into t1 values (1);
|
insert into t1 values (1);
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
|
||||||
--error ER_DATA_OUT_OF_RANGE
|
|
||||||
create or replace table t1 (pk int) with system versioning
|
|
||||||
partition by system_time interval 10 year partitions 3;
|
|
||||||
|
|
||||||
# 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';
|
|
||||||
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';
|
|
||||||
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';
|
|
||||||
--error ER_VERS_DROP_PARTITION_INTERVAL
|
|
||||||
alter table t1 drop partition p2;
|
|
||||||
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
|
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
|
--echo # MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
|
||||||
--echo #
|
--echo #
|
||||||
@ -389,7 +416,9 @@ partition by system_time;
|
|||||||
--error ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION
|
--error ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION
|
||||||
alter table t drop system versioning;
|
alter table t drop system versioning;
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-15191 Assertion `bit < (map)->n_bits' failed in bitmap_is_set upon INSERT
|
--echo # MDEV-15191 Assertion `bit < (map)->n_bits' failed in bitmap_is_set upon INSERT
|
||||||
|
--echo #
|
||||||
create or replace table t1 (i int) with system versioning;
|
create or replace table t1 (i int) with system versioning;
|
||||||
insert into t1 values (1), (2);
|
insert into t1 values (1), (2);
|
||||||
update t1 set i= 3;
|
update t1 set i= 3;
|
||||||
@ -399,7 +428,9 @@ alter table t1 add partition (partition p2 history);
|
|||||||
insert into t1 values (4);
|
insert into t1 values (4);
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # 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
|
--echo # 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
|
||||||
|
--echo #
|
||||||
create or replace table t1 (a int) with system versioning
|
create or replace table t1 (a int) with system versioning
|
||||||
partition by system_time limit 2 partitions 4;
|
partition by system_time limit 2 partitions 4;
|
||||||
insert into t1 values (1),(2),(3);
|
insert into t1 values (1),(2),(3);
|
||||||
@ -407,7 +438,9 @@ update t1 set a = 4;
|
|||||||
delete from t1;
|
delete from t1;
|
||||||
delete from t1 where a is not null;
|
delete from t1 where a is not null;
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-14823 Wrong error message upon selecting from a system_time partition
|
--echo # MDEV-14823 Wrong error message upon selecting from a system_time partition
|
||||||
|
--echo #
|
||||||
create or replace table t1 (i int) with system versioning partition by system_time limit 10;
|
create or replace table t1 (i int) with system versioning partition by system_time limit 10;
|
||||||
--error ER_VERS_QUERY_IN_PARTITION
|
--error ER_VERS_QUERY_IN_PARTITION
|
||||||
select * from t1 partition (p0) for system_time all;
|
select * from t1 partition (p0) for system_time all;
|
||||||
@ -420,7 +453,9 @@ call sp;
|
|||||||
call sp;
|
call sp;
|
||||||
drop procedure sp;
|
drop procedure sp;
|
||||||
|
|
||||||
|
--echo #
|
||||||
--echo # MDEV-15380 Index for versioned table gets corrupt after partitioning and DELETE
|
--echo # MDEV-15380 Index for versioned table gets corrupt after partitioning and DELETE
|
||||||
|
--echo #
|
||||||
create or replace table t1 (pk int primary key)
|
create or replace table t1 (pk int primary key)
|
||||||
engine=myisam
|
engine=myisam
|
||||||
with system versioning
|
with system versioning
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include "sql_plugin.h" // st_plugin_int
|
#include "sql_plugin.h" // st_plugin_int
|
||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "vers_utils.h"
|
#include "table.h"
|
||||||
|
#include "vers_string.h"
|
||||||
|
|
||||||
/* System Versioning: TRT_TRX_ID(), TRT_COMMIT_ID(), TRT_BEGIN_TS(), TRT_COMMIT_TS(), TRT_ISO_LEVEL() */
|
/* System Versioning: TRT_TRX_ID(), TRT_COMMIT_ID(), TRT_BEGIN_TS(), TRT_COMMIT_TS(), TRT_ISO_LEVEL() */
|
||||||
template <TR_table::field_id_t TRT_FIELD>
|
template <TR_table::field_id_t TRT_FIELD>
|
||||||
|
@ -32,9 +32,10 @@
|
|||||||
#include "sql_parse.h"
|
#include "sql_parse.h"
|
||||||
#include "sql_acl.h" // *_ACL
|
#include "sql_acl.h" // *_ACL
|
||||||
#include "sql_base.h" // fill_record
|
#include "sql_base.h" // fill_record
|
||||||
#include "sql_statistics.h" // vers_stat_end
|
|
||||||
#include "vers_utils.h"
|
|
||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
|
#include "table.h"
|
||||||
|
#include "sql_class.h"
|
||||||
|
#include "vers_string.h"
|
||||||
|
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
#include "ha_partition.h"
|
#include "ha_partition.h"
|
||||||
@ -196,49 +197,6 @@ bool partition_info::set_named_partition_bitmap(const char *part_name, size_t le
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Prune away partitions not mentioned in the PARTITION () clause,
|
|
||||||
if used.
|
|
||||||
|
|
||||||
@param table_list Table list pointing to table to prune.
|
|
||||||
|
|
||||||
@return Operation status
|
|
||||||
@retval false Success
|
|
||||||
@retval true Failure
|
|
||||||
*/
|
|
||||||
bool partition_info::set_read_partitions(List<char> *partition_names)
|
|
||||||
{
|
|
||||||
DBUG_ENTER("partition_info::set_read_partitions");
|
|
||||||
if (!partition_names || !partition_names->elements)
|
|
||||||
{
|
|
||||||
DBUG_RETURN(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint num_names= partition_names->elements;
|
|
||||||
List_iterator<char> partition_names_it(*partition_names);
|
|
||||||
uint i= 0;
|
|
||||||
/*
|
|
||||||
TODO: When adding support for FK in partitioned tables, the referenced
|
|
||||||
table must probably lock all partitions for read, and also write depending
|
|
||||||
of ON DELETE/UPDATE.
|
|
||||||
*/
|
|
||||||
bitmap_clear_all(&read_partitions);
|
|
||||||
|
|
||||||
/* No check for duplicate names or overlapping partitions/subpartitions. */
|
|
||||||
|
|
||||||
DBUG_PRINT("info", ("Searching through partition_name_hash"));
|
|
||||||
do
|
|
||||||
{
|
|
||||||
char *part_name= partition_names_it++;
|
|
||||||
if (add_named_partition(part_name, strlen(part_name)))
|
|
||||||
DBUG_RETURN(true);
|
|
||||||
} while (++i < num_names);
|
|
||||||
DBUG_RETURN(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prune away partitions not mentioned in the PARTITION () clause,
|
Prune away partitions not mentioned in the PARTITION () clause,
|
||||||
if used.
|
if used.
|
||||||
@ -849,6 +807,15 @@ bool partition_info::has_unique_name(partition_element *element)
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Switch history partition according limit or interval
|
||||||
|
|
||||||
|
@note
|
||||||
|
vers_info->limit Limit by number of partition records
|
||||||
|
vers_info->interval Limit by fixed time interval
|
||||||
|
vers_info->hist_part (out) Working history partition
|
||||||
|
*/
|
||||||
void partition_info::vers_set_hist_part(THD *thd)
|
void partition_info::vers_set_hist_part(THD *thd)
|
||||||
{
|
{
|
||||||
if (vers_info->limit)
|
if (vers_info->limit)
|
||||||
@ -867,7 +834,7 @@ void partition_info::vers_set_hist_part(THD *thd)
|
|||||||
vers_info->hist_part= next;
|
vers_info->hist_part= next;
|
||||||
records= next_records;
|
records= next_records;
|
||||||
}
|
}
|
||||||
if (records > vers_info->limit)
|
if (records >= vers_info->limit)
|
||||||
{
|
{
|
||||||
if (next == vers_info->now_part)
|
if (next == vers_info->now_part)
|
||||||
{
|
{
|
||||||
@ -904,49 +871,6 @@ void partition_info::vers_set_hist_part(THD *thd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add)
|
|
||||||
{
|
|
||||||
if (!table->versioned())
|
|
||||||
{
|
|
||||||
// frm must be corrupted, normally CREATE/ALTER TABLE checks for that
|
|
||||||
my_error(ER_FILE_CORRUPT, MYF(0), table->s->path.str);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DBUG_ASSERT(part_type == VERSIONING_PARTITION);
|
|
||||||
DBUG_ASSERT(table->versioned(VERS_TIMESTAMP));
|
|
||||||
|
|
||||||
if (!alter_add)
|
|
||||||
{
|
|
||||||
Field *row_end= table->vers_end_field();
|
|
||||||
// needed in handle_list_of_fields()
|
|
||||||
row_end->flags|= GET_FIXED_FIELDS_FLAG;
|
|
||||||
Name_resolution_context *context= &thd->lex->current_select->context;
|
|
||||||
Item *row_end_item= new (thd->mem_root) Item_field(thd, context, row_end);
|
|
||||||
Item *row_end_ts= new (thd->mem_root) Item_func_unix_timestamp(thd, row_end_item);
|
|
||||||
set_part_expr(thd, row_end_ts, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alter_add)
|
|
||||||
{
|
|
||||||
List_iterator<partition_element> it(partitions);
|
|
||||||
partition_element *el;
|
|
||||||
for(uint32 id= 0; ((el= it++)); id++)
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(el->type != partition_element::CONVENTIONAL);
|
|
||||||
/* Newly added element is inserted before AS_OF_NOW. */
|
|
||||||
if (el->id == UINT_MAX32 || el->type == partition_element::CURRENT)
|
|
||||||
{
|
|
||||||
el->id= id;
|
|
||||||
if (el->type == partition_element::CURRENT)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check that the partition/subpartition is setup to use the correct
|
Check that the partition/subpartition is setup to use the correct
|
||||||
storage engine
|
storage engine
|
||||||
@ -1424,9 +1348,8 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
|
|||||||
|
|
||||||
if (add_or_reorg_part)
|
if (add_or_reorg_part)
|
||||||
{
|
{
|
||||||
if (unlikely(part_type == VERSIONING_PARTITION &&
|
if (part_type == VERSIONING_PARTITION && add_or_reorg_part->partitions.elements)
|
||||||
vers_setup_expression(thd, add_or_reorg_part->partitions.elements)))
|
vers_update_el_ids();
|
||||||
goto end;
|
|
||||||
if (check_constants(thd, this))
|
if (check_constants(thd, this))
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -385,11 +385,9 @@ private:
|
|||||||
uint start_no);
|
uint start_no);
|
||||||
char *create_default_subpartition_name(THD *thd, uint subpart_no,
|
char *create_default_subpartition_name(THD *thd, uint subpart_no,
|
||||||
const char *part_name);
|
const char *part_name);
|
||||||
// FIXME: prune_partition_bitmaps() is duplicate of set_read_partitions()
|
bool prune_partition_bitmaps(List<String> *partition_names); // set_read_partitions() in 8.0
|
||||||
bool prune_partition_bitmaps(List<String> *partition_names);
|
|
||||||
bool add_named_partition(const char *part_name, size_t length);
|
bool add_named_partition(const char *part_name, size_t length);
|
||||||
public:
|
public:
|
||||||
bool set_read_partitions(List<char> *partition_names);
|
|
||||||
bool has_unique_name(partition_element *element);
|
bool has_unique_name(partition_element *element);
|
||||||
bool field_in_partition_expr(Field *field) const;
|
bool field_in_partition_expr(Field *field) const;
|
||||||
|
|
||||||
@ -404,7 +402,8 @@ public:
|
|||||||
return !limit;
|
return !limit;
|
||||||
}
|
}
|
||||||
void vers_set_hist_part(THD *thd);
|
void vers_set_hist_part(THD *thd);
|
||||||
bool vers_setup_expression(THD *thd, uint32 alter_add= 0); /* Stage 1. */
|
bool vers_fix_field_list(THD *thd);
|
||||||
|
void vers_update_el_ids();
|
||||||
partition_element *get_partition(uint part_id)
|
partition_element *get_partition(uint part_id)
|
||||||
{
|
{
|
||||||
List_iterator<partition_element> it(partitions);
|
List_iterator<partition_element> it(partitions);
|
||||||
@ -445,4 +444,60 @@ void init_all_partitions_iterator(partition_info *part_info,
|
|||||||
part_iter->get_next= get_next_partition_id_range;
|
part_iter->get_next= get_next_partition_id_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Update part_field_list by row_end field name
|
||||||
|
|
||||||
|
@returns true on error; false on success
|
||||||
|
*/
|
||||||
|
inline
|
||||||
|
bool partition_info::vers_fix_field_list(THD * thd)
|
||||||
|
{
|
||||||
|
if (!table->versioned())
|
||||||
|
{
|
||||||
|
// frm must be corrupted, normally CREATE/ALTER TABLE checks for that
|
||||||
|
my_error(ER_FILE_CORRUPT, MYF(0), table->s->path.str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
DBUG_ASSERT(part_type == VERSIONING_PARTITION);
|
||||||
|
DBUG_ASSERT(table->versioned(VERS_TIMESTAMP));
|
||||||
|
|
||||||
|
Field *row_end= table->vers_end_field();
|
||||||
|
// needed in handle_list_of_fields()
|
||||||
|
row_end->flags|= GET_FIXED_FIELDS_FLAG;
|
||||||
|
Name_resolution_context *context= &thd->lex->current_select->context;
|
||||||
|
Item *row_end_item= new (thd->mem_root) Item_field(thd, context, row_end);
|
||||||
|
Item *row_end_ts= new (thd->mem_root) Item_func_unix_timestamp(thd, row_end_item);
|
||||||
|
set_part_expr(thd, row_end_ts, false);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Update partition_element's id
|
||||||
|
|
||||||
|
@returns true on error; false on success
|
||||||
|
*/
|
||||||
|
inline
|
||||||
|
void partition_info::vers_update_el_ids()
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(part_type == VERSIONING_PARTITION);
|
||||||
|
DBUG_ASSERT(table->versioned(VERS_TIMESTAMP));
|
||||||
|
|
||||||
|
List_iterator<partition_element> it(partitions);
|
||||||
|
partition_element *el;
|
||||||
|
for(uint32 id= 0; ((el= it++)); id++)
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(el->type != partition_element::CONVENTIONAL);
|
||||||
|
/* Newly added element is inserted before AS_OF_NOW. */
|
||||||
|
if (el->id == UINT_MAX32 || el->type == partition_element::CURRENT)
|
||||||
|
{
|
||||||
|
el->id= id;
|
||||||
|
if (el->type == partition_element::CURRENT)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* PARTITION_INFO_INCLUDED */
|
#endif /* PARTITION_INFO_INCLUDED */
|
||||||
|
@ -2013,7 +2013,7 @@ bool fix_partition_func(THD *thd, TABLE *table, bool is_create_table_ind)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (part_info->part_type == VERSIONING_PARTITION &&
|
if (part_info->part_type == VERSIONING_PARTITION &&
|
||||||
part_info->vers_setup_expression(thd))
|
part_info->vers_fix_field_list(thd))
|
||||||
goto end;
|
goto end;
|
||||||
if (unlikely(fix_fields_part_func(thd, part_info->part_expr,
|
if (unlikely(fix_fields_part_func(thd, part_info->part_expr,
|
||||||
table, FALSE, is_create_table_ind)))
|
table, FALSE, is_create_table_ind)))
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#ifndef VERS_UTILS_INCLUDED
|
|
||||||
#define VERS_UTILS_INCLUDED
|
|
||||||
|
|
||||||
#include "table.h"
|
|
||||||
#include "sql_class.h"
|
|
||||||
#include "vers_string.h"
|
|
||||||
|
|
||||||
#endif // VERS_UTILS_INCLUDED
|
|
@ -2033,7 +2033,6 @@ static bool srv_task_execute()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Do the actual purge operation.
|
/** Do the actual purge operation.
|
||||||
@param[in,out] n_total_purged total number of purged pages
|
@param[in,out] n_total_purged total number of purged pages
|
||||||
@return length of history list before the last purge batch. */
|
@return length of history list before the last purge batch. */
|
||||||
|
Reference in New Issue
Block a user