############################################################################### # # # Variable name: password_history # # Scope : GLOBAL # # Access Type : Dynamic # # Data type : Integer # # Default value: 0 # # Minimum Value: 0 # # Maximum value: 4294967295 # # # # # # Creation Date: 29-Nov-2017 # # Author : Mohit Joshi # # # # Description : Test case added for dynamic server variable password_history # # We check the behaviour of this variable for: # # * Default values # # * Valid and invalid values # # * Scope and access method # # # # References: Reference: http://dev.mysql.com/doc/refman/8.0/en/ # # server-system-variables.html # # # ############################################################################### ################################################################ # Saving initial values of password_history variable in # # a temporary variable # ################################################################ SET @password_history_save = @@global.password_history; SELECT @password_history_save; ################################################################ # Display the DEFAULT value of password_history # ################################################################ --echo Default value must be 0 for global scope SET @@global.password_history = 1; SET @@global.password_history = DEFAULT; SELECT @@global.password_history; --error ER_GLOBAL_VARIABLE SET @@session.password_history = 2; --error ER_GLOBAL_VARIABLE SET @@session.password_history = DEFAULT; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.password_history; ################################################################ # Check if NULL or empty value is accepted # ################################################################ --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = NULL; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = ''; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = ' '; --error ER_GLOBAL_VARIABLE SET @@session.password_history = NULL; --error ER_GLOBAL_VARIABLE SET @@session.password_history = ''; --error ER_GLOBAL_VARIABLE SET @@session.password_history = ' '; ############################################################################## # Change the value of password_history to a valid value for GLOBAL scope # ############################################################################## SET @@global.password_history = 0; SELECT @@global.password_history; SET @@global.password_history = 1; SELECT @@global.password_history; SET @@global.password_history = TRUE; SELECT @@global.password_history; SET @@global.password_history = FALSE; SELECT @@global.password_history; SET @@global.password_history = 4294967295; SELECT @@global.password_history; SET @@global.password_history = DEFAULT; SELECT @@global.password_history; ############################################################################# # Change the value of password_history to an invalid value for GLOBAL scope # ############################################################################# SET @@global.password_history = -1; SELECT @@global.password_history; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = 'ABC'; SELECT @@global.password_history; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = ON; SELECT @@global.password_history; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = 'OFF'; SELECT @@global.password_history; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = 2.14; SELECT @@global.password_history; --error ER_WRONG_TYPE_FOR_VAR SET @@global.password_history = NONE; SELECT @@global.password_history; SET @@global.password_history = -4294967295; SELECT @@global.password_history; SET @@global.password_history = 4294967296; SELECT @@global.password_history; ############################################################################# # Check if the value in GLOBAL Table matches value in variable # ############################################################################# --echo Must return 1 --disable_warnings SELECT @@global.password_history = VARIABLE_VALUE FROM performance_schema.global_variables WHERE VARIABLE_NAME='password_history'; --enable_warnings ############################################################################### # Check if password_history variable can be accessed with and without @@ sign # ############################################################################### SET GLOBAL password_history = 1; SET @@global.password_history = 1; --error ER_PARSE_ERROR SET global.password_history = 1; --error ER_GLOBAL_VARIABLE SET @@password_history = 1; --error ER_GLOBAL_VARIABLE SET password_history = 1; --error ER_UNKNOWN_TABLE SELECT global.password_history; --error ER_BAD_FIELD_ERROR SELECT GLOBAL password_history; SELECT @@password_history; ############################################################################# # Restoring the original value of password_history variable # ############################################################################# SET @@global.password_history = @password_history_save;