Skip to content

Commit

Permalink
SQL, Parser: system_time logic and syntax fixes [closes #237]
Browse files Browse the repository at this point in the history
  • Loading branch information
midenok committed Aug 8, 2017
1 parent 53370de commit d3d2ea9
Show file tree
Hide file tree
Showing 25 changed files with 263 additions and 434 deletions.
8 changes: 2 additions & 6 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ t CREATE TABLE `t` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t without system versioning;
ERROR HY000: Wrong parameters for `t`: table is not versioned
alter table t with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
alter table t with system versioning;
show create table t;
Table Create Table
Expand Down Expand Up @@ -226,10 +224,8 @@ t CREATE TABLE `t` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t modify a int with system versioning;
ERROR HY000: Wrong parameters for `t`: table is not versioned
alter table t modify a int with system versioning with system versioning;
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `a`
alter table t modify a int with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `a`
alter table t modify a int without system versioning;
ERROR HY000: Wrong parameters for `t`: table is not versioned
alter table t with system versioning;
alter table t modify a int without system versioning;
show create table t;
Expand Down
32 changes: 4 additions & 28 deletions mysql-test/suite/versioning/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Sys_start2 SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW START' (`Sys_start2`, `Sys_start`)
ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW START'
create or replace table t1 (
x4 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Expand All @@ -118,7 +118,7 @@ Sys_end SYS_TRX_TYPE generated always as row end,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW END' (`Sys_end2`, `Sys_end`)
ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW END'
create or replace table t1 (
x6 int unsigned,
period for system_time (Sys_start, Sys_end)
Expand All @@ -131,7 +131,7 @@ Sys_end SYS_TRX_TYPE generated always as row end,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW END' (`Sys_end2`, `Sys_end`)
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x8 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Expand All @@ -152,7 +152,7 @@ Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: Wrong parameters for `t1`: multiple `Sys_start` for 'PERIOD FOR SYSTEM_TIME'
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x11 int unsigned,
Sys_start bigint unsigned generated always as row start,
Expand Down Expand Up @@ -257,34 +257,10 @@ create or replace table t1 (
A8 int without system versioning
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: no columns defined 'WITH SYSTEM VERSIONING'
create or replace table t1 (
A9 int without system versioning with system versioning
);
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `A9`
create or replace table t1 (
A10 int with system versioning without system versioning
);
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `A10`
create table t(
a11 int
) without system versioning;
ERROR HY000: Wrong parameters for `t`: not allowed 'WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A12 int
) without system versioning with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A13 int
) with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A14 int
) with system versioning with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A15 int
) without system versioning without system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (a int) with system versioning;
create temporary table tmp with system versioning select * from t1;
create or replace table t1 (a int) with system versioning;
Expand Down
52 changes: 2 additions & 50 deletions mysql-test/suite/versioning/r/select.result
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ASOF_x y
7 107
8 108
9 109
select x as FROMTO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1;
FROMTO_x y
0 100
1 101
Expand All @@ -114,7 +114,7 @@ FROMTO_x y
7 107
8 108
9 109
select x as BETWAND_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1;
BETWAND_x y
0 100
1 101
Expand All @@ -127,31 +127,6 @@ BETWAND_x y
8 108
9 109
3 33
select x as FROMTO_ext_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
FROMTO_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
select x as BETWAND_ext_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
BETWAND_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
select x as ALL_x, y from t1 for system_time all;
ALL_x y
0 100
Expand Down Expand Up @@ -199,29 +174,6 @@ BETWAND2_x y
8 108
9 109
3 33
FROMTO2_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
BETWAND2_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
create or replace table t1 (
x int unsigned,
y int unsigned
Expand Down
64 changes: 6 additions & 58 deletions mysql-test/suite/versioning/r/select_sp.result
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,17 @@ select vtq_commit_ts(@x1) into @t1;
end if;
select x, y from t1;
select x as ASOF_x, y from t1 for system_time as of timestamp @t0;
select x as FROMTO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO_ext_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND_ext_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1;
select x as ALL_x, y from t1 for system_time all;
if engine = 'innodb' then
select x as ASOF2_x, y from t1 for system_time as of transaction @x0;
select x as FROMTO2_x, y from t1 for system_time from transaction @x0 to transaction @x1;
select x as ASOF2_x, y from t1 for system_time as of @x0;
select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1;
select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1;
select x as FROMTO2_ext_x, y from t1 for system_time transaction from @x0 to @x1;
select x as BETWAND2_ext_x, y from t1 for system_time transaction between @x0 and @x1;
else
select x as ASOF2_x, y from t1 for system_time as of timestamp @t0;
select x as FROMTO2_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as ASOF2_x, y from t1 for system_time as of @t0;
select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO2_ext_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND2_ext_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
end if;
drop table t1;
end~~
Expand Down Expand Up @@ -198,29 +192,6 @@ BETWAND_x y
8 108
9 109
3 33
FROMTO_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
BETWAND_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
ALL_x y
0 100
1 101
Expand Down Expand Up @@ -267,29 +238,6 @@ BETWAND2_x y
8 108
9 109
3 33
FROMTO2_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
BETWAND2_ext_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
call test_02();
IJ1_x1 y1 x2 y2
1 1 1 2
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/versioning/r/sysvars.result
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ select * from t for system_time all;
a sys_trx_start sys_trx_end
2 TIMESTAMP TIMESTAMP
1 TIMESTAMP TIMESTAMP
select * from t for system_time timestamp from '0-0-0' to current_timestamp(6);
select * from t for system_time from '0-0-0' to current_timestamp(6);
a sys_trx_start sys_trx_end
2 TIMESTAMP TIMESTAMP
1 TIMESTAMP TIMESTAMP
select * from t for system_time timestamp between '0-0-0' and current_timestamp(6);
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
Expand Down
20 changes: 10 additions & 10 deletions mysql-test/suite/versioning/r/truncate.result
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
create table t (a int);
truncate t for system_time all;
ERROR HY000: Unused clause: 'SYSTEM_TIME'
ERROR HY000: System Versioning required: t
create procedure truncate_history_of_t()
begin
prepare stmt from 'truncate t for system_time timestamp between \'1-1-1\' and now(6)';
prepare stmt from 'truncate t for system_time between \'1-1-1\' and now(6)';
execute stmt;
drop prepare stmt;
end~~
Expand Down Expand Up @@ -34,12 +34,12 @@ a
4
2
3
truncate t for system_time timestamp between '1-1-1' and now(6);
truncate t for system_time between '1-1-1' and now(6);
select * from t for system_time all;
a
4
update t set a=5;
truncate t for system_time timestamp from '1-1-1' to now(6);
truncate t for system_time from '1-1-1' to now(6);
select * from t for system_time all;
a
5
Expand All @@ -52,13 +52,13 @@ set @ts1 = now(6);
update t set a=7;
set @ts2 = now(6);
update t set a=8;
truncate t for system_time timestamp from '1-1-1' to @ts1;
truncate t for system_time from '1-1-1' to @ts1;
select * from t for system_time all;
a
8
7
update t set a=9;
truncate t for system_time timestamp between '1-1-1' and @ts2;
truncate t for system_time between '1-1-1' and @ts2;
select * from t for system_time all;
a
9
Expand All @@ -82,12 +82,12 @@ a
4
2
3
truncate t for system_time timestamp between '1-1-1' and now(6);
truncate t for system_time between '1-1-1' and now(6);
select * from t for system_time all;
a
4
update t set a=5;
truncate t for system_time timestamp from '1-1-1' to now(6);
truncate t for system_time from '1-1-1' to now(6);
select * from t for system_time all;
a
5
Expand All @@ -100,13 +100,13 @@ set @ts1 = now(6);
update t set a=7;
set @ts2 = now(6);
update t set a=8;
truncate t for system_time timestamp from '1-1-1' to @ts1;
truncate t for system_time from '1-1-1' to timestamp @ts1;
select * from t for system_time all;
a
8
7
update t set a=9;
truncate t for system_time timestamp between '1-1-1' and @ts2;
truncate t for system_time between '1-1-1' and timestamp @ts2;
select * from t for system_time all;
a
9
Expand Down
6 changes: 1 addition & 5 deletions mysql-test/suite/versioning/t/alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ create table t(
show create table t;
--error ER_VERS_WRONG_PARAMS
alter table t without system versioning;
--error ER_VERS_WRONG_PARAMS
alter table t with system versioning without system versioning;

alter table t with system versioning;
show create table t;
Expand Down Expand Up @@ -118,9 +116,7 @@ show create table t;
--error ER_VERS_WRONG_PARAMS
alter table t modify a int with system versioning;
--error ER_VERS_WRONG_PARAMS
alter table t modify a int with system versioning with system versioning;
--error ER_VERS_WRONG_PARAMS
alter table t modify a int with system versioning without system versioning;
alter table t modify a int without system versioning;

alter table t with system versioning;

Expand Down
Loading

0 comments on commit d3d2ea9

Please sign in to comment.