Commit ecd18bc0 authored by kevg's avatar kevg Committed by Aleksey Midenkov

SQL: allow FOR SYSTEM_TIME BEFORE for SELECT queries [closes #170]

parent 4af3cb82
......@@ -122,6 +122,9 @@ a
22
1
2
select * from t for system_time before timestamp @ts1;
a
1
truncate t for system_time before timestamp @ts1;
select * from t for system_time all;
a
......@@ -144,6 +147,12 @@ a
22
1
2
select * from t for system_time before timestamp @ts1;
a
select * from t for system_time before transaction 2000;
a
1
2
truncate t for system_time before timestamp @ts1;
select * from t for system_time all;
a
......@@ -157,7 +166,5 @@ a
11
22
2
select * from t for system_time before timestamp now();
ERROR HY000: `FOR SYSTEM_TIME BEFORE` works only with `TRUNCATE` query type
drop table t;
drop procedure truncate_history_of_t;
......@@ -96,6 +96,7 @@ update t set a=11 where a=1;
set @ts1=now(6);
update t set a=22 where a=2;
select * from t for system_time all;
select * from t for system_time before timestamp @ts1;
truncate t for system_time before timestamp @ts1;
select * from t for system_time all;
truncate t for system_time before timestamp now(6);
......@@ -107,13 +108,12 @@ update t set a=11 where a=1;
set @ts1=now(6);
update t set a=22 where a=2;
select * from t for system_time all;
select * from t for system_time before timestamp @ts1;
select * from t for system_time before transaction 2000;
truncate t for system_time before timestamp @ts1;
select * from t for system_time all;
truncate t for system_time before timestamp now(6);
select * from t for system_time all;
--error ER_VERS_WRONG_QUERY_TYPE
select * from t for system_time before timestamp now();
drop table t;
drop procedure truncate_history_of_t;
......@@ -786,14 +786,6 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
table->vers_conditions.type == FOR_SYSTEM_TIME_UNSPECIFIED ?
slex->vers_conditions : table->vers_conditions;
if (vers_conditions.type == FOR_SYSTEM_TIME_BEFORE &&
thd->lex->sql_command != SQLCOM_TRUNCATE)
{
my_error(ER_VERS_WRONG_QUERY_TYPE, MYF(0), "FOR SYSTEM_TIME BEFORE",
"TRUNCATE");
DBUG_RETURN(-1);
}
if (vers_conditions.type == FOR_SYSTEM_TIME_UNSPECIFIED)
{
if (vers_conditions.init_from_sysvar(thd))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment