--source include/have_innodb.inc

SET @start_global_value = @@global.innodb_simulate_comp_failures;
SELECT @start_global_value;

#
# exists as global only
#

--echo Valid values are between 0 and 99
select @@global.innodb_simulate_comp_failures between 0 and 99;
select @@global.innodb_simulate_comp_failures;

--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.innodb_simulate_comp_failures;

show global variables like 'innodb_simulate_comp_failures';
show session variables like 'innodb_simulate_comp_failures';
select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
select * from information_schema.session_variables where variable_name='innodb_simulate_comp_failures';

#
# show that it's writable
#

set global innodb_simulate_comp_failures=10;
select @@global.innodb_simulate_comp_failures;
select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
select * from information_schema.session_variables where variable_name='innodb_simulate_comp_failures';

--error ER_GLOBAL_VARIABLE
set session innodb_simulate_comp_failures=1;

#
# incorrect types
#

--error ER_WRONG_TYPE_FOR_VAR
set global innodb_simulate_comp_failures=1.1;
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_simulate_comp_failures=1e1;
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_simulate_comp_failures="foo";

set global innodb_simulate_comp_failures=-7;
select @@global.innodb_simulate_comp_failures;
select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
set global innodb_simulate_comp_failures=106;
select @@global.innodb_simulate_comp_failures;
select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';

#
# min/max/DEFAULT values
#

set global innodb_simulate_comp_failures=0;
select @@global.innodb_simulate_comp_failures;
set global innodb_simulate_comp_failures=99;
select @@global.innodb_simulate_comp_failures;
set global innodb_simulate_comp_failures=DEFAULT;
select @@global.innodb_simulate_comp_failures;

SET @@global.innodb_simulate_comp_failures = @start_global_value;
SELECT @@global.innodb_simulate_comp_failures;
