Skip to content

Commit

Permalink
SQL: (0.6) Pruning for VERSIONING partitions [closes #97]
Browse files Browse the repository at this point in the history
* based on RANGE pruning by COLUMNS (sys_trx_end) condition
* removed DEFAULT; AS OF NOW is always last; current VERSIONING as last non-empty (or first empty)
* Min/Max stats in TABLE_SHARE
* ALTER TABLE ADD PARTITION adds before AS OF NOW partition
  • Loading branch information
midenok committed Jan 16, 2017
1 parent 3f9119c commit 26f5cbe
Show file tree
Hide file tree
Showing 17 changed files with 580 additions and 307 deletions.
2 changes: 1 addition & 1 deletion mysql-test/suite/perfschema/r/dml_setup_instruments.result
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ wait/synch/rwlock/sql/LOGGER::LOCK_logger YES YES
wait/synch/rwlock/sql/MDL_context::LOCK_waiting_for YES YES
wait/synch/rwlock/sql/MDL_lock::rwlock YES YES
wait/synch/rwlock/sql/Query_cache_query::lock YES YES
wait/synch/rwlock/sql/THR_LOCK_servers YES YES
wait/synch/rwlock/sql/TABLE_SHARE::LOCK_stat_serial YES YES
select * from performance_schema.setup_instruments
where name like 'Wait/Synch/Cond/sql/%'
and name not in (
Expand Down
155 changes: 57 additions & 98 deletions mysql-test/suite/versioning/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ x
300
create or replace table t1 (x int)
partition by system_time (
partition p0 as of now,
partition p1 versioning);
partition p0 versioning,
partition pn as of now);
ERROR HY000: System Versioning required: `BY SYSTEM_TIME` partitioning
create or replace table t1 (x int);
alter table t1
partition by system_time (
partition p0 as of now,
partition p1 versioning);
partition p0 versioning,
partition pn as of now);
ERROR HY000: System Versioning required: `BY SYSTEM_TIME` partitioning
create or replace table t1 (x int)
with system versioning
Expand All @@ -59,179 +59,138 @@ ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: no `AS OF NOW` partition def
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 as of now,
partition p1 versioning);
partition pn as of now,
partition p0 versioning);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: AS OF NOW partition is not last
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 versioning,
partition pn as of now);
alter table t1 add partition (
partition p2 as of now);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `AS OF NOW` partitions
partition p1 as of now);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: AS OF NOW partition can not be added
alter table t1 add partition (
partition p2 versioning default);
partition p1 versioning);
Warnings:
Warning 4041 Maybe missing parameters: no rotation condition for multiple `VERSIONING` partitions.
alter table t1 drop partition p0;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
/*!50500 PARTITION BY SYSTEM_TIME
(PARTITION p0 VERSIONING ENGINE = MyISAM,
PARTITION p1 VERSIONING ENGINE = MyISAM,
PARTITION pn AS OF NOW ENGINE = MyISAM) */
alter table t1 drop partition pn;
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: `AS OF NOW` partition can not be dropped
alter table t1 drop partition p2;
alter table t1 drop partition p1;
alter table t1 drop partition p0;
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: one `AS OF NOW` and at least one `VERSIONING` partition required
insert into t1 values (1);
select * from t1;
x
1
select * from t1 partition (p0);
x
1
select * from t1 partition (p1);
x
delete from t1;
select * from t1 partition (p0) for system_time all;
x
select * from t1 partition (p1) for system_time all;
x
1
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 versioning,
partition p1 as of now);
insert into t1 values (1);
select * from t1;
x
1
select * from t1 partition (p0);
x
select * from t1 partition (p1);
select * from t1 partition (pn);
x
1
delete from t1;
select * from t1 partition (p0) for system_time all;
x
1
select * from t1 partition (p1) for system_time all;
select * from t1 partition (pn) for system_time all;
x
create or replace table t1 (x int)
with system versioning
engine myisam
partition by system_time limit 1 (
partition p0 as of now,
partition p0 versioning,
partition p1 versioning,
partition p2 versioning);
Warnings:
Warning 4041 No `DEFAULT` for `VERSIONING` partitions. Setting `p1` as default.
partition pn as of now);
insert into t1 values (1), (2);
select * from t1 partition (p0);
select * from t1 partition (pn);
x
1
2
delete from t1;
Warnings:
Note 4042 Switching from partition `p1` to `p2`
select * from t1 partition (p1) for system_time all;
Note 4042 Switching from partition `p0` to `p1`
select * from t1 partition (p0) for system_time all;
x
1
select * from t1 partition (p2) for system_time all;
select * from t1 partition (p1) for system_time all;
x
2
insert into t1 values (3);
delete from t1;
Warnings:
Warning 4040 Using full partition `p2`, need more VERSIONING partitions!
select * from t1 partition (p2) for system_time all;
Warning 4040 Using full partition `p1`, need more VERSIONING partitions!
select * from t1 partition (p1) for system_time all;
x
2
3
create or replace table t1 (x int)
with system versioning
engine myisam
partition by system_time interval 1 second (
partition p0 as of now,
partition p1 versioning default,
partition p2 versioning);
partition p0 versioning,
partition p1 versioning,
partition pn as of now);
insert into t1 values (1), (2), (3);
select * from t1 partition (p0);
select * from t1 partition (pn);
x
1
2
3
delete from t1;
select * from t1 partition (p1) for system_time all;
select * from t1 partition (p0) for system_time all;
x
1
2
3
insert into t1 values (4);
delete from t1;
Warnings:
Note 4042 Switching from partition `p1` to `p2`
select * from t1 partition (p2) for system_time all;
x
4
create or replace table t1 (x int)
with system versioning
engine myisam
partition by system_time limit 1 (
partition p0 as of now,
partition p1 versioning default,
partition p2 versioning default);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `DEFAULT` partitions
create or replace table t1 (x int)
with system versioning
engine myisam
partition by system_time limit 1 (
partition p0 as of now,
partition p1 versioning,
partition p2 versioning default);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
/*!50500 PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION p0 AS OF NOW ENGINE = MyISAM,
PARTITION p1 VERSIONING ENGINE = MyISAM,
PARTITION p2 VERSIONING DEFAULT ENGINE = MyISAM) */
insert into t1 values (4), (5);
delete from t1;
Warnings:
Note 4042 Switching from partition `p2` to `p1`
select * from t1 partition (p2) for system_time all;
x
4
Note 4042 Switching from partition `p0` to `p1`
select * from t1 partition (p1) for system_time all;
x
5
4
create or replace table t1 (x int)
with system versioning
engine myisam
partition by system_time limit 1
subpartition by key (x)
subpartitions 2 (
partition p0 as of now,
partition p1 versioning default,
partition p2 versioning);
partition p0 versioning,
partition p1 versioning,
partition pn as of now);
insert into t1 (x) values (1), (2), (3);
select * from t1 partition (p0sp0);
select * from t1 partition (pnsp0);
x
1
3
select * from t1 partition (p0sp1);
select * from t1 partition (pnsp1);
x
2
delete from t1;
Warnings:
Note 4042 Switching from partition `p1` to `p2`
Warning 4040 Using full partition `p2`, need more VERSIONING partitions!
select * from t1 partition (p1sp0) for system_time all;
Note 4042 Switching from partition `p0` to `p1`
Warning 4040 Using full partition `p1`, need more VERSIONING partitions!
select * from t1 partition (p0sp0) for system_time all;
x
1
select * from t1 partition (p1sp1) for system_time all;
select * from t1 partition (p0sp1) for system_time all;
x
select * from t1 partition (p2sp0) for system_time all;
select * from t1 partition (p1sp0) for system_time all;
x
3
select * from t1 partition (p2sp1) for system_time all;
select * from t1 partition (p1sp1) for system_time all;
x
2
drop table t1;
Loading

0 comments on commit 26f5cbe

Please sign in to comment.