--source include/have_falcon.inc

#
# We exclude falcon_debug_mask as workaround for
# Bug#41368 --replace_regex does not work as expected.
#
SHOW VARIABLES
  WHERE variable_name LIKE 'falcon_%'
    AND variable_name <> 'falcon_serial_log_dir'
    AND variable_name <> 'falcon_debug_mask';

--let $debug = `SELECT @@GLOBAL.falcon_debug_mask;`
--replace_result $debug 0
SHOW VARIABLES WHERE variable_name LIKE 'falcon_debug_mask';

# Test that these server variables are READ ONLY.

SELECT @@GLOBAL.falcon_debug_server;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_debug_server = TRUE;

--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_serial_log_dir = '/foo';

SELECT @@GLOBAL.falcon_page_cache_size;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_page_cache_size = 8M;

SELECT @@GLOBAL.falcon_page_size;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_page_size = 1K;

SELECT @@GLOBAL.falcon_serial_log_buffers;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_serial_log_buffers = 100;

# These variables are r/w.
SELECT @@GLOBAL.falcon_debug_mask INTO @previous_falcon_debug_mask;
--replace_result $debug 0
SELECT @@GLOBAL.falcon_debug_mask;
SET GLOBAL falcon_debug_mask = 4096;
SELECT @@GLOBAL.falcon_debug_mask;

SELECT @@GLOBAL.falcon_record_memory_max INTO @previous_falcon_record_memory_max;
SELECT @@GLOBAL.falcon_record_memory_max;
SET GLOBAL falcon_record_memory_max = 536870912;
SELECT @@GLOBAL.falcon_record_memory_max;

SELECT @@GLOBAL.falcon_index_chill_threshold INTO @previous_falcon_index_chill_threshold;
SET GLOBAL falcon_index_chill_threshold = 1073741824;
SELECT @@GLOBAL.falcon_index_chill_threshold;

SELECT @@GLOBAL.falcon_record_chill_threshold INTO @previous_falcon_record_chill_threshold;
SET GLOBAL falcon_record_chill_threshold = 1073741824;
SELECT @@GLOBAL.falcon_record_chill_threshold;


# Test INFORMATION_SCHEMA access to variables.
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.global_variables
  WHERE variable_name LIKE 'falcon%' and variable_name <> 'falcon_serial_log_dir';

# Final cleanup.
SET GLOBAL falcon_debug_mask = @previous_falcon_debug_mask;
SET GLOBAL falcon_record_memory_max =  @previous_falcon_record_memory_max;
SET GLOBAL falcon_index_chill_threshold = @previous_falcon_index_chill_threshold;
SET GLOBAL falcon_record_chill_threshold = @previous_falcon_record_chill_threshold;
