| 1 |
##################### mysql-test\t\slow_query_log_basic.test ################### |
| 2 |
# # |
| 3 |
# Variable Name: slow_query_log # |
| 4 |
# Scope: GLOBAL # |
| 5 |
# Access Type: Dynamic # |
| 6 |
# Data Type: BOOLEAN # |
| 7 |
# Default Value: OFF # |
| 8 |
# Valid Values: ON, OFF # |
| 9 |
# # |
| 10 |
# # |
| 11 |
# Creation Date: 2008-03-16 # |
| 12 |
# Author: Salman Rawala # |
| 13 |
# # |
| 14 |
# Description: Test Cases of Dynamic System Variable "slow_query_log" # |
| 15 |
# that checks behavior of this variable in the following ways # |
| 16 |
# * Default Value # |
| 17 |
# * Valid & Invalid values # |
| 18 |
# * Scope & Access method # |
| 19 |
# * Data Integrity # |
| 20 |
# # |
| 21 |
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # |
| 22 |
# server-options.html#option_mysqld_event-scheduler # |
| 23 |
# # |
| 24 |
################################################################################ |
| 25 |
|
| 26 |
--source include/load_sysvars.inc |
| 27 |
|
| 28 |
########################################################### |
| 29 |
# START OF slow_query_log TESTS # |
| 30 |
########################################################### |
| 31 |
|
| 32 |
|
| 33 |
###################################################################### |
| 34 |
# Saving initial value of slow_query_log in a temporary variable # |
| 35 |
###################################################################### |
| 36 |
|
| 37 |
SET @start_value = @@global.slow_query_log; |
| 38 |
SELECT @start_value; |
| 39 |
|
| 40 |
|
| 41 |
--echo '#---------------------FN_DYNVARS_004_01-------------------------#' |
| 42 |
############################################### |
| 43 |
# Verify default value of variable # |
| 44 |
############################################### |
| 45 |
|
| 46 |
SET @@global.slow_query_log = DEFAULT; |
| 47 |
SELECT @@global.slow_query_log = 0; |
| 48 |
|
| 49 |
|
| 50 |
--echo '#--------------------FN_DYNVARS_004_02------------------------#' |
| 51 |
###################################################################### |
| 52 |
# Change the value of slow_query_log to a valid value # |
| 53 |
###################################################################### |
| 54 |
|
| 55 |
SET @@global.slow_query_log = ON; |
| 56 |
SELECT @@global.slow_query_log; |
| 57 |
SET @@global.slow_query_log = OFF; |
| 58 |
SELECT @@global.slow_query_log; |
| 59 |
|
| 60 |
--echo '#--------------------FN_DYNVARS_004_03-------------------------#' |
| 61 |
###################################################################### |
| 62 |
# Change the value of slow_query_log to invalid value # |
| 63 |
###################################################################### |
| 64 |
|
| 65 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 66 |
SET @@global.slow_query_log = 2; |
| 67 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 68 |
SET @@global.slow_query_log = -1; |
| 69 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 70 |
SET @@global.slow_query_log = TRUEF; |
| 71 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 72 |
SET @@global.slow_query_log = TRUE_F; |
| 73 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 74 |
SET @@global.slow_query_log = FALSE0; |
| 75 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 76 |
SET @@global.slow_query_log = OON; |
| 77 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 78 |
SET @@global.slow_query_log = ONN; |
| 79 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 80 |
SET @@global.slow_query_log = OOFF; |
| 81 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 82 |
SET @@global.slow_query_log = 0FF; |
| 83 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 84 |
SET @@global.slow_query_log = ' '; |
| 85 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 86 |
SET @@global.slow_query_log = " "; |
| 87 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 88 |
SET @@global.slow_query_log = ''; |
| 89 |
|
| 90 |
|
| 91 |
--echo '#-------------------FN_DYNVARS_004_04----------------------------#' |
| 92 |
################################################################## |
| 93 |
# Test if accessing session slow_query_log gives error # |
| 94 |
################################################################## |
| 95 |
|
| 96 |
--Error ER_GLOBAL_VARIABLE |
| 97 |
SET @@session.slow_query_log = OFF; |
| 98 |
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 99 |
SELECT @@session.slow_query_log; |
| 100 |
|
| 101 |
|
| 102 |
--echo '#----------------------FN_DYNVARS_004_05------------------------#' |
| 103 |
############################################################################## |
| 104 |
# Check if the value in GLOBAL Tables matches values in variable # |
| 105 |
############################################################################## |
| 106 |
|
| 107 |
--disable_warnings |
| 108 |
SELECT IF(@@global.slow_query_log, "ON", "OFF") = VARIABLE_VALUE |
| 109 |
FROM performance_schema.global_variables |
| 110 |
WHERE VARIABLE_NAME='slow_query_log'; |
| 111 |
--enable_warnings |
| 112 |
|
| 113 |
|
| 114 |
--echo '#---------------------FN_DYNVARS_004_06----------------------#' |
| 115 |
################################################################ |
| 116 |
# Check if 0 and 1 values can be used on variable # |
| 117 |
################################################################ |
| 118 |
|
| 119 |
SET @@global.slow_query_log = 0; |
| 120 |
SELECT @@global.slow_query_log; |
| 121 |
SET @@global.slow_query_log = 1; |
| 122 |
SELECT @@global.slow_query_log; |
| 123 |
|
| 124 |
--echo '#---------------------FN_DYNVARS_004_07----------------------#' |
| 125 |
################################################################### |
| 126 |
# Check if TRUE and FALSE values can be used on variable # |
| 127 |
################################################################### |
| 128 |
|
| 129 |
SET @@global.slow_query_log = TRUE; |
| 130 |
SELECT @@global.slow_query_log; |
| 131 |
SET @@global.slow_query_log = FALSE; |
| 132 |
SELECT @@global.slow_query_log; |
| 133 |
|
| 134 |
--echo '#---------------------FN_DYNVARS_004_08----------------------#' |
| 135 |
############################################################################## |
| 136 |
# Check if accessing variable with SESSION,LOCAL and without SCOPE points # |
| 137 |
# to same session variable # |
| 138 |
############################################################################## |
| 139 |
|
| 140 |
SET @@global.slow_query_log = ON; |
| 141 |
SELECT @@slow_query_log = @@global.slow_query_log; |
| 142 |
|
| 143 |
--echo '#---------------------FN_DYNVARS_004_09----------------------#' |
| 144 |
###################################################################### |
| 145 |
# Check if slow_query_log can be accessed with and without @@ sign # |
| 146 |
###################################################################### |
| 147 |
--Error ER_GLOBAL_VARIABLE |
| 148 |
SET slow_query_log = ON; |
| 149 |
--Error ER_PARSE_ERROR |
| 150 |
SET local.slow_query_log = OFF; |
| 151 |
--Error ER_UNKNOWN_TABLE |
| 152 |
SELECT local.slow_query_log; |
| 153 |
--Error ER_PARSE_ERROR |
| 154 |
SET global.slow_query_log = ON; |
| 155 |
--Error ER_UNKNOWN_TABLE |
| 156 |
SELECT global.slow_query_log; |
| 157 |
--Error ER_BAD_FIELD_ERROR |
| 158 |
SELECT slow_query_log; |
| 159 |
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 160 |
SELECT @@session.slow_query_log; |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
############################## |
| 165 |
# Restore initial value # |
| 166 |
############################## |
| 167 |
|
| 168 |
SET @@global.slow_query_log = @start_value; |
| 169 |
SELECT @@global.slow_query_log; |
| 170 |
|
| 171 |
|
| 172 |
#################################################### |
| 173 |
# END OF slow_query_log TESTS # |
| 174 |
#################################################### |