mariadb/mysql-test/suite/versioning/t/sysvars.test
Aleksey Midenkov b633b6a9d8 MDEV-22906 Disallow system_versioning_asof in DML
system_versioning_asof does not influence on multi-delete,
multi-update, insert-select, replace-select.
2020-06-16 10:43:53 +03:00

129 lines
4.2 KiB
Text

create table t (a int) with system versioning;
insert into t values (1);
update t set a= 2;
show global variables like 'system_versioning_asof';
show variables like 'system_versioning_asof';
select * from t;
set system_versioning_asof= '2031-1-1 0:0:0';
show variables like 'system_versioning_asof';
select * from t;
set system_versioning_asof= '2011-1-1 0:0:0';
show variables like 'system_versioning_asof';
select * from t;
# global
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= 'alley';
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= null;
--error ER_WRONG_TYPE_FOR_VAR
set global system_versioning_asof= 1;
--error ER_WRONG_TYPE_FOR_VAR
set global system_versioning_asof= 1.1;
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= '2011-02-29 00:00';
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= '2011-02-28 24:00';
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= '2011-00-28 00:00';
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= '0000-00-00 00:00';
# session
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= 'alley';
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= null;
--error ER_WRONG_TYPE_FOR_VAR
set system_versioning_asof= 1;
--error ER_WRONG_TYPE_FOR_VAR
set system_versioning_asof= 1.1;
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= '2011-02-29 00:00';
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= '2011-02-28 24:00';
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= '2011-00-28 00:00';
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= '0000-00-00 00:00';
--echo # GLOBAL @@system_versioning_asof
set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
show global variables like 'system_versioning_asof';
set global system_versioning_asof= '1900-01-01 00:00:00';
show global variables like 'system_versioning_asof';
set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
show global variables like 'system_versioning_asof';
set @ts= timestamp'1900-01-01 00:00:00';
set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';
set global system_versioning_asof= default;
select @@global.system_versioning_asof;
--echo # SESSION @@system_versioning_asof
set system_versioning_asof= '1911-11-11 11:11:11.1111119';
show variables like 'system_versioning_asof';
set system_versioning_asof= '1900-01-01 00:00:00';
show variables like 'system_versioning_asof';
set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
show variables like 'system_versioning_asof';
set @ts= timestamp'1900-01-01 00:00:00';
set system_versioning_asof= @ts;
show variables like 'system_versioning_asof';
--echo # DEFAULT: value is copied from GLOBAL to SESSION
set global system_versioning_asof= timestamp'1911-11-11 11:11:11.111111';
set system_versioning_asof= '1900-01-01 00:00:00';
select @@global.system_versioning_asof != @@system_versioning_asof as different;
set system_versioning_asof= default;
select @@global.system_versioning_asof = @@system_versioning_asof as equal;
set global system_versioning_asof= DEFAULT;
set system_versioning_asof= DEFAULT;
select @@global.system_versioning_asof, @@system_versioning_asof;
select * from t for system_time all;
select * from t;
select * from t for system_time as of timestamp current_timestamp(6);
select * from t for system_time all;
select * from t for system_time from '1970-01-01 00:00' to current_timestamp(6);
select * from t for system_time between '1970-01-01 00:00' and current_timestamp(6);
show status like "Feature_system_versioning";
drop table t;
--echo #
--echo # MDEV-22906 Disallow system_versioning_asof in DML
--echo #
create or replace table t1 (x int) with system versioning;
create or replace table t2 (y int);
insert into t1 values (1);
insert into t2 values (1);
set system_versioning_asof= '1970-01-01 00:00:00';
delete t1, t2 from t1 join t2 where t1.x = t2.y;
select * from t1 for system_time as of timestamp now(6);
insert into t1 values (1);
insert into t2 values (1);
update t1, t2 set x= 2, y= 2 where x = y;
select * from t1 for system_time as of timestamp now(6);
replace t2 select x + 1 from t1;
select * from t2;
insert t2 select x + 2 from t1;
select * from t2;
drop tables t1, t2;