Skip to content

Commit

Permalink
Parser: syntax extension FOR SYSTEM_TIME ALL
Browse files Browse the repository at this point in the history
  • Loading branch information
midenok committed May 5, 2017
1 parent 9a7a9ae commit eff649e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
25 changes: 25 additions & 0 deletions mysql-test/suite/versioning/r/select.result
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ select x as FROMTO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to
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 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 0 to transaction @x1;
Expand Down Expand Up @@ -169,6 +170,18 @@ BETWAND_ext_x y
8 108
9 109
3 33
ALL_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_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_start)');
x y
0 100
Expand Down Expand Up @@ -236,6 +249,18 @@ BETWAND_ext_x y
8 108
9 109
3 33
ALL_x y
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
3 33
ASOF2_x y
0 100
1 101
Expand Down
9 changes: 5 additions & 4 deletions mysql-test/suite/versioning/t/select.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ begin
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 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;
Expand Down Expand Up @@ -77,18 +78,18 @@ begin
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('create or replace table t2', @str0);
prepare stmt from @str; execute stmt; drop prepare stmt;

insert into t1 values (1, 1), (1, 2), (1, 3), (4, 4), (5, 5);
insert into t2 values (1, 2), (2, 1), (3, 1);
set @t0= now(6);

select t1.x as IJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x;
select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x;
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
Expand Down
10 changes: 10 additions & 0 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -8712,6 +8712,16 @@ opt_for_system_time_clause:
MYSQL_YYABORT;
Lex->current_select->vers_conditions.init(FOR_SYSTEM_TIME_AS_OF, UNIT_TIMESTAMP, item);
}
| FOR_SYSTEM_TIME_SYM ALL
{
static MYSQL_TIME min= { TIMESTAMP_MIN_YEAR, 1, 1, 0, 0, 0, 0, false, MYSQL_TIMESTAMP_DATETIME };
static MYSQL_TIME max= { TIMESTAMP_MAX_YEAR, 12, 31, 23, 59, 59, 0, false, MYSQL_TIMESTAMP_DATETIME };
Item *t0= new (thd->mem_root) Item_datetime_literal(thd, &min);
Item *t1= new (thd->mem_root) Item_datetime_literal(thd, &max);
if (!t0 || !t1)
MYSQL_YYABORT;
Lex->current_select->vers_conditions.init(FOR_SYSTEM_TIME_BETWEEN, UNIT_TIMESTAMP, t0, t1);
}
| FOR_SYSTEM_TIME_SYM
FROM
trans_or_timestamp
Expand Down

0 comments on commit eff649e

Please sign in to comment.