Skip to content

Commit

Permalink
SQL: (0.5) Versioned partitions [closes #77]
Browse files Browse the repository at this point in the history
* one `AS OF NOW`, multiple `VERSIONING` partitions;
* rotation of `VERSIONING` partitions by record count, time period;
* rotation is multi-threaded;
* conventional subpartitions as bottom level for versioned partitions;
* `DEFAULT` keyword selects first `VERSIONING` partition;
* ALTER TABLE ADD/DROP partition;
* REBUILD PARTITION basic operation.
  • Loading branch information
midenok committed Dec 15, 2016
1 parent da5708f commit f4a097b
Show file tree
Hide file tree
Showing 31 changed files with 1,326 additions and 115 deletions.
4 changes: 1 addition & 3 deletions mysql-test/r/parser.result
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ create table MIN(a int);
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 'MIN(a int)' at line 1
create table MIN (a int);
drop table MIN;
create table NOW(a int);
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 'NOW(a int)' at line 1
create table NOW (a int);
drop table NOW;
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 'NOW (a int)' at line 1
create table POSITION(a int);
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 'POSITION(a int)' at line 1
create table POSITION (a int);
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setti
create table t1 (a int)
partition by hash (a)
(partition p0 (subpartition sp0));
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
create table t1 (a int)
partition by range (a)
(partition p0 values less than (1));
Expand Down
14 changes: 7 additions & 7 deletions mysql-test/r/partition_error.result
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLD_DATADIR/test/t1.par');
load_file('$MYSQLD_DATADIR/test/t1.par')
NULL
Expand All @@ -1034,7 +1034,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (a, b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLD_DATADIR/test/t1.par');
load_file('$MYSQLD_DATADIR/test/t1.par')
NULL
Expand All @@ -1045,7 +1045,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLD_DATADIR/test/t1.par');
load_file('$MYSQLD_DATADIR/test/t1.par')
NULL
Expand All @@ -1056,7 +1056,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLD_DATADIR/test/t1.par');
load_file('$MYSQLD_DATADIR/test/t1.par')
NULL
Expand All @@ -1067,7 +1067,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (a, b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLD_DATADIR/test/t1.par');
load_file('$MYSQLD_DATADIR/test/t1.par')
NULL
Expand All @@ -1078,7 +1078,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
select load_file('$MYSQLD_DATADIR/test/t1.par');
load_file('$MYSQLD_DATADIR/test/t1.par')
NULL
Expand Down Expand Up @@ -1135,7 +1135,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (3+4);
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
CREATE TABLE t1 (
a int not null,
b int not null,
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition_syntax_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ f_charbig VARCHAR(1000)
)
PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11));
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
#------------------------------------------------------------------------
# 2.2 Every partition must have the same number of subpartitions.
# This is a limitation of MySQL 5.1, which could be removed in
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition_syntax_myisam.result
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ f_charbig VARCHAR(1000)
)
PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11));
ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning
#------------------------------------------------------------------------
# 2.2 Every partition must have the same number of subpartitions.
# This is a limitation of MySQL 5.1, which could be removed in
Expand Down
18 changes: 9 additions & 9 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t without system versioning;
ERROR HY000: Wrong parameters for versioned table `t`: table is not versioned
ERROR HY000: Wrong parameters for `t`: table is not versioned
alter table t with system versioning without system versioning;
ERROR HY000: Wrong parameters for versioned table `t`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same table
alter table t with system versioning;
show create table t;
Table Create Table
Expand Down Expand Up @@ -119,9 +119,9 @@ t CREATE TABLE `t` (
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column f int after sys_trx_start;
ERROR HY000: Wrong parameters for versioned table `t`: Can not put new field after system versioning field
ERROR HY000: Wrong parameters for `t`: Can not put new field after system versioning field
alter table t add column f int after sys_trx_end;
ERROR HY000: Wrong parameters for versioned table `t`: Can not put new field after system versioning field
ERROR HY000: Wrong parameters for `t`: Can not put new field after system versioning field
alter table t drop column a;
show create table t;
Table Create Table
Expand All @@ -135,9 +135,9 @@ t CREATE TABLE `t` (
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t drop column sys_trx_start;
ERROR HY000: Wrong parameters for versioned table `t`: Can not drop system versioning field
ERROR HY000: Wrong parameters for `t`: Can not drop system versioning field
alter table t drop column sys_trx_end;
ERROR HY000: Wrong parameters for versioned table `t`: Can not drop system versioning field
ERROR HY000: Wrong parameters for `t`: Can not drop system versioning field
create or replace table t(
a int
);
Expand Down Expand Up @@ -205,11 +205,11 @@ t CREATE TABLE `t` (
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t modify a int with system versioning;
ERROR HY000: Wrong parameters for versioned table `t`: Can not change fields versioning mode in a non-versioned table
ERROR HY000: Wrong parameters for `t`: Can not change fields versioning mode in a non-versioned table
alter table t modify a int with system versioning with system versioning;
ERROR HY000: Wrong parameters for versioned table `t`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same field
alter table t modify a int with system versioning without system versioning;
ERROR HY000: Wrong parameters for versioned table `t`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same field
alter table t with system versioning;
alter table t modify a int without system versioning;
show create table t;
Expand Down
36 changes: 18 additions & 18 deletions mysql-test/suite/versioning/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -32,56 +32,56 @@ Sys_start2 timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: multiple 'GENERATED ALWAYS AS ROW START'
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW START'
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: multiple 'GENERATED ALWAYS AS ROW END'
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
create or replace table t1 (
XNo int unsigned,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: 'GENERATED AS ROW START' column missing
ERROR HY000: Wrong parameters for `t1`: 'GENERATED AS ROW START' column missing
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_end2 timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for versioned table `t1`: multiple 'GENERATED ALWAYS AS ROW END'
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (sys_insert, sys_remove)
) with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for versioned table `t1`: 'WITH SYSTEM VERSIONING' missing
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
create or replace table t1 (
XNo int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: Wrong parameters for versioned table `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different
create or replace table t1 (
XNo int unsigned,
Sys_start int generated always as row start,
Expand Down Expand Up @@ -147,7 +147,7 @@ create or replace table t1 (
A int,
B int without system versioning
);
ERROR HY000: Wrong parameters for versioned table `t1`: 'WITH SYSTEM VERSIONING' missing
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
create or replace table t1 (
A int,
B int without system versioning
Expand Down Expand Up @@ -190,37 +190,37 @@ t1 CREATE TABLE `t1` (
create or replace table t1 (
A int without system versioning
);
ERROR HY000: Wrong parameters for versioned table `t1`: 'WITH SYSTEM VERSIONING' missing
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
create or replace table t1 (
A int without system versioning
) with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: versioned fields missing
ERROR HY000: Wrong parameters for `t1`: versioned fields missing
create or replace table t1 (
A int without system versioning with system versioning
);
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
create or replace table t1 (
A int with system versioning without system versioning
);
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
create table t(
a int
) without system versioning;
ERROR HY000: Wrong parameters for versioned table `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
ERROR HY000: Wrong parameters for `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
create or replace table t1 (
A int
) without system versioning with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (
A int
) with system versioning without system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (
A int
) with system versioning with system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (
A int
) without system versioning without system versioning;
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
drop table t1;
Loading

0 comments on commit f4a097b

Please sign in to comment.