summaryrefslogtreecommitdiff
path: root/mysql-test/t/query_cache_wlock_invalidate_func.test
blob: 83b0c446b28c02d23a8b4cdeed335b8f6ffeb760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
############# mysql-test\t\query_cache_wlock_invalidate_func.test ####################
#                                                                                    #
# Variable Name: query_cache_wlock_invalidate                                        #
# Scope: GLOBAL & SESSION                                                            #
# Access Type: Dynamic                                                               #
# Data Type: boolean                                                                 #
# Default Value: FALSE                                                               #
# Values: TRUE / 1, FALSE / 0                                                        #
#                                                                                    #
#                                                                                    #
# Creation Date: 2008-02-21                                                          #
# Author:  Sharique Abdullah                                                         #
#                                                                                    #
# Description: Test Cases of Dynamic System Variable "query_cache_wlock_invalidate"  #
#              that checks behavior of this variable in the following ways           #
#              * Default Value                                                       #
#              * Valid & Invalid values                                              #
#              * Scope & Access method                                               #
#              * Cache behaviors                                                     #
#                                                                                    #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                                 #
#            server-system-variables.html#option_mysqld_query_cache_wlock_invalidate #
#                                                                                    #
######################################################################################

--echo ** Setup **
--echo
#
# Setup
#

# disabled due to differences in the result
--disable_ps_protocol
#
# Save initial value
#
--echo ** Connecting con0 using root **
connect (con0,localhost,root,,);
--echo ** Connecting con1 using root **
connect (con1, localhost, root,,);
--echo ** Connection con0 **
connection con0;

SET @start_global_value = @@GLOBAL.query_cache_wlock_invalidate;
SET @start_session_value = @@SESSION.query_cache_wlock_invalidate;

SET @old_cache_size = @@GLOBAL.query_cache_size;
SET @old_cache_type = @@GLOBAL.query_cache_type;

#
# Creating test table
#

CREATE TABLE t1(id int, value varchar(10));

INSERT INTO t1 VALUES(1, 'val1');
INSERT INTO t1 VALUES(2, 'val2');
INSERT INTO t1 VALUES(3, 'val3');

#
# Clearing the query cache and setting up cache size
#

SET GLOBAL query_cache_size = 131072;

--echo FLUSHING CACHE
SET GLOBAL query_cache_size = 0;
SET GLOBAL query_cache_size = 131072;

SET GLOBAL query_cache_type = ON;

#
# Testing for value ON
#
--echo Testing for value ON

--echo ** Connection con0 **
connection con0;

SET SESSION query_cache_wlock_invalidate = ON;

--echo ** Connection con1 **
connection con1;

SET SESSION query_cache_wlock_invalidate = ON;

--echo '#----------------------------FN_DYNVARS_136_01--------------#'
#
# Testing for cache invalidation
#

--echo Testing for cache invalidation

SELECT * FROM t1;

SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 1 Expected

LOCK TABLE t1 WRITE;

UNLOCK TABLES;

SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 0 Expected

--echo '#----------------------------FN_DYNVARS_136_02-----------------------#'
#
# Testing for blockage of access
#

disable_result_log;

SELECT * FROM t1;

SHOW STATUS LIKE 'Qcache_queries_in_cache';

enable_result_log;

--echo ** Connection con1 **
connection con1;

SELECT * FROM t1;

--echo ** Connection con0 **
connection con0;

LOCK TABLE t1 WRITE;

--echo ** Connection con1 **
connection con1;

--echo ** Asynchronous Execution **
send SELECT * FROM t1;

--echo ** Connection con0 **
connection con0;

--echo Sleeping 2 Seconds before unlock
--sleep 2
UNLOCK TABLES;

--echo ** Connection con1 **
connection con1;
--echo ** Asynchronous Result **
reap;

#
# Testing for value OFF
#
--echo Testing for value OFF

--echo ** Connection con0 **
connection con0;

SET SESSION query_cache_wlock_invalidate = OFF;

--echo ** Connection con1 **
connection con1;

SET SESSION query_cache_wlock_invalidate = OFF;

--echo '#----------------------------FN_DYNVARS_136_03------------------#'
#
# Testing for cache invalidation
#

--echo Testing for cache invalidation

SELECT * FROM t1;

SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 1 Expected

LOCK TABLE t1 WRITE;

UNLOCK TABLES;

SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 1 Expected

--echo '#----------------------------FN_DYNVARS_136_04---------------------#'
#
# Testing for blockage of access
#

SELECT * FROM t1;

SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 1 Expected

--echo ** Connection con1 **
connection con1;

SELECT * FROM t1;

--echo ** Connection con0 **
connection con0;

LOCK TABLE t1 WRITE;

--echo ** Connection con1 **
connection con1;

--echo ** Should not be blocked **
SELECT * FROM t1;

--echo ** Connection con0 **
connection con0;

--echo Sleeping 2 Seconds before unlock
--sleep 2
UNLOCK TABLES;

--echo ** Connection con1 **
connection con1;

--echo '#----------------------------FN_DYNVARS_136_05------------------------#'
#
# Session data integrity check & GLOBAL Value check
#

SET GLOBAL query_cache_wlock_invalidate = OFF;

--echo ** Connecting con_int1 using root **
connect (con_int1,localhost,root,,);
--echo ** Connection con_int1 **
connection con_int1;

SELECT @@SESSION.query_cache_wlock_invalidate;
--echo Expected Value : 0 / OFF;
SET SESSION query_cache_wlock_invalidate = ON;

--echo ** Connecting con_int2 using root **
connect (con_int2,localhost,root,,);
--echo ** Connection con_int2 **
connection con_int2;

SELECT @@SESSION.query_cache_wlock_invalidate;
--echo Expected Value : 0 / OFF;

SET SESSION query_cache_wlock_invalidate = OFF;

--echo ** Connection con_int1 **
connection con_int1;
SELECT @@SESSION.query_cache_wlock_invalidate;
--echo Expected Value : 1 / ON;

--echo ** Connection con_int2 **
connection con_int2;
SELECT @@SESSION.query_cache_wlock_invalidate;
--echo Expected Value : 0 / OFF;

SELECT @@GLOBAL.query_cache_wlock_invalidate;
--echo Expected Value : 0 / OFF;

--echo ** Connection default **
connection default;
--echo Disconnecting Connections con_int1, con_int2
disconnect con_int1;
disconnect con_int2;

#
# Cleanup
#
--echo
--echo CLEANUP

--echo ** Connection con0 **
connection con0;

SET @@GLOBAL.query_cache_wlock_invalidate = @start_global_value;
SET @@SESSION.query_cache_wlock_invalidate = @start_session_value ;
SET @@GLOBAL.query_cache_size = @old_cache_size;
SET @@GLOBAL.query_cache_type = @old_cache_type;

--echo ** Connection default **
connection default;
--echo Disconnecting Connections con0, con1
disconnect con0;
disconnect con1;

DROP TABLE t1;

--enable_ps_protocol