

############### mysql-test\t\innodb_undo_log_truncate_basic.test ##############
#                                                                             #
# Variable Name: innodb_undo_log_truncate                                     #
# Scope: Global                                                               #
# Access Type: Dynamic                                                        #
# Data Type: boolean                                                          #
#                                                                             #
#                                                                             #
# Creation Date: 2008-02-07                                                   #
# Author : Sharique Abdullah                                                  #
#                                                                             #
#                                                                             #
# Description:Test Cases of Dynamic System Variable innodb_undo_log_truncate  #
#             that checks the behavior of this variable in the following ways #
#              * Value Check                                                  #
#              * Scope Check                                                  #
#                                                                             #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
#  server-system-variables.html                                               #
#                                                                             #
###############################################################################

--source include/have_innodb.inc

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


--echo '#---------------------BS_STVARS_028_01----------------------#'
####################################################################
#   Displaying default value                                       #
####################################################################
SELECT COUNT(@@GLOBAL.innodb_undo_log_truncate);
--echo 1 Expected


--echo '#---------------------BS_STVARS_028_02----------------------#'
####################################################################
#   Check if Value can set                                         #
####################################################################

SET @@global.innodb_undo_log_truncate = 0;
SELECT @@global.innodb_undo_log_truncate;

SET @@global.innodb_undo_log_truncate ='On' ;
SELECT @@global.innodb_undo_log_truncate;

SET @@global.innodb_undo_log_truncate ='Off' ;
SELECT @@global.innodb_undo_log_truncate;

SET @@global.innodb_undo_log_truncate = 1;
SELECT @@global.innodb_undo_log_truncate;

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

--disable_warnings
SELECT IF(@@GLOBAL.innodb_undo_log_truncate,'ON','OFF') = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_undo_log_truncate';
--echo 1 Expected

SELECT COUNT(@@GLOBAL.innodb_undo_log_truncate);
--echo 1 Expected

SELECT COUNT(VARIABLE_VALUE)
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_undo_log_truncate';
--echo 1 Expected
--enable_warnings


--echo '#---------------------BS_STVARS_028_04----------------------#'
################################################################################
#  Check if accessing variable with and without GLOBAL point to same variable  #
################################################################################
SELECT @@innodb_undo_log_truncate = @@GLOBAL.innodb_undo_log_truncate;
--echo 1 Expected



--echo '#---------------------BS_STVARS_028_05----------------------#'
################################################################################
#   Check if innodb_undo_log_truncate can be accessed with and without @@ sign     #
################################################################################

SELECT COUNT(@@innodb_undo_log_truncate);
--echo 1 Expected

--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT COUNT(@@local.innodb_undo_log_truncate);
--echo Expected error 'Variable is a GLOBAL variable'

--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT COUNT(@@SESSION.innodb_undo_log_truncate);
--echo Expected error 'Variable is a GLOBAL variable'

SELECT COUNT(@@GLOBAL.innodb_undo_log_truncate);
--echo 1 Expected

--Error ER_BAD_FIELD_ERROR
SELECT innodb_undo_log_truncate = @@SESSION.innodb_undo_log_truncate;

#
# Cleanup
#

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