mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
SQL, Parser: system_time logic and syntax fixes [closes #237]
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
|
@@ -192,16 +192,6 @@ create or replace table t1 (
|
||||
A8 int without system versioning
|
||||
) with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A9 int without system versioning with system versioning
|
||||
);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A10 int with system versioning without system versioning
|
||||
);
|
||||
|
||||
# table with/without system versioning
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
@@ -209,26 +199,6 @@ create table t(
|
||||
a11 int
|
||||
) without system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A12 int
|
||||
) without system versioning with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A13 int
|
||||
) with system versioning without system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A14 int
|
||||
) with system versioning with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A15 int
|
||||
) without system versioning without system versioning;
|
||||
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create temporary table tmp with system versioning select * from t1;
|
||||
|
||||
|
@@ -42,28 +42,22 @@ if ($default_engine == 'innodb')
|
||||
|
||||
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;
|
||||
|
||||
--disable_query_log
|
||||
if ($default_engine == 'innodb')
|
||||
{
|
||||
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;
|
||||
}
|
||||
if ($default_engine != 'innodb')
|
||||
{
|
||||
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;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
|
@@ -45,24 +45,18 @@ begin
|
||||
|
||||
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;
|
||||
|
@@ -84,9 +84,9 @@ select * from t for system_time as of timestamp current_timestamp(6);
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/
|
||||
select * from t for system_time all;
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/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);
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/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);
|
||||
|
||||
set versioning_hide= NEVER;
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/
|
||||
|
@@ -1,13 +1,13 @@
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
create table t (a int);
|
||||
--error ER_VERS_UNUSED_CLAUSE
|
||||
--error ER_VERSIONING_REQUIRED
|
||||
truncate t for system_time all;
|
||||
|
||||
delimiter ~~;
|
||||
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~~
|
||||
@@ -34,11 +34,11 @@ update t set a=4;
|
||||
truncate t for system_time as of timestamp now(6);
|
||||
select * from t for system_time all;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
update t set a=6;
|
||||
@@ -49,10 +49,10 @@ 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;
|
||||
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;
|
||||
|
||||
|
||||
@@ -69,11 +69,11 @@ update t set a=4;
|
||||
truncate t for system_time as of timestamp now(6);
|
||||
select * from t for system_time all;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
update t set a=6;
|
||||
@@ -84,10 +84,10 @@ 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;
|
||||
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;
|
||||
|
||||
create or replace table t (a int) with system versioning;
|
||||
|
Reference in New Issue
Block a user