Skip to content

Commit

Permalink
MDEV-14765 Server crashes in Sys_var_vers_asof::update
Browse files Browse the repository at this point in the history
  • Loading branch information
midenok committed Dec 26, 2017
1 parent 11c6882 commit 04451f0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
19 changes: 19 additions & 0 deletions mysql-test/suite/versioning/r/sysvars.result
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set system_versioning_asof= 1;
ERROR 42000: Incorrect argument type to variable 'system_versioning_asof'
set system_versioning_asof= 1.1;
ERROR 42000: Incorrect argument type to variable 'system_versioning_asof'
# GLOBAL @@system_versioning_asof
set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
Warnings:
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
Expand All @@ -61,6 +62,11 @@ set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';
Variable_name Value
system_versioning_asof 1900-01-01 00:00:00.000000
set global system_versioning_asof= default;
select @@global.system_versioning_asof;
@@global.system_versioning_asof
DEFAULT
# SESSION @@system_versioning_asof
set system_versioning_asof= '1911-11-11 11:11:11.1111119';
Warnings:
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
Expand All @@ -83,8 +89,21 @@ set system_versioning_asof= @ts;
show variables like 'system_versioning_asof';
Variable_name Value
system_versioning_asof 1900-01-01 00:00:00.000000
# 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;
different
1
set system_versioning_asof= default;
select @@global.system_versioning_asof = @@system_versioning_asof as equal;
equal
1
set global system_versioning_asof= DEFAULT;
set system_versioning_asof= DEFAULT;
select @@global.system_versioning_asof, @@system_versioning_asof;
@@global.system_versioning_asof @@system_versioning_asof
DEFAULT DEFAULT
show variables where variable_name = "system_versioning_hide";
Variable_name Value
system_versioning_hide IMPLICIT
Expand Down
15 changes: 13 additions & 2 deletions mysql-test/suite/versioning/t/sysvars.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set system_versioning_asof= 1;
--error ER_WRONG_TYPE_FOR_VAR
set system_versioning_asof= 1.1;

# global
--echo # GLOBAL @@system_versioning_asof
set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
show global variables like 'system_versioning_asof';

Expand All @@ -48,7 +48,10 @@ set @ts= timestamp'1900-01-01 00:00:00';
set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';

# session
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';

Expand All @@ -62,8 +65,16 @@ 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;

show variables where variable_name = "system_versioning_hide";
select * from t for system_time all;
Expand Down
10 changes: 9 additions & 1 deletion sql/sys_vars.ic
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,15 @@ private:
out.type= static_cast<enum_var_type>(var->save_result.ulonglong_value);
if (out.type == SYSTEM_TIME_AS_OF)
{
res= var->value->get_date(&out.ltime, 0);
if (var->value)
{
res= var->value->get_date(&out.ltime, 0);
}
else // set DEFAULT from global var
{
out= global_var(vers_asof_timestamp_t);
res= false;
}
}
return res;
}
Expand Down

0 comments on commit 04451f0

Please sign in to comment.