--source include/have_optimizer_trace.inc

# Basic read/write test.
# Functionality of this variable is covered in
# main.optimizer_trace*.test

SELECT @@global.optimizer_trace_max_mem_size;
SET @@global.optimizer_trace_max_mem_size=5;
show global variables like 'optimizer_trace_max_mem_size';
select * from information_schema.global_variables where variable_name='optimizer_trace_max_mem_size';

select @@session.optimizer_trace_max_mem_size;
show session variables like 'optimizer_trace_max_mem_size';
select * from information_schema.session_variables where variable_name='optimizer_trace_max_mem_size';

#
# show that it's writable
#
set session optimizer_trace_max_mem_size=10;
select @@session.optimizer_trace_max_mem_size;
show session variables like 'optimizer_trace_max_mem_size';

set session optimizer_trace_max_mem_size=0;
select @@session.optimizer_trace_max_mem_size;
show session variables like 'optimizer_trace_max_mem_size';

set session optimizer_trace_max_mem_size=-100;
select @@session.optimizer_trace_max_mem_size;
show session variables like 'optimizer_trace_max_mem_size';

# 32-bit big values should be accepted on all platforms
set session optimizer_trace_max_mem_size=2000000000;
select @@session.optimizer_trace_max_mem_size;
show session variables like 'optimizer_trace_max_mem_size';

set session optimizer_trace_max_mem_size=default;
select @@session.optimizer_trace_max_mem_size;
show session variables like 'optimizer_trace_max_mem_size';

set global optimizer_trace_max_mem_size=default;
select @@global.optimizer_trace_max_mem_size;
show global variables like 'optimizer_trace_max_mem_size';

#
# incorrect assignments
#
--error ER_WRONG_TYPE_FOR_VAR
set optimizer_trace_max_mem_size=1.1;
--error ER_WRONG_TYPE_FOR_VAR
set optimizer_trace_max_mem_size="foobar";
