1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-30 05:23:50 +03:00

System Versioning 1.0 pre6

Merge remote-tracking branch 'mariadb/bb-10.3-temporal-serg' into trunk
This commit is contained in:
Aleksey Midenkov
2017-12-15 18:12:18 +03:00
47 changed files with 528 additions and 541 deletions

View File

@@ -1,5 +1,5 @@
select @@versioning_alter_history;
@@versioning_alter_history
select @@system_versioning_alter_history;
@@system_versioning_alter_history
ERROR
create table t(
a int
@@ -21,7 +21,7 @@ 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 y int;
ERROR HY000: Not allowed for versioned `test`.`t`. Change `versioning_alter_history` to proceed with ALTER.
ERROR HY000: Not allowed for versioned `test`.`t`. Change @@system_versioning_alter_history to proceed with ALTER.
alter table t engine innodb;
ERROR HY000: Not allowed for versioned `test`.`t`. Change to/from native versioning engine is prohibited.
alter table t drop system versioning;
@@ -30,7 +30,7 @@ Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set versioning_alter_history= keep;
set system_versioning_alter_history= keep;
alter table t
add column trx_start bigint(20) unsigned generated always as row start,
add column trx_end bigint(20) unsigned generated always as row end,
@@ -398,6 +398,16 @@ t CREATE TABLE `t` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
call verify_vtq;
No A B C D
create or replace table t (a int);
insert t values (1),(2),(3),(4);
alter table t add b int auto_increment null unique;
select * from t;
a b
1 1
2 2
3 3
4 4
drop table t;
create or replace table t (a int) with system versioning engine=innodb;
insert into t values (1), (2), (3);
delete from t where a<3;
@@ -493,10 +503,10 @@ Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set versioning_alter_history= SURVIVE;
ERROR 42000: Variable 'versioning_alter_history' can't be set to the value of 'SURVIVE'
set versioning_alter_history= DROP;
ERROR 42000: Variable 'versioning_alter_history' can't be set to the value of 'DROP'
set system_versioning_alter_history= SURVIVE;
ERROR 42000: Variable 'system_versioning_alter_history' can't be set to the value of 'SURVIVE'
set system_versioning_alter_history= DROP;
ERROR 42000: Variable 'system_versioning_alter_history' can't be set to the value of 'DROP'
create or replace table t (a int) with system versioning;
alter table t add system versioning;
ERROR HY000: Table `t` is already system-versioned table

View File

@@ -119,13 +119,13 @@ emp_id name mgr address
2 bill 1 New York
3 kate 1 London
4 john 1 Paris
with ancestors as (select * from emp natural join addr where 1 for system_time all) select * from ancestors;
with ancestors as (select * from (select * from emp natural join addr) for system_time all as t) select * from ancestors;
emp_id name mgr address
1 bill 0 Moscow
2 bill 1 New York
3 kate 1 London
4 john 1 Paris
select * from emp natural join addr where 1 for system_time all;
select * from (select * from emp natural join addr) for system_time all as t;
emp_id name mgr address
1 bill 0 Moscow
2 bill 1 New York

View File

@@ -91,13 +91,11 @@ ancestors
as
(
select e.emp_id, e.name, e.mgr
from emp as e
from emp for system_time as of timestamp @ts as e
where name = 'bill'
for system_time as of timestamp @ts
union
union
select ee.emp_id, ee.name, ee.mgr
from emp
for system_time as of timestamp @ts as ee,
from emp for system_time as of timestamp @ts as ee,
ancestors as a
where ee.mgr = a.emp_id
)
@@ -112,9 +110,8 @@ ancestors
as
(
select e.emp_id, e.name, e.mgr
from emp as e
from emp for system_time as of timestamp @ts as e
where name = 'bill'
for system_time as of timestamp @ts
union
select ee.emp_id, ee.name, ee.mgr
from emp for system_time as of timestamp @ts as ee,
@@ -170,7 +167,7 @@ select * from (select * from vt1, t2) as s0;
x y
1 10
### SYSTEM_TIME clash
select * from (select * from t1 for system_time all) dt0 for system_time all;
select * from (select * from t1 for system_time all) for system_time all as dt0;
ERROR HY000: SYSTEM_TIME is not allowed outside historical `dt0`
select * from vt1 for system_time all;
ERROR HY000: SYSTEM_TIME is not allowed outside historical `vt1`

View File

@@ -25,7 +25,7 @@ a b
3 NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select count(*) from t group by b for system_time as of timestamp now(6);
select count(*) from t for system_time as of timestamp now(6) group by b;
count(*)
2
Warnings:
@@ -44,41 +44,10 @@ a b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4112 Attempt to read unversioned field `b` in historical query
select * from t group by a having a=2 for system_time as of timestamp now(6);
select * from t for system_time as of timestamp now(6) group by a having a=2;
a b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select * from t group by b having b=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select a from t where b=2 for system_time as of timestamp now(6);
a
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select a from t where b=NULL for system_time as of timestamp now(6);
a
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select a from t where b is NULL for system_time as of timestamp now(6);
a
1
3
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6);
count(*) b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select a, b from t;
a b
1 2
3 4
select count(*) from t for system_time as of timestamp now(6) group by b;
count(*)
2
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select * from t for system_time as of timestamp now(6) group by b having b=2;
a b
Warnings:
@@ -101,6 +70,10 @@ select count(*), b from t for system_time as of timestamp now(6) group by b havi
count(*) b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
select a, b from t;
a b
1 2
3 4
create or replace table t (
a int,
b int not null without system versioning

View File

@@ -22,10 +22,10 @@ select * from t1 for system_time all;
x
3
300
select * from t1 partition (p0) for system_time all;
select * from t1 partition (p0);
x
3
select * from t1 partition (p1) for system_time all;
select * from t1 partition (p1);
x
300
### Engine change versioned/non-versioned prohibited
@@ -35,50 +35,50 @@ ERROR HY000: Not allowed for versioned `test`.`t1`. Change to/from native versio
### check server-level partitioning
create or replace table t1 (x int)
partition by system_time (
partition p0 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition pn current);
ERROR HY000: Engine does not support System Versioning for `t1`
create or replace table t1 (x int);
alter table t1
partition by system_time (
partition p0 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition pn current);
Got one of the listed errors
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 as of current_timestamp);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
partition p0 current);
ERROR HY000: Wrong partitions consistency 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 as of current_timestamp,
partition p1 as of current_timestamp);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
partition p0 current,
partition p1 current);
ERROR HY000: Wrong partitions consistency 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 versioning,
partition p1 versioning);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
partition p0 history,
partition p1 history);
ERROR HY000: Wrong partitions consistency 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 as of current_timestamp,
partition p0 versioning);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
partition pn current,
partition p0 history);
ERROR HY000: Wrong partitions consistency 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 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition pn current);
alter table t1 add partition (
partition p1 as of current_timestamp);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
partition p1 current);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
alter table t1 add partition (
partition p1 versioning);
partition p1 history);
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple `VERSIONING` partitions.
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -88,15 +88,15 @@ t1 CREATE TABLE `t1` (
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
(PARTITION `p0` VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1` VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION `pn` AS OF CURRENT_TIMESTAMP ENGINE = ${INNODB_OR_MYISAM})
(PARTITION `p0` HISTORY ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1` HISTORY ENGINE = ${INNODB_OR_MYISAM},
PARTITION `pn` CURRENT ENGINE = ${INNODB_OR_MYISAM})
insert into t1 values (1), (2);
alter table t1 drop partition pn;
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
ERROR HY000: Wrong partitions consistency 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 consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
select x from t1;
x
1
@@ -104,15 +104,15 @@ x
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition pn current);
set @now= now(6);
insert into t1 values (1);
set @ts_start= sys_commit_ts('sys_trx_start');
set @ts_end= sys_commit_ts('sys_trx_end');
set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all');
set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0)');
prepare select_p0 from @str;
set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn) for system_time all');
set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_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
@@ -133,7 +133,7 @@ x A B
1 1 1
execute select_pn;
x C D
set @str= concat('select ', @ts_start, ' from t1 partition (p0) for system_time all into @ts1');
set @str= concat('select ', @ts_start, ' from t1 partition (p0) into @ts1');
prepare stmt from @str;
execute stmt;
drop prepare stmt;
@@ -163,11 +163,11 @@ x C D
3 1 1
drop prepare select_p0;
drop prepare select_pn;
set @str= concat('select ', @ts_start, ' from t1 partition (p0) for system_time all where x = 2 into @ts1');
set @str= concat('select ', @ts_start, ' from t1 partition (p0) where x = 2 into @ts1');
prepare stmt from @str;
execute stmt;
drop prepare stmt;
set @str= concat('select ', @ts_end, ' from t1 partition (p0) for system_time all where x = 2 into @ts2');
set @str= concat('select ', @ts_end, ' from t1 partition (p0) where x = 2 into @ts2');
prepare stmt from @str;
execute stmt;
drop prepare stmt;
@@ -184,16 +184,16 @@ select @ts2 = @ts3;
create or replace table t1 (x int)
with system versioning
partition by system_time limit 0 (
partition p0 versioning,
partition p1 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition p1 history,
partition pn current);
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 1 (
partition p0 versioning,
partition p1 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition p1 history,
partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -203,9 +203,9 @@ t1 CREATE TABLE `t1` (
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION `p0` VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1` VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION `pn` AS OF CURRENT_TIMESTAMP ENGINE = ${INNODB_OR_MYISAM})
(PARTITION `p0` HISTORY ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1` HISTORY ENGINE = ${INNODB_OR_MYISAM},
PARTITION `pn` CURRENT ENGINE = ${INNODB_OR_MYISAM})
alter table t1 drop partition non_existent;
ERROR HY000: Error in list of partitions to DROP
insert into t1 values (1), (2);
@@ -215,34 +215,34 @@ x
2
delete from t1;
Warnings:
Note 4116 Switching from partition `p0` to `p1`
select * from t1 partition (p0) for system_time all;
Note 4116 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
select * from t1 partition (p0);
x
1
select * from t1 partition (p1) for system_time all;
select * from t1 partition (p1);
x
2
insert into t1 values (3);
delete from t1;
Warnings:
Warning 4114 Using full partition `p1`, need more VERSIONING partitions!
select * from t1 partition (p1) for system_time all;
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
select * from t1 partition (p1);
x
2
3
create or replace table t1 (x int)
with system versioning
partition by system_time interval 0 second (
partition p0 versioning,
partition p1 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition p1 history,
partition pn current);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
create or replace table t1 (x int)
with system versioning
partition by system_time interval 1 second (
partition p0 versioning,
partition p1 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 values (1), (2), (3);
select * from t1 partition (pn);
x
@@ -250,7 +250,7 @@ x
2
3
delete from t1;
select * from t1 partition (p0) for system_time all;
select * from t1 partition (p0);
x
1
2
@@ -258,8 +258,8 @@ x
insert into t1 values (4);
delete from t1;
Warnings:
Note 4116 Switching from partition `p0` to `p1`
select * from t1 partition (p1) for system_time all;
Note 4116 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
select * from t1 partition (p1);
x
4
create or replace table t1 (x int)
@@ -267,9 +267,9 @@ with system versioning
partition by system_time limit 1
subpartition by key (x)
subpartitions 2 (
partition p0 versioning,
partition p1 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 (x) values (1), (2), (3);
select * from t1 partition (pnsp0);
x
@@ -280,17 +280,17 @@ x
2
delete from t1;
Warnings:
Note 4116 Switching from partition `p0` to `p1`
Warning 4114 Using full partition `p1`, need more VERSIONING partitions!
select * from t1 partition (p0sp0) for system_time all;
Note 4116 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
select * from t1 partition (p0sp0);
x
1
select * from t1 partition (p0sp1) for system_time all;
select * from t1 partition (p0sp1);
x
select * from t1 partition (p1sp0) for system_time all;
select * from t1 partition (p1sp0);
x
3
select * from t1 partition (p1sp1) for system_time all;
select * from t1 partition (p1sp1);
x
2
create or replace table t1 (a bigint)

View File

@@ -144,22 +144,43 @@ NULL NULL 2 1
NULL NULL 3 1
delete from t1;
delete from t2;
select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
explain extended select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6)))
explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL left join `test`.`t2` FOR SYSTEM_TIME ALL on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6)))) where 1
explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME ALL left join `test`.`t1` FOR SYSTEM_TIME ALL on(`test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6)))) where 1
select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
IJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
LJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
1 3 1 2
4 4 NULL NULL
5 5 NULL NULL
select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
RJ2_x1 y1 x2 y2
1 1 1 2
1 2 1 2
@@ -280,8 +301,9 @@ select * from t1, t2 for system_time all;
x y
1 1
2 1
select * from t1 for system_time all, t2 for system_time all for system_time all;
ERROR HY000: Unused clause: 'SYSTEM_TIME'
select * from (select * from t1 for system_time all, t2 for system_time all)
for system_time all as t;
ERROR HY000: SYSTEM_TIME is not allowed outside historical `t`
# TRANSACTION/TIMESTAMP specifier in SYSTEM_TIME [MDEV-14645, Issue #396]
create or replace table t1 (x int) with system versioning engine myisam;
select * from t1 for system_time as of transaction 1;

View File

@@ -77,12 +77,12 @@ select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 o
select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x;
delete from t1;
delete from t2;
select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x
for system_time as of timestamp @t0;
select IJ2_x1,y1,x2,y2 from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
select LJ2_x1,y1,x2,y2 from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
select RJ2_x1,y1,x2,y2 from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
for system_time as of timestamp @t0 as t;
drop table t1;
drop table t2;
end~~
@@ -321,8 +321,10 @@ select * from t1, t2 for system_time all;
x y
1 1
2 1
select * from t1 for system_time all, t2 for system_time all for system_time all;
ERROR HY000: Unused clause: 'SYSTEM_TIME'
select * from (select * from t1 for system_time all, t2 for system_time all) for system_time all as t;
ERROR HY000: SYSTEM_TIME is not allowed outside historical `t`
select * from (t1 for system_time all join t2 for system_time all) for system_time all;
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 '' at line 1
drop view v1;
drop table t1, t2;
call innodb_verify_vtq(27);

View File

@@ -42,31 +42,32 @@ where d.dept_id = 10
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 2000 10 accounting
select * from emp e, dept d
select * from
emp for system_time from timestamp @ts_1 to timestamp @ts_2 e,
dept for system_time from timestamp @ts_1 to timestamp @ts_2 d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time from timestamp @ts_1 to timestamp @ts_2;
and d.dept_id = e.dept_id;
emp_id dept_id name salary sys_trx_start sys_trx_end dept_id name sys_trx_start sys_trx_end
set statement system_versioning_asof=@ts_0 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_0;
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
set statement system_versioning_asof=@ts_1 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_1;
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
set statement system_versioning_asof=@ts_2 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_2;
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 1000 10 accounting
set statement system_versioning_asof=@ts_3 for
select * from emp e, dept d
where d.dept_id = 10
and d.dept_id = e.dept_id
for system_time as of timestamp @ts_3;
and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 2000 10 accounting
drop table emp, dept;

View File

@@ -1,116 +1,98 @@
create table t (a int) with system versioning;
insert into t values (1);
update t set a= 2;
show global variables like 'versioning_asof_timestamp';
show global variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp CURRENT
show variables like 'versioning_asof_timestamp';
system_versioning_asof DEFAULT
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp CURRENT
system_versioning_asof DEFAULT
select * from t;
a
2
set versioning_asof_timestamp= '2031-1-1 0:0:0';
show variables like 'versioning_asof_timestamp';
set system_versioning_asof= '2031-1-1 0:0:0';
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 2031-01-01 00:00:00.000000
system_versioning_asof 2031-01-01 00:00:00.000000
select * from t;
a
2
set versioning_asof_timestamp= '2011-1-1 0:0:0';
show variables like 'versioning_asof_timestamp';
set system_versioning_asof= '2011-1-1 0:0:0';
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 2011-01-01 00:00:00.000000
system_versioning_asof 2011-01-01 00:00:00.000000
select * from t;
a
set versioning_asof_timestamp= ALL;
show variables like 'versioning_asof_timestamp';
Variable_name Value
versioning_asof_timestamp ALL
select * from t;
a
2
1
create view vt as select * from t;
select * from t;
a
2
1
drop view vt;
select * from (select * from t) as tt;
a
2
1
set global versioning_asof_timestamp= 'alley';
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'alley'
set global versioning_asof_timestamp= null;
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'NULL'
set global versioning_asof_timestamp= 1;
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
set global versioning_asof_timestamp= 1.1;
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
set versioning_asof_timestamp= 'alley';
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'alley'
set versioning_asof_timestamp= null;
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'NULL'
set versioning_asof_timestamp= 1;
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
set versioning_asof_timestamp= 1.1;
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
set global versioning_asof_timestamp= '1911-11-11 11:11:11.1111119';
set global system_versioning_asof= 'alley';
ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of 'alley'
set global system_versioning_asof= null;
ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of 'NULL'
set global system_versioning_asof= 1;
ERROR 42000: Incorrect argument type to variable 'system_versioning_asof'
set global system_versioning_asof= 1.1;
ERROR 42000: Incorrect argument type to variable 'system_versioning_asof'
set system_versioning_asof= 'alley';
ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of 'alley'
set system_versioning_asof= null;
ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of 'NULL'
set system_versioning_asof= 1;
ERROR 42000: Incorrect argument type to variable 'system_versioning_asof'
set system_versioning_asof= 1.1;
ERROR 42000: Incorrect argument type to variable 'system_versioning_asof'
set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
Warnings:
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
show global variables like 'versioning_asof_timestamp';
show global variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1911-11-11 11:11:11.111111
set global versioning_asof_timestamp= '1900-01-01 00:00:00';
show global variables like 'versioning_asof_timestamp';
system_versioning_asof 1911-11-11 11:11:11.111111
set global system_versioning_asof= '1900-01-01 00:00:00';
show global variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1900-01-01 00:00:00.000000
set global versioning_asof_timestamp= timestamp'1911-11-11 11:11:11.1111119';
system_versioning_asof 1900-01-01 00:00:00.000000
set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
Warnings:
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
show global variables like 'versioning_asof_timestamp';
show global variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1911-11-11 11:11:11.111111
system_versioning_asof 1911-11-11 11:11:11.111111
set @ts= timestamp'1900-01-01 00:00:00';
set global versioning_asof_timestamp= @ts;
show global variables like 'versioning_asof_timestamp';
set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1900-01-01 00:00:00.000000
set versioning_asof_timestamp= '1911-11-11 11:11:11.1111119';
system_versioning_asof 1900-01-01 00:00:00.000000
set system_versioning_asof= '1911-11-11 11:11:11.1111119';
Warnings:
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
show variables like 'versioning_asof_timestamp';
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1911-11-11 11:11:11.111111
set versioning_asof_timestamp= '1900-01-01 00:00:00';
show variables like 'versioning_asof_timestamp';
system_versioning_asof 1911-11-11 11:11:11.111111
set system_versioning_asof= '1900-01-01 00:00:00';
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1900-01-01 00:00:00.000000
set versioning_asof_timestamp= timestamp'1911-11-11 11:11:11.1111119';
system_versioning_asof 1900-01-01 00:00:00.000000
set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
Warnings:
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
show variables like 'versioning_asof_timestamp';
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1911-11-11 11:11:11.111111
system_versioning_asof 1911-11-11 11:11:11.111111
set @ts= timestamp'1900-01-01 00:00:00';
set versioning_asof_timestamp= @ts;
show variables like 'versioning_asof_timestamp';
set system_versioning_asof= @ts;
show variables like 'system_versioning_asof';
Variable_name Value
versioning_asof_timestamp 1900-01-01 00:00:00.000000
set global versioning_asof_timestamp= CURRENT;
set versioning_asof_timestamp= CURRENT;
show variables where variable_name = "versioning_hide";
system_versioning_asof 1900-01-01 00:00:00.000000
set global system_versioning_asof= DEFAULT;
set system_versioning_asof= DEFAULT;
show variables where variable_name = "system_versioning_hide";
Variable_name Value
versioning_hide IMPLICIT
system_versioning_hide IMPLICIT
select * from t for system_time all;
a
2
1
set versioning_hide= AUTO;
set system_versioning_hide= AUTO;
select * from t;
a
2
@@ -129,11 +111,11 @@ select * from t for system_time between '0-0-0' and current_timestamp(6);
a sys_trx_start sys_trx_end
2 TIMESTAMP TIMESTAMP
1 TIMESTAMP TIMESTAMP
set versioning_hide= NEVER;
set system_versioning_hide= NEVER;
select * from t;
a sys_trx_start sys_trx_end
2 TIMESTAMP TIMESTAMP
set versioning_hide= FULL;
set system_versioning_hide= FULL;
create or replace table t (
x int,
st timestamp(6) generated always as row start,
@@ -153,4 +135,4 @@ select * from t for system_time all;
x
2
drop table t;
set versioning_hide= IMPLICIT;
set system_versioning_hide= IMPLICIT;

View File

@@ -39,8 +39,8 @@ create or replace table t (a int)
with system versioning
engine myisam
partition by system_time (
partition p0 versioning,
partition pn as of current_timestamp);
partition p0 history,
partition pn current);
truncate table t to system_time current_timestamp;
ERROR 42000: The used command is not allowed with this MariaDB version
drop table t;

View File

@@ -13,8 +13,8 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
truncate mysqltest.t to system_time now();
ERROR 42000: DELETE VERSIONING ROWS command denied to user 'mysqltest_1'@'localhost' for table 't'
connection root;
grant delete versioning rows on mysqltest.* to mysqltest_1@localhost;
grant delete versioning rows on mysqltest.t to mysqltest_1@localhost;
grant delete history on mysqltest.* to mysqltest_1@localhost;
grant delete history on mysqltest.t to mysqltest_1@localhost;
connection user1;
show grants;
Grants for mysqltest_1@localhost