mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
SQL: allow FOR SYSTEM_TIME BEFORE for SELECT queries [closes #170]
This commit is contained in:
@@ -122,6 +122,9 @@ a
|
|||||||
22
|
22
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
|
select * from t for system_time before timestamp @ts1;
|
||||||
|
a
|
||||||
|
1
|
||||||
truncate t for system_time before timestamp @ts1;
|
truncate t for system_time before timestamp @ts1;
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
a
|
a
|
||||||
@@ -144,6 +147,12 @@ a
|
|||||||
22
|
22
|
||||||
1
|
1
|
||||||
2
|
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;
|
truncate t for system_time before timestamp @ts1;
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
a
|
a
|
||||||
@@ -157,7 +166,5 @@ a
|
|||||||
11
|
11
|
||||||
22
|
22
|
||||||
2
|
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 table t;
|
||||||
drop procedure truncate_history_of_t;
|
drop procedure truncate_history_of_t;
|
||||||
|
@@ -96,6 +96,7 @@ update t set a=11 where a=1;
|
|||||||
set @ts1=now(6);
|
set @ts1=now(6);
|
||||||
update t set a=22 where a=2;
|
update t set a=22 where a=2;
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
|
select * from t for system_time before timestamp @ts1;
|
||||||
truncate t for system_time before timestamp @ts1;
|
truncate t for system_time before timestamp @ts1;
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
truncate t for system_time before timestamp now(6);
|
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);
|
set @ts1=now(6);
|
||||||
update t set a=22 where a=2;
|
update t set a=22 where a=2;
|
||||||
select * from t for system_time all;
|
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;
|
truncate t for system_time before timestamp @ts1;
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
truncate t for system_time before timestamp now(6);
|
truncate t for system_time before timestamp now(6);
|
||||||
select * from t for system_time all;
|
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 table t;
|
||||||
drop procedure truncate_history_of_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 ?
|
table->vers_conditions.type == FOR_SYSTEM_TIME_UNSPECIFIED ?
|
||||||
slex->vers_conditions : table->vers_conditions;
|
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.type == FOR_SYSTEM_TIME_UNSPECIFIED)
|
||||||
{
|
{
|
||||||
if (vers_conditions.init_from_sysvar(thd))
|
if (vers_conditions.init_from_sysvar(thd))
|
||||||
|
Reference in New Issue
Block a user