############## mysql-test\t\keep_files_on_create_basic.test ###################
#                                                                             #
# Variable Name: keep_files_on_create                                         #
# Scope: GLOBAL & SESSION                                                     #
# Access Type: Dynamic                                                        #
# Data Type: boolean                                                          #
# Default Value: OFF                                                          #
# Range:                                                                      #
#                                                                             #
#                                                                             #
# Creation Date: 2008-02-11                                                   #
# Author:  Salman                                                             #
#                                                                             #
# Description: Test Cases of Dynamic System Variable keep_files_on_create     #
#              that checks the behavior of this variable in the following ways#
#              * Default Value                                                #
#              * Valid & Invalid values                                       #
#              * Scope & Access method                                        #
#              * Data Integrity                                               #
#                                                                             #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
#  server-system-variables.html#option_mysqld_keep_files_on_create            #
#                                                                             #
###############################################################################

--source include/load_sysvars.inc

####################################################################
#           START OF keep_files_on_create TESTS                    #
####################################################################


#############################################################
#                 Save initial value                        #
#############################################################

SET @start_global_value = @@global.keep_files_on_create;
SELECT @start_global_value;
SET @start_session_value = @@session.keep_files_on_create;
SELECT @start_session_value;


--echo '#--------------------FN_DYNVARS_054_01-------------------------#'
########################################################################
#     Display the DEFAULT value of keep_files_on_create                #
########################################################################

SET @@global.keep_files_on_create = ON;
SET @@global.keep_files_on_create = DEFAULT;
SELECT @@global.keep_files_on_create;

SET @@session.keep_files_on_create = ON;
SET @@session.keep_files_on_create = DEFAULT;
SELECT @@session.keep_files_on_create;


--echo '#--------------------FN_DYNVARS_054_02-------------------------#'
########################################################################
#     Check the DEFAULT value of keep_files_on_create                  #
########################################################################

SET @@global.keep_files_on_create = DEFAULT;
SELECT @@global.keep_files_on_create = 'OFF';

SET @@session.keep_files_on_create = DEFAULT;
SELECT @@session.keep_files_on_create = 'OFF';


--echo '#--------------------FN_DYNVARS_054_03-------------------------#'
##############################################################################
# Change the value of keep_files_on_create to a valid value for GLOBAL Scope #
##############################################################################

SET @@global.keep_files_on_create = ON;
SELECT @@global.keep_files_on_create;
SET @@global.keep_files_on_create = OFF;
SELECT @@global.keep_files_on_create;
SET @@global.keep_files_on_create = 0;
SELECT @@global.keep_files_on_create;
SET @@global.keep_files_on_create = 1;
SELECT @@global.keep_files_on_create;
SET @@global.keep_files_on_create = TRUE;
SELECT @@global.keep_files_on_create;
SET @@global.keep_files_on_create = FALSE;
SELECT @@global.keep_files_on_create;



--echo '#--------------------FN_DYNVARS_054_04-------------------------#'
###############################################################################
# Change the value of keep_files_on_create to a valid value for SESSION Scope #
###############################################################################
 
SET @@session.keep_files_on_create = ON;
SELECT @@session.keep_files_on_create;
SET @@session.keep_files_on_create = OFF;
SELECT @@session.keep_files_on_create;
SET @@session.keep_files_on_create = 0;
SELECT @@session.keep_files_on_create;
SET @@session.keep_files_on_create = 1;
SELECT @@session.keep_files_on_create;
SET @@session.keep_files_on_create = TRUE;
SELECT @@session.keep_files_on_create;
SET @@session.keep_files_on_create = FALSE;
SELECT @@session.keep_files_on_create;


--echo '#------------------FN_DYNVARS_054_05-----------------------#'
################################################################
# Change the value of keep_files_on_create to an invalid value #
################################################################

--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = 'ONN';
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = "OFFF";
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = TTRUE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = FELSE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = -1024;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = 65536;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.keep_files_on_create = 65530.34;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.keep_files_on_create = test;

--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = ONF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = OF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = 'OFN';
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = -2;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.keep_files_on_create = 65530.34;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = 65550;

--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = test;
SELECT @@session.keep_files_on_create;


--echo '#------------------FN_DYNVARS_054_06-----------------------#'
####################################################################
#   Check if the value in GLOBAL Table matches value in variable   #
####################################################################


SELECT IF(@@global.keep_files_on_create, "ON", "OFF") = VARIABLE_VALUE 
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='keep_files_on_create';

--echo '#------------------FN_DYNVARS_054_07-----------------------#'
####################################################################
#  Check if the value in SESSION Table matches value in variable   #
####################################################################

SELECT IF(@@session.keep_files_on_create, "ON", "OFF") = VARIABLE_VALUE 
FROM INFORMATION_SCHEMA.SESSION_VARIABLES 
WHERE VARIABLE_NAME='keep_files_on_create';


--echo '#---------------------FN_DYNVARS_001_08----------------------#'
###############################################################################
#  Check if accessing variable with and without GLOBAL point to same variable #
###############################################################################

SET @@keep_files_on_create = OFF;
SET @@global.keep_files_on_create = ON;
SELECT @@keep_files_on_create = @@global.keep_files_on_create;


--echo '#---------------------FN_DYNVARS_001_09----------------------#'
##############################################################################
#    Check if accessing variable with SESSION,LOCAL and without SCOPE points #
#    to same session variable                                                #
##############################################################################

SET @@keep_files_on_create = ON;
SELECT @@keep_files_on_create = @@local.keep_files_on_create;
SELECT @@local.keep_files_on_create = @@session.keep_files_on_create;


--echo '#---------------------FN_DYNVARS_001_10----------------------#'
###############################################################################
#   Check if keep_files_on_create can be accessed with and without @@ sign    #
###############################################################################

SET keep_files_on_create = 1;
SELECT @@keep_files_on_create;
--Error ER_UNKNOWN_TABLE
SELECT local.keep_files_on_create;
--Error ER_UNKNOWN_TABLE
SELECT session.keep_files_on_create;
--Error ER_BAD_FIELD_ERROR
SELECT keep_files_on_create = @@session.keep_files_on_create;


####################################
#     Restore initial value        #
####################################

SET @@global.keep_files_on_create = @start_global_value;
SELECT @@global.keep_files_on_create;
SET @@session.keep_files_on_create = @start_session_value;
SELECT @@session.keep_files_on_create;


#########################################################
#                 END OF keep_files_on_create TESTS     #
#########################################################

