MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
query_cache_size_basic.inc
1 ############## mysql-test\t\query_cache_size_basic.test ###############
2 # #
3 # Variable Name: query_cache_size #
4 # Scope: GLOBAL #
5 # Access Type: Dynamic #
6 # Data Type: numeric #
7 # Default Value: 1048576 (1M) #
8 # Range: - #
9 # #
10 # #
11 # Creation Date: 2008-02-07 #
12 # Author: Salman #
13 # #
14 # Description: Test Cases of Dynamic System Variable query_cache_size #
15 # that checks the 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-system-variables.html #
23 # #
24 ###############################################################################
25 
26 --source include/have_query_cache.inc
27 --source include/load_sysvars.inc
28 
29 ########################################################################
30 # START OF query_cache_size TESTS #
31 ########################################################################
32 
33 
34 ###############################################################################
35 # Saving initial value of query_cache_size in a temporary variable #
36 ###############################################################################
37 
38 SET @start_value = @@global.query_cache_size;
39 
40 --echo '#--------------------FN_DYNVARS_133_01------------------------#'
41 ###############################################################################
42 # Display the DEFAULT value of query_cache_size #
43 ###############################################################################
44 
45 SET @@global.query_cache_size = 99;
46 SET @@global.query_cache_size = DEFAULT;
47 SELECT @@global.query_cache_size;
48 
49 --echo '#---------------------FN_DYNVARS_133_02-------------------------#'
50 ###############################################
51 # Verify default value of variable #
52 ###############################################
53 
54 SET @@global.query_cache_size = @start_value;
55 SELECT @@global.query_cache_size = @start_value;
56 
57 --echo '#--------------------FN_DYNVARS_133_03------------------------#'
58 ################################################################################
59 # Change the value of query_cache_size to a valid value #
60 ################################################################################
61 
62 SET @@global.query_cache_size = 0;
63 SELECT @@global.query_cache_size;
64 SET @@global.query_cache_size = 1;
65 SELECT @@global.query_cache_size;
66 
67 SET @@global.query_cache_size = 512;
68 SELECT @@global.query_cache_size;
69 SET @@global.query_cache_size = 1024;
70 SELECT @@global.query_cache_size;
71 SET @@global.query_cache_size = 1048576;
72 SELECT @@global.query_cache_size;
73 SET @@global.query_cache_size = 1048575;
74 SELECT @@global.query_cache_size;
75 
76 --echo '#--------------------FN_DYNVARS_133_04-------------------------#'
77 ###################################################################################
78 # Change the value of query_cache_size to invalid value #
79 ###################################################################################
80 
81 SET @@global.query_cache_size = -1;
82 SELECT @@global.query_cache_size;
83 
84 #
85 # Bug 11748572 - 36747: ALLOCATING A LARGE QUERY CACHE IS NOT DETERMINISTIC
86 #
87 # SET @@global.query_cache_size = 4294967296;
88 # SELECT @@global.query_cache_size;
89 
90 SET @@global.query_cache_size = 511;
91 SELECT @@global.query_cache_size;
92 --Error ER_WRONG_TYPE_FOR_VAR
93 SET @@global.query_cache_size = 10000.01;
94 SELECT @@global.query_cache_size;
95 SET @@global.query_cache_size = -1024;
96 SELECT @@global.query_cache_size;
97 SET @@global.query_cache_size = 42949672950;
98 SELECT @@global.query_cache_size;
99 --Error ER_WRONG_TYPE_FOR_VAR
100 SET @@global.query_cache_size = ON;
101 SELECT @@global.query_cache_size;
102 --Error ER_WRONG_TYPE_FOR_VAR
103 SET @@global.query_cache_size = 'test';
104 SELECT @@global.query_cache_size;
105 
106 --echo '#-------------------FN_DYNVARS_133_05----------------------------#'
107 ###################################################################################
108 # Test if accessing session query_cache_size gives error #
109 ###################################################################################
110 
111 --Error ER_GLOBAL_VARIABLE
112 SET @@session.query_cache_size = 0;
113 SELECT @@query_cache_size;
114 
115 --echo '#----------------------FN_DYNVARS_133_06------------------------#'
116 ##############################################################################
117 # Check if the value in GLOBAL & SESSION Tables matches values in variable #
118 ##############################################################################
119 
120 SELECT @@global.query_cache_size = VARIABLE_VALUE
121 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
122 WHERE VARIABLE_NAME='query_cache_size';
123 
124 SELECT @@query_cache_size = VARIABLE_VALUE
125 FROM INFORMATION_SCHEMA.SESSION_VARIABLES
126 WHERE VARIABLE_NAME='query_cache_size';
127 
128 --echo '#---------------------FN_DYNVARS_133_07----------------------#'
129 ###################################################################
130 # Check if TRUE and FALSE values can be used on variable #
131 ###################################################################
132 
133 SET @@global.query_cache_size = TRUE;
134 SELECT @@global.query_cache_size;
135 SET @@global.query_cache_size = FALSE;
136 SELECT @@global.query_cache_size;
137 
138 --echo '#---------------------FN_DYNVARS_133_08----------------------#'
139 ########################################################################################################
140 # Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
141 ########################################################################################################
142 
143 SET @@global.query_cache_size = 1;
144 SELECT @@query_cache_size = @@global.query_cache_size;
145 
146 --echo '#---------------------FN_DYNVARS_133_09----------------------#'
147 ##################################################################################
148 # Check if query_cache_size can be accessed with and without @@ sign #
149 ##################################################################################
150 
151 --Error ER_GLOBAL_VARIABLE
152 SET query_cache_size = 1;
153 SELECT @@query_cache_size;
154 --Error ER_PARSE_ERROR
155 SET local.query_cache_size = 1;
156 --Error ER_UNKNOWN_TABLE
157 SELECT local.query_cache_size;
158 --Error ER_PARSE_ERROR
159 SET global.query_cache_size = 1;
160 --Error ER_UNKNOWN_TABLE
161 SELECT global.query_cache_size;
162 --Error ER_BAD_FIELD_ERROR
163 SELECT query_cache_size = @@session.query_cache_size;
164 
165 ##############################
166 # Restore initial value #
167 ##############################
168 
169 SET @@global.query_cache_size = @start_value;
170 
171 ########################################################################
172 # END OF query_cache_size TESTS #
173 ########################################################################
174