Commit b633b6a9 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-22906 Disallow system_versioning_asof in DML

system_versioning_asof does not influence on multi-delete,
multi-update, insert-select, replace-select.
parent 9f37323f
......@@ -146,3 +146,32 @@ show status like "Feature_system_versioning";
Variable_name Value
Feature_system_versioning 2
drop table t;
#
# MDEV-22906 Disallow system_versioning_asof in DML
#
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);
x
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);
x
2
replace t2 select x + 1 from t1;
select * from t2;
y
2
3
insert t2 select x + 2 from t1;
select * from t2;
y
2
3
4
drop tables t1, t2;
......@@ -103,3 +103,27 @@ select * from t for system_time between '1970-01-01 00:00' and current_timestamp
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;
......@@ -778,9 +778,12 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
}
bool is_select= false;
bool use_sysvar= false;
switch (thd->lex->sql_command)
{
case SQLCOM_SELECT:
use_sysvar= true;
/* fall through */
case SQLCOM_INSERT_SELECT:
case SQLCOM_REPLACE_SELECT:
case SQLCOM_DELETE_MULTI:
......@@ -824,7 +827,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
}
// propagate system_time from sysvar
if (!vers_conditions.is_set() && is_select)
if (!vers_conditions.is_set() && use_sysvar)
{
if (vers_conditions.init_from_sysvar(thd))
DBUG_RETURN(-1);
......
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