############## mysql-test\t\identity_basic.test ############### # # # Variable Name: identity # # Scope: SESSION # # Access Type: Dynamic # # Data Type: numeric # # Default Value: - # # Range: - # # # # # # Creation Date: 2008-02-07 # # Author: Salman # # # # Description: Test Cases of Dynamic System Variable identity # # 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 # # # ############################################################################### --source include/load_sysvars.inc ################################################################ # START OF identity TESTS # ################################################################ ################################################################ # Saving initial value of identity in a temporary variable # ################################################################ SET @start_value = @@session.identity; SELECT @start_value; --echo '#--------------------FN_DYNVARS_035_01------------------------#' ######################################################################## # Display the DEFAULT value of identity # ######################################################################## SET @@session.identity = 99; # SET @@session.identity = DEFAULT; --echo 'Variable is giving error on assigning Default value'; SELECT @@session.identity; --echo '#---------------------FN_DYNVARS_035_02-------------------------#' ############################################### # Verify default value of variable # ############################################### SET @@session.identity = @start_value; SELECT @@session.identity = 0; --echo '#--------------------FN_DYNVARS_035_03------------------------#' ######################################################################## # Change the value of identity to a valid value # ######################################################################## SET @@session.identity = 0; SELECT @@session.identity; SET @@session.identity = 1099; SELECT @@session.identity; SET @@session.identity = 1800; SELECT @@session.identity; SET @@session.identity = 65535; SELECT @@session.identity; --echo '#--------------------FN_DYNVARS_035_04-------------------------#' ########################################################################### # Change the value of identity to invalid value # ########################################################################### SET @@session.identity = -1; SELECT @@session.identity; SET @@session.identity = 100000000000; SELECT @@session.identity; --Error ER_WRONG_TYPE_FOR_VAR SET @@session.identity = 10000.01; SELECT @@session.identity; SET @@session.identity = -1024; SELECT @@session.identity; SET @@session.identity = 42949672950; SELECT @@session.identity; --Error ER_WRONG_TYPE_FOR_VAR SET @@session.identity = ON; SELECT @@session.identity; --Error ER_WRONG_TYPE_FOR_VAR SET @@session.identity = 'test'; SELECT @@session.identity; --echo '#-------------------FN_DYNVARS_035_05----------------------------#' ########################################################################### # Test if accessing global identity gives error # ########################################################################### --Error ER_LOCAL_VARIABLE SET @@global.identity = 0; --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@global.identity; --echo '#----------------------FN_DYNVARS_035_06------------------------#' ############################################################################## # Check if the value in GLOBAL & SESSION Tables matches values in variable # ############################################################################## --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@global.identity = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='identity'; SELECT @@session.identity = VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='identity'; --echo '#-------------------FN_DYNVARS_035_07----------------------------#' ###################################################################### # Test if accessing GLOBAL identity gives error # ###################################################################### --Error ER_LOCAL_VARIABLE SET @@global.identity = 0; --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@global.identity; --echo '#---------------------FN_DYNVARS_035_08----------------------#' ################################################################### # Check if TRUE and FALSE values can be used on variable # ################################################################### SET @@session.identity = TRUE; SELECT @@session.identity; SET @@session.identity = FALSE; SELECT @@session.identity; --echo '#---------------------FN_DYNVARS_035_09----------------------#' ######################################################################################################## # Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable # ######################################################################################################## SET @@session.identity = 1; SELECT @@identity = @@session.identity; SELECT @@session.identity = @@local.identity; --echo '#---------------------FN_DYNVARS_035_10----------------------#' ########################################################################## # Check if identity can be accessed with and without @@ sign # ########################################################################## SET identity = 1; SELECT @@identity; --Error ER_PARSE_ERROR SET local.identity = 1; --Error ER_UNKNOWN_TABLE SELECT local.identity; --Error ER_PARSE_ERROR SET session.identity = 1; --Error ER_UNKNOWN_TABLE SELECT session.identity; --Error ER_BAD_FIELD_ERROR SELECT identity = @@session.identity; ############################## # Restore initial value # ############################## SET @@session.identity = @start_value; SELECT @@session.identity; ######################################################################## # END OF identity TESTS # ########################################################################