Merge lp:~sharan-monikantan/drizzle/trunk-bug-723915-complete into lp:drizzle
- trunk-bug-723915-complete
- Merge into 7.2
Proposed by
Patrick Crews
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~sharan-monikantan/drizzle/trunk-bug-723915-complete | ||||
Merge into: | lp:drizzle | ||||
Diff against target: |
2145 lines (+1856/-43) 23 files modified
plugin/logging_query/tests/parse-query-log.sh (+1/-1) plugin/logging_query/tests/r/blob.result (+46/-0) plugin/logging_query/tests/r/create.result (+61/-0) plugin/logging_query/tests/r/datatypes_datetime.result (+117/-0) plugin/logging_query/tests/r/datatypes_numeric.result (+97/-0) plugin/logging_query/tests/r/datatypes_string.result (+62/-0) plugin/logging_query/tests/r/delete.result (+104/-0) plugin/logging_query/tests/r/file.result (+36/-11) plugin/logging_query/tests/r/insert.result (+85/-0) plugin/logging_query/tests/r/select.result (+130/-0) plugin/logging_query/tests/r/thresholds.result (+11/-7) plugin/logging_query/tests/r/update.result (+62/-0) plugin/logging_query/tests/t/blob.test (+84/-0) plugin/logging_query/tests/t/create.test (+80/-0) plugin/logging_query/tests/t/datatypes_datetime.test (+151/-0) plugin/logging_query/tests/t/datatypes_numeric.test (+126/-0) plugin/logging_query/tests/t/datatypes_string.test (+111/-0) plugin/logging_query/tests/t/delete.test (+152/-0) plugin/logging_query/tests/t/file.bak (+33/-24) plugin/logging_query/tests/t/insert.test (+87/-0) plugin/logging_query/tests/t/select.test (+128/-0) plugin/logging_query/tests/t/thresholds.bak (+4/-0) plugin/logging_query/tests/t/update.test (+88/-0) |
||||
To merge this branch: | bzr merge lp:~sharan-monikantan/drizzle/trunk-bug-723915-complete | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Patrick Crews | Needs Fixing | ||
Review via email: mp+128547@code.launchpad.net |
Commit message
Description of the change
Added tests for the logging query plugin
To post a comment you must log in.
Unmerged revisions
- 2595. By Sharan Kumar
-
Added the following tests to logging_query plugin
1.blob
2.create
3.datatypes_datetime
4.datatypes_numeric
5.datatypes_string
6.delete
7.insert
8.select
9.update
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugin/logging_query/tests/parse-query-log.sh' |
2 | --- plugin/logging_query/tests/parse-query-log.sh 2012-07-10 18:29:14 +0000 |
3 | +++ plugin/logging_query/tests/parse-query-log.sh 2012-10-08 16:53:22 +0000 |
4 | @@ -1,2 +1,2 @@ |
5 | #!/bin/sh |
6 | -wc -l "$1"|awk '{print($1)}' |
7 | +wc -l "$1"|awk '{print("Number of queries logged : "$1)}' |
8 | |
9 | === added file 'plugin/logging_query/tests/r/blob.result' |
10 | --- plugin/logging_query/tests/r/blob.result 1970-01-01 00:00:00 +0000 |
11 | +++ plugin/logging_query/tests/r/blob.result 2012-10-08 16:53:22 +0000 |
12 | @@ -0,0 +1,46 @@ |
13 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
14 | +Log file exists |
15 | +Number of queries logged : 1 |
16 | +# The logging_query plugin is not enabled and hence none of the following queries should be logged |
17 | +DROP SCHEMA IF EXISTS Blob_Test; |
18 | +Warnings: |
19 | +Note 1008 Can't drop schema 'Blob_Test'; schema doesn't exist |
20 | +CREATE SCHEMA Blob_Test; |
21 | +USE Blob_Test; |
22 | +CREATE TABLE test_blob (data BLOB); |
23 | +# Enabling the logging_query plugin |
24 | +SET GLOBAL logging_query_enable=true; |
25 | +Inserting blob data |
26 | +INSERT INTO test_blob VALUES (null); |
27 | +INSERT INTO test_blob VALUES (""); |
28 | +INSERT INTO test_blob VALUES ("A"); |
29 | +INSERT INTO test_blob VALUES ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
30 | +INSERT INTO test_blob VALUES ("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"); |
31 | +Number of queries logged : 7 |
32 | +Selecting blob data |
33 | +SELECT data FROM test_blob WHERE data LIKE null; |
34 | +data |
35 | +SELECT data FROM test_blob WHERE data LIKE ""; |
36 | +data |
37 | + |
38 | +SELECT data FROM test_blob WHERE data LIKE "A"; |
39 | +data |
40 | +A |
41 | +SELECT data FROM test_blob WHERE LENGTH(data) < 100; |
42 | +data |
43 | + |
44 | +A |
45 | +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
46 | +SELECT data FROM test_blob WHERE LENGTH(data) > 1024; |
47 | +data |
48 | +ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
49 | +Number of queries logged : 12 |
50 | +Deleting blob data |
51 | +DELETE FROM test_blob WHERE data LIKE null; |
52 | +DELETE FROM test_blob WHERE LENGTH(data) > 1000; |
53 | +DELETE FROM test_blob WHERE data = 'A'; |
54 | +Number of queries logged : 15 |
55 | +cleaning up... |
56 | +SET GLOBAL logging_query_enable=false; |
57 | +DROP SCHEMA Blob_Test; |
58 | +***done*** |
59 | |
60 | === added file 'plugin/logging_query/tests/r/create.result' |
61 | --- plugin/logging_query/tests/r/create.result 1970-01-01 00:00:00 +0000 |
62 | +++ plugin/logging_query/tests/r/create.result 2012-10-08 16:53:22 +0000 |
63 | @@ -0,0 +1,61 @@ |
64 | +# Logging query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not |
65 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
66 | +Log file exists |
67 | +# Clearing the log file |
68 | +# Checking if the log file is cleared |
69 | +Number of queries logged : 1 |
70 | +# The above command should print 1 indicating that the file is empty |
71 | +# Preparation phase completed |
72 | + |
73 | +# Starting the test |
74 | +# The logging_query is not enabled and hence the following query should not be logged |
75 | +DROP SCHEMA IF EXISTS test; |
76 | +CREATE SCHEMA test; |
77 | +# This should print 1 to indicate the log file is still empty |
78 | +Number of queries logged : 1 |
79 | +# Enabling the logging_query plugin |
80 | +SET GLOBAL logging_query_enable=true; |
81 | +# The following queries should be logged |
82 | +DROP SCHEMA IF EXISTS test_db; |
83 | +Warnings: |
84 | +Note 1008 Can't drop schema 'test_db'; schema doesn't exist |
85 | +CREATE SCHEMA test_db; |
86 | +USE test_db; |
87 | +# This should print 6 indicating that the above queries are logged |
88 | +Number of queries logged : 6 |
89 | +# Issuing another CREATE query. This should be logged |
90 | +CREATE TABLE Test_Entries (test_id INT, test_name VARCHAR(10)); |
91 | +# This should print 7 to indicate that the above query is logged |
92 | +Number of queries logged : 7 |
93 | +# Enabling logging_query pluging for only SELECT queries |
94 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
95 | +# The following CREATE query should not be logged |
96 | +CREATE TABLE Test_Entries_2 (test_id INT, test_name VARCHAR(10)); |
97 | +# This should print 8 to indicate that the above query is not logged |
98 | +Number of queries logged : 8 |
99 | +# The following SELECT query should be logged |
100 | +SELECT * FROM Test_Entries_2; |
101 | +test_id test_name |
102 | +# This should print 9 to indicate that the above query is logged |
103 | +Number of queries logged : 9 |
104 | +# Enabling logging_query plugin for only CREATE queries |
105 | +SET GLOBAL logging_query_pcre="CREATE.+"; |
106 | +# The following CREATE query should be logged |
107 | +DROP SCHEMA IF EXISTS test_db_2; |
108 | +Warnings: |
109 | +Note 1008 Can't drop schema 'test_db_2'; schema doesn't exist |
110 | +CREATE SCHEMA test_db_2; |
111 | +# This should print 11 |
112 | +Number of queries logged : 11 |
113 | +# The following SELECT query should not be logged |
114 | +SELECT * FROM Test_Entries_2; |
115 | +test_id test_name |
116 | +# This should print 11 indicating that the above query is not logged |
117 | +Number of queries logged : 11 |
118 | +cleaning up... |
119 | +DROP SCHEMA test; |
120 | +DROP SCHEMA test_db; |
121 | +DROP SCHEMA test_db_2; |
122 | +SET GLOBAL logging_query_enable=false; |
123 | +SET GLOBAL logging_query_pcre=".+"; |
124 | +***done*** |
125 | |
126 | === added file 'plugin/logging_query/tests/r/datatypes_datetime.result' |
127 | --- plugin/logging_query/tests/r/datatypes_datetime.result 1970-01-01 00:00:00 +0000 |
128 | +++ plugin/logging_query/tests/r/datatypes_datetime.result 2012-10-08 16:53:22 +0000 |
129 | @@ -0,0 +1,117 @@ |
130 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
131 | +Log file exists |
132 | +Number of queries logged : 1 |
133 | +# logging_query plugin is not enabled and hence none of the following queries should be logged |
134 | +DROP SCHEMA IF EXISTS Test; |
135 | +CREATE SCHEMA Test; |
136 | +USE Test; |
137 | +# Enabling the logging_query plugin |
138 | +SET GLOBAL logging_query_enable=true; |
139 | +#DATE |
140 | +CREATE TABLE test_date (type DATE); |
141 | +# Inserting a record with DATE value within the range |
142 | +INSERT INTO test_date VALUES ('1990-01-01'); |
143 | +INSERT INTO test_date VALUES ('2012-01-01'); |
144 | +# Inserting a record with DATE value on range border |
145 | +INSERT INTO test_date VALUES ('0001-01-01'); |
146 | +INSERT INTO test_date VALUES ('9999-12-31'); |
147 | +# Selecting the record |
148 | +SELECT type FROM test_date WHERE (EXTRACT(year FROM type) == 1990); |
149 | +type |
150 | +1990-01-01 |
151 | +SELECT type FROM test_date WHERE (EXTRACT(month FROM type) == 01); |
152 | +type |
153 | +1990-01-01 |
154 | +2012-01-01 |
155 | +0001-01-01 |
156 | +SELECT type FROM test_date WHERE (EXTRACT(day FROM type) == 31); |
157 | +type |
158 | +9999-12-31 |
159 | +# Deleting the record |
160 | +DELETE FROM test_date WHERE (EXTRACT(year FROM type) == 0001); |
161 | +DELETE FROM test_date WHERE (EXTRACT(month FROM type) == 01); |
162 | +DELETE FROM test_date WHERE (EXTRACT(day FROM type) == 31); |
163 | +# Selecting the record ; this should return a NULL set |
164 | +SELECT * FROM test_date; |
165 | +type |
166 | +Number of queries logged : 14 |
167 | +#TIME |
168 | +CREATE TABLE test_time (type TIME); |
169 | +# Inserting a record with TIME value within the range |
170 | +INSERT INTO test_time VALUES ('09:00:00'); |
171 | +INSERT INTO test_time VALUES ('15:00:00'); |
172 | +# Inserting a record with TIME value on range border |
173 | +INSERT INTO test_time VALUES ('00:00:00'); |
174 | +INSERT INTO test_time VALUES ('23:59:59'); |
175 | +# Selecting the record |
176 | +SELECT type FROM test_time WHERE (HOUR(type) == 09); |
177 | +type |
178 | +09:00:00 |
179 | +SELECT type FROM test_time WHERE (MINUTE(type) == 00); |
180 | +type |
181 | +09:00:00 |
182 | +15:00:00 |
183 | +00:00:00 |
184 | +SELECT type FROM test_time WHERE (SECOND(type) == 59); |
185 | +type |
186 | +23:59:59 |
187 | +# Deleting the record |
188 | +DELETE FROM test_time WHERE (HOUR(type) == 09); |
189 | +DELETE FROM test_time WHERE (MINUTE(type) == 00); |
190 | +DELETE FROM test_time WHERE (SECOND(type) == 59); |
191 | +# Selecting the record ; this should return a NULL set |
192 | +SELECT * FROM test_time; |
193 | +type |
194 | +Number of queries logged : 26 |
195 | +#DATETIME |
196 | +CREATE TABLE test_datetime (type DATETIME); |
197 | +# Inserting a record with DATETIME value within the range |
198 | +INSERT INTO test_datetime VALUES ('1992-07-22 07:50:30'); |
199 | +INSERT INTO test_datetime VALUES ('2012-09-29 20:49:50'); |
200 | +# Insertingt a record with DATETIME value on range border |
201 | +INSERT INTO test_datetime VALUES ('0001-01-01 00:00:00'); |
202 | +INSERT INTO test_datetime VALUES ('9999-12-31 23:59:59'); |
203 | +# Selecting the record |
204 | +SELECT type FROM test_datetime WHERE (EXTRACT(year FROM type) == 1992); |
205 | +type |
206 | +1992-07-22 07:50:30 |
207 | +SELECT type FROM test_datetime WHERE (HOUR(type) == 07); |
208 | +type |
209 | +1992-07-22 07:50:30 |
210 | +# Deleting the record |
211 | +DELETE FROM test_datetime WHERE (EXTRACT(year FROM type) == 2012); |
212 | +DELETE FROM test_datetime WHERE (MINUTE(type) == 50); |
213 | +# Selecting the records ; this should return 2 records |
214 | +SELECT * FROM test_datetime; |
215 | +type |
216 | +0001-01-01 00:00:00 |
217 | +9999-12-31 23:59:59 |
218 | +Number of queries logged : 36 |
219 | +#TIMESTAMP(6) |
220 | +CREATE TABLE test_timestamp (type TIMESTAMP(6)); |
221 | +# Inserting a record with TIMESTAMP value within the range |
222 | +INSERT INTO test_timestamp VALUES ('1992-07-22 07:50:23.324543'); |
223 | +INSERT INTO test_timestamp VALUES ('2012-09-29 23:12:20.232109'); |
224 | +# Inserting a record with TIMESTAMP value on range border |
225 | +INSERT INTO test_timestamp VALUES ('1970-01-01 00:00:01.000000'); |
226 | +INSERT INTO test_timestamp VALUES ('2038-01-19 03:14:07.999999'); |
227 | +# Selecting the record |
228 | +SELECT type FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1970); |
229 | +type |
230 | +1970-01-01 00:00:01.000000 |
231 | +SELECT type FROM test_timestamp WHERE (HOUR(type) == 03); |
232 | +type |
233 | +2038-01-19 03:14:07.999999 |
234 | +# Deleting the record |
235 | +DELETE FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1992); |
236 | +DELETE FROM test_timestamp WHERE (MINUTE(type) == 12); |
237 | +# Selecting the records ; this should return 2 records |
238 | +SELECT * FROM test_timestamp; |
239 | +type |
240 | +1970-01-01 00:00:01.000000 |
241 | +2038-01-19 03:14:07.999999 |
242 | +Number of queries logged : 46 |
243 | +cleaning up... |
244 | +SET GLOBAL logging_query_enable=false; |
245 | +DROP SCHEMA Test; |
246 | +***done*** |
247 | |
248 | === added file 'plugin/logging_query/tests/r/datatypes_numeric.result' |
249 | --- plugin/logging_query/tests/r/datatypes_numeric.result 1970-01-01 00:00:00 +0000 |
250 | +++ plugin/logging_query/tests/r/datatypes_numeric.result 2012-10-08 16:53:22 +0000 |
251 | @@ -0,0 +1,97 @@ |
252 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
253 | +Log file exists |
254 | +Number of queries logged : 1 |
255 | +# logging_query plugin is not enabled and hence none of the following queries should be logged |
256 | +DROP SCHEMA IF EXISTS Test; |
257 | +CREATE SCHEMA Test; |
258 | +USE Test; |
259 | +# Enabling the logging_query plugin |
260 | +SET GLOBAL logging_query_enable=true; |
261 | +#INTEGER |
262 | +CREATE TABLE test_integer (type INTEGER); |
263 | +# Inserting a record with INTEGER value within range |
264 | +INSERT INTO test_integer VALUES (2147483645); |
265 | +INSERT INTO test_integer VALUES (-2147483645); |
266 | +# Inserting a record with INTEGER value on range borders |
267 | +INSERT INTO test_integer VALUES (2147483647); |
268 | +INSERT INTO test_integer VALUES (-2147483648); |
269 | +# Selecting the record from table |
270 | +SELECT type FROM test_integer WHERE type > 0; |
271 | +type |
272 | +2147483645 |
273 | +2147483647 |
274 | +SELECT type FROM test_integer WHERE type < 0; |
275 | +type |
276 | +-2147483645 |
277 | +-2147483648 |
278 | +# Deleting a record from table |
279 | +DELETE FROM test_integer WHERE type > 0; |
280 | +# This SELECT should return only two records |
281 | +SELECT * FROM test_integer; |
282 | +type |
283 | +-2147483645 |
284 | +-2147483648 |
285 | +# Deleting a record from table |
286 | +DELETE FROM test_integer WHERE type < 0; |
287 | +# This SELECT should return a NULL set |
288 | +SELECT * FROM test_integer; |
289 | +type |
290 | +Number of queries logged : 13 |
291 | +#BIGINT |
292 | +CREATE TABLE test_bigint (type BIGINT); |
293 | +# Inserting a record with BIGINT value within range |
294 | +INSERT INTO test_bigint VALUES (9223372036854775805); |
295 | +INSERT INTO test_bigint VALUES (-9223372036854775805); |
296 | +# Inserting a record with BIGINT value on range borders |
297 | +INSERT INTO test_bigint VALUES (9223372036854775807); |
298 | +INSERT INTO test_bigint VALUES (-9223372036854775808); |
299 | +# Selecting the record from table |
300 | +SELECT type FROM test_bigint WHERE type > 0; |
301 | +type |
302 | +9223372036854775805 |
303 | +9223372036854775807 |
304 | +SELECT type FROM test_bigint WHERE type < 0; |
305 | +type |
306 | +-9223372036854775805 |
307 | +-9223372036854775808 |
308 | +# Deleting a record from table |
309 | +DELETE FROM test_bigint WHERE type > 0; |
310 | +# This SELECT should return only two records |
311 | +SELECT * FROM test_bigint; |
312 | +type |
313 | +-9223372036854775805 |
314 | +-9223372036854775808 |
315 | +# Deleting a record from table |
316 | +DELETE FROM test_bigint WHERE type < 0; |
317 | +# This SELECT should return a NULL set |
318 | +SELECT * FROM test_bigint; |
319 | +type |
320 | +Number of queries logged : 24 |
321 | +#DOUBLE |
322 | +CREATE TABLE test_double (type DOUBLE); |
323 | +#Inserting a record with DOUBLE value within range |
324 | +INSERT INTO test_double VALUES (-1.7976931348623155E+308); |
325 | +INSERT INTO test_double VALUES (1.7976931348623157E+308); |
326 | +# Selecting the record from table |
327 | +SELECT type FROM test_double WHERE type > 0; |
328 | +type |
329 | +1.79769313486232e308 |
330 | +SELECT type FROM test_double WHERE type < 0; |
331 | +type |
332 | +-1.79769313486232e308 |
333 | +# Deleting a record from table |
334 | +DELETE FROM test_double WHERE type > 0; |
335 | +# This SELECT should return only one record |
336 | +SELECT * FROM test_double; |
337 | +type |
338 | +-1.79769313486232e308 |
339 | +# Deleting a record from table |
340 | +DELETE FROM test_double WHERE type < 0; |
341 | +# This SELECT should return a NULL set |
342 | +SELECT * FROM test_double; |
343 | +type |
344 | +Number of queries logged : 33 |
345 | +cleaning up... |
346 | +SET GLOBAL logging_query_enable=false; |
347 | +DROP SCHEMA Test; |
348 | +***done*** |
349 | |
350 | === added file 'plugin/logging_query/tests/r/datatypes_string.result' |
351 | --- plugin/logging_query/tests/r/datatypes_string.result 1970-01-01 00:00:00 +0000 |
352 | +++ plugin/logging_query/tests/r/datatypes_string.result 2012-10-08 16:53:22 +0000 |
353 | @@ -0,0 +1,62 @@ |
354 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
355 | +Log file exists |
356 | +Number of queries logged : 1 |
357 | +# logging_query plugin is not enabled and hence none of the following queries should be logged |
358 | +DROP SCHEMA IF EXISTS Test; |
359 | +CREATE SCHEMA Test; |
360 | +USE Test; |
361 | +# Enabling the logging_query plugin |
362 | +SET GLOBAL logging_query_enable=true; |
363 | +#VARCHAR |
364 | +CREATE TABLE test_varchar (type VARCHAR(10)); |
365 | +# Inserting a record with VARCHAR length within range |
366 | +INSERT INTO test_varchar VALUES ('varchar'); |
367 | +INSERT INTO test_varchar VALUES ('sql'); |
368 | +# Inserting a record with VARCHAR length on range borders |
369 | +INSERT INTO test_varchar VALUES ('drizzle-DB'); |
370 | +INSERT INTO test_varchar VALUES (''); |
371 | +# Selecting records from table |
372 | +SELECT type FROM test_varchar WHERE LENGTH(type) = 3; |
373 | +type |
374 | +sql |
375 | +SELECT type FROM test_varchar WHERE LENGTH(type) = 0; |
376 | +type |
377 | + |
378 | +# Deleting records |
379 | +DELETE FROM test_varchar WHERE type LIKE REVERSE('rahcrav'); |
380 | +DELETE FROM test_varchar WHERE type LIKE SUBSTRING('mysql',3); |
381 | +# Selecting records from table ; this should return 2 rows |
382 | +SELECT * FROM test_varchar; |
383 | +type |
384 | +drizzle-DB |
385 | + |
386 | +Number of queries logged : 12 |
387 | +#ENUM |
388 | +CREATE TABLE test_enum (type ENUM('one','two','three','four','five','six','seven','eight','nine','ten')); |
389 | +# Inserting a record with ENUM value within range |
390 | +INSERT INTO test_enum VALUES (3); |
391 | +INSERT INTO test_enum VALUES (7); |
392 | +# Inserting a record with ENUM value on range border |
393 | +INSERT INTO test_enum VALUES (1); |
394 | +INSERT INTO test_enum VALUES (9); |
395 | +# Selecting records from table |
396 | +SELECT type FROM test_enum WHERE type > 5; |
397 | +type |
398 | +seven |
399 | +nine |
400 | +SELECT type FROM test_enum WHERE type < 5; |
401 | +type |
402 | +three |
403 | +one |
404 | +# Deleting records |
405 | +DELETE FROM test_enum WHERE type = 9; |
406 | +DELETE FROM test_enum WHERE type > 1; |
407 | +# Selecting records from table ; this should return 1 row |
408 | +SELECT * FROM test_enum; |
409 | +type |
410 | +one |
411 | +Number of queries logged : 22 |
412 | +cleaning up... |
413 | +SET GLOBAL logging_query_enable=false; |
414 | +DROP SCHEMA Test; |
415 | +***done*** |
416 | |
417 | === added file 'plugin/logging_query/tests/r/delete.result' |
418 | --- plugin/logging_query/tests/r/delete.result 1970-01-01 00:00:00 +0000 |
419 | +++ plugin/logging_query/tests/r/delete.result 2012-10-08 16:53:22 +0000 |
420 | @@ -0,0 +1,104 @@ |
421 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
422 | +Log file exists |
423 | +Number of queries logged : 1 |
424 | +Preparing the test bed... |
425 | +# The logging_query plugin is not yet enabled and hence none of the queries in the prepare phase should be logged |
426 | +DROP SCHEMA IF EXISTS Test_Delete; |
427 | +Warnings: |
428 | +Note 1008 Can't drop schema 'Test_Delete'; schema doesn't exist |
429 | +CREATE SCHEMA Test_Delete; |
430 | +DROP SCHEMA IF EXISTS Test_Truncate; |
431 | +Warnings: |
432 | +Note 1008 Can't drop schema 'Test_Truncate'; schema doesn't exist |
433 | +CREATE SCHEMA Test_Truncate; |
434 | +DROP SCHEMA IF EXISTS Test_Drop; |
435 | +Warnings: |
436 | +Note 1008 Can't drop schema 'Test_Drop'; schema doesn't exist |
437 | +CREATE SCHEMA Test_Drop; |
438 | +# Preparing test bed for DELETE test |
439 | +USE Test_Delete; |
440 | +CREATE TABLE test_delete_1 ( test_id INT, test_name CHAR(10) ); |
441 | +INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
442 | +CREATE TABLE test_delete_2 ( test_id INT, test_name VARCHAR(10) ); |
443 | +INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
444 | +# Preparing test bed for TRUNCATE test |
445 | +USE Test_Truncate; |
446 | +CREATE TABLE test_truncate_1 ( test_id INT, test_name CHAR(10) ); |
447 | +INSERT INTO test_truncate_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
448 | +CREATE TABLE test_truncate_2 ( test_id INT, test_name CHAR(10) ); |
449 | +INSERT INTO test_truncate_2 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
450 | +# Preparing test bed for DROP test |
451 | +USE Test_Drop; |
452 | +CREATE TABLE test_drop ( test_id INT, test_name CHAR(10) ); |
453 | +CREATE INDEX index_id ON test_drop ( test_id ); |
454 | +INSERT INTO test_drop VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
455 | +# This should print 1 indicating that, the log file is still empty |
456 | +Number of queries logged : 1 |
457 | +# enabling the logging_query plugin |
458 | +SET GLOBAL logging_query_enable=true; |
459 | +# Now the tests begin!!! |
460 | +DELETE test in progress... |
461 | +USE Test_Delete; |
462 | +# The following 2 queries should be logged |
463 | +DELETE FROM test_delete_1; |
464 | +# The following query should return a null set |
465 | +SELECT * FROM test_delete_1; |
466 | +test_id test_name |
467 | +# enabling the logging_query plugin to log only DELETE queries |
468 | +SET GLOBAL logging_query_pcre="DELETE.+"; |
469 | +# The following DELETE queries should be logged |
470 | +DELETE FROM test_delete_2 WHERE test_id = 1; |
471 | +DELETE FROM test_delete_2 WHERE test_name = "select"; |
472 | +# The following query should select only tuples with id = (3,4,5) and this query should not be logged |
473 | +SELECT * FROM test_delete_2; |
474 | +test_id test_name |
475 | +# enabling the logging_query plugin to log SELECT queries |
476 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
477 | +# The following DELETE query should not be logged |
478 | +DELETE FROM test_delete_2; |
479 | +# The following SELECT query should return a null set and should be logged |
480 | +SELECT * FROM test_delete_2; |
481 | +test_id test_name |
482 | +# Delete test is completed. Now checking the logging_query.log file. This should print 10 |
483 | +Number of queries logged : 10 |
484 | +TRUNCATE test in progress... |
485 | +USE Test_Truncate; |
486 | +# enabling the logging_query plugin to log TRUNCATE queries |
487 | +SET GLOBAL logging_query_pcre="TRUNCATE.+"; |
488 | +# The following TRUNCATE query should be logged |
489 | +TRUNCATE TABLE test_truncate_1; |
490 | +# This SELECT query should not be logged ; this should return a null set |
491 | +SELECT * FROM test_truncate_1; |
492 | +test_id test_name |
493 | +# enabling the logging_query plugin to log RENAME query |
494 | +SET GLOBAL logging_query_pcre="RENAME.+"; |
495 | +# The following RENAME query should be logged |
496 | +RENAME TABLE test_truncate_2 TO test_truncate; |
497 | +# This TRUNCATE query should not be logged |
498 | +TRUNCATE TABLE test_truncate; |
499 | +# This SELECT query should not be logged ; this should return a null set |
500 | +SELECT * FROM test_truncate; |
501 | +test_id test_name |
502 | +# Truncate test is completed. Now checking the logging_query.log file. This should print 14 |
503 | +Number of queries logged : 14 |
504 | +DROP test in progress... |
505 | +USE Test_Drop; |
506 | +# enabling the logging_query plugin to log DROP queries |
507 | +SET GLOBAL logging_query_pcre="DROP.+"; |
508 | +# dropping an index ; this query should be logged since it is a DROP query ( though implemented through ALTER query ) |
509 | +ALTER TABLE test_drop DROP INDEX index_id; |
510 | +# dropping a table ; this query should be logged |
511 | +DROP TABLE test_drop; |
512 | +# dropping a schema ; this query should be logged |
513 | +DROP SCHEMA Test_Drop; |
514 | +# Drop test is completed. Now checking the logging_query.log file. This should print 18 |
515 | +Number of queries logged : 18 |
516 | +cleaning up... |
517 | +SET GLOBAL logging_query_enable=false; |
518 | +SET GLOBAL logging_query_pcre=".+"; |
519 | +DROP SCHEMA IF EXISTS Test_Delete; |
520 | +DROP SCHEMA IF EXISTS Test_Truncate; |
521 | +DROP SCHEMA IF EXISTS Test_Drop; |
522 | +Warnings: |
523 | +Note 1008 Can't drop schema 'Test_Drop'; schema doesn't exist |
524 | +***done*** |
525 | |
526 | === modified file 'plugin/logging_query/tests/r/file.result' |
527 | --- plugin/logging_query/tests/r/file.result 2012-07-10 18:29:14 +0000 |
528 | +++ plugin/logging_query/tests/r/file.result 2012-10-08 16:53:22 +0000 |
529 | @@ -1,23 +1,33 @@ |
530 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
531 | Log file exists |
532 | -1 |
533 | +Number of queries logged : 1 |
534 | +# Since logging_query_enable is OFF by default, this should not be logged into the log file. |
535 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
536 | Variable_name Value |
537 | logging_query_enable OFF |
538 | -logging_query_pcre |
539 | +logging_query_pcre .+ |
540 | logging_query_threshold_big_examined 0 |
541 | logging_query_threshold_big_resultset 0 |
542 | logging_query_threshold_slow 0 |
543 | -1 |
544 | +#This should not print anything |
545 | +Number of queries logged : 1 |
546 | +#Enabling logging_query plugin |
547 | SET GLOBAL logging_query_enable=true; |
548 | +#Now as logging_query_enable is set to true, this should be logged. |
549 | SELECT 1; |
550 | 1 |
551 | 1 |
552 | -3 |
553 | +#This should print the content of log file as SET GLOBAL query and SELECT query |
554 | +Number of queries logged : 3 |
555 | +#Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now. |
556 | SET GLOBAL logging_query_pcre="SHOW.+"; |
557 | +#This should not be logged |
558 | SELECT @@logging_query_enable; |
559 | @@logging_query_enable |
560 | 1 |
561 | -4 |
562 | +#This should print the content of log file updated with |
563 | +Number of queries logged : 4 |
564 | +#This should be logged |
565 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
566 | Variable_name Value |
567 | logging_query_enable ON |
568 | @@ -25,14 +35,22 @@ |
569 | logging_query_threshold_big_examined 0 |
570 | logging_query_threshold_big_resultset 0 |
571 | logging_query_threshold_slow 0 |
572 | -5 |
573 | +#This should print the content of log file updated with SHOW query as it matched the regex. |
574 | +Number of queries logged : 5 |
575 | +#Now changing the query log filename |
576 | SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query1.log"; |
577 | -1 |
578 | +#--exec if [ -f /home/sharan/Drizzle/drizzle-bug-723915/tests/var/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi |
579 | +# Clear log file. |
580 | +# Double-check that log file is clear. |
581 | +Number of queries logged : 1 |
582 | +#This should not be logged. Neither into new log file. Nor into new log file. |
583 | SELECT @@logging_query_enable; |
584 | @@logging_query_enable |
585 | 1 |
586 | -5 |
587 | -1 |
588 | +#Checking the content of both the files. |
589 | +Number of queries logged : 5 |
590 | +Number of queries logged : 1 |
591 | +#This should be logged into new log file |
592 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
593 | Variable_name Value |
594 | logging_query_enable ON |
595 | @@ -40,7 +58,14 @@ |
596 | logging_query_threshold_big_examined 0 |
597 | logging_query_threshold_big_resultset 0 |
598 | logging_query_threshold_slow 0 |
599 | -5 |
600 | -2 |
601 | +#Checking the contents of boh the log files. |
602 | +Number of queries logged : 5 |
603 | +Number of queries logged : 2 |
604 | +#Changing log file to null string. This should throw error. |
605 | SET GLOBAL logging_query_filename=""; |
606 | ERROR HY000: Incorrect arguments to SET |
607 | +cleaning up... |
608 | +SET GLOBAL logging_query_enable=false; |
609 | +SET GLOBAL logging_query_pcre="*"; |
610 | +SET GLOBAL logging_query_filename="/home/sharan/Drizzle/drizzle-bug-723915/tests/var/logging_query.log"; |
611 | +***done*** |
612 | |
613 | === added file 'plugin/logging_query/tests/r/insert.result' |
614 | --- plugin/logging_query/tests/r/insert.result 1970-01-01 00:00:00 +0000 |
615 | +++ plugin/logging_query/tests/r/insert.result 2012-10-08 16:53:22 +0000 |
616 | @@ -0,0 +1,85 @@ |
617 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
618 | +Log file exists |
619 | +Number of queries logged : 1 |
620 | +preparing the test bed... |
621 | +# The logging_query plugin is not enabled and hence the following queries should not be logged |
622 | +DROP SCHEMA IF EXISTS Test; |
623 | +CREATE SCHEMA Test; |
624 | +USE Test; |
625 | +CREATE TABLE test_info (test_id INT, test_name VARCHAR(10)); |
626 | +INSERT INTO test_info (test_id,test_name) VALUES (0,null); |
627 | +# This should print 1 indicating the log file is still empty |
628 | +Number of queries logged : 1 |
629 | + |
630 | +# Now the test begins!!! |
631 | +# Enabling the logging_query plugin |
632 | +SET GLOBAL logging_query_enable=true; |
633 | +# The following queries should be logged |
634 | +INSERT INTO test_info (test_id) VALUES (1); |
635 | +INSERT INTO test_info (test_id,test_name) VALUES (1,"create"); |
636 | +INSERT INTO test_info VALUES (2,"select"); |
637 | +SELECT * FROM test_info; |
638 | +test_id test_name |
639 | +0 NULL |
640 | +1 NULL |
641 | +1 create |
642 | +2 select |
643 | +# This should print 6 indicating that, all of the above queries are logged |
644 | +Number of queries logged : 6 |
645 | +# Enabling the logging_query plugin to log only INSERT queries |
646 | +SET GLOBAL logging_query_pcre="INSERT.+"; |
647 | +# The following INSERT query should be logged |
648 | +INSERT INTO test_info (test_id,test_name) VALUES (3,"insert"); |
649 | +INSERT INTO test_info VALUES (4,"drop"),(5,"delete"); |
650 | +SELECT test_name FROM test_info; |
651 | +test_name |
652 | +NULL |
653 | +NULL |
654 | +create |
655 | +select |
656 | +insert |
657 | +drop |
658 | +delete |
659 | +DELETE FROM test_info WHERE test_id = 0; |
660 | +SELECT * FROM test_info; |
661 | +test_id test_name |
662 | +1 NULL |
663 | +1 create |
664 | +2 select |
665 | +3 insert |
666 | +4 drop |
667 | +5 delete |
668 | +# This should print 9 indicating that, only the INSERT queries were logged |
669 | +Number of queries logged : 9 |
670 | +# Enabling the logging_query plugin to log SELECT queries |
671 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
672 | +# The following INSERT queries should NOT be logged |
673 | +INSERT INTO test_info VALUES (5,"delete"); |
674 | +SELECT test_name AS tests FROM test_info; |
675 | +tests |
676 | +NULL |
677 | +create |
678 | +select |
679 | +insert |
680 | +drop |
681 | +delete |
682 | +delete |
683 | +SELECT * FROM test_info WHERE test_id > 3; |
684 | +test_id test_name |
685 | +4 drop |
686 | +5 delete |
687 | +5 delete |
688 | +# This should print 12 indicating that, the INSERT query is NOT logged |
689 | +Number of queries logged : 12 |
690 | +# Enabling the logging_query plugin to log DELETE queries |
691 | +SET GLOBAL logging_query_pcre="DELETE.+"; |
692 | +# The following INSERT queries should NOT be logged |
693 | +INSERT INTO test_info VALUES (6,""),(7,"enums"); |
694 | +DELETE FROM test_info WHERE test_id=6 OR 7; |
695 | +# This should print 14 indicating that, the INSERT query is NOT Logged |
696 | +Number of queries logged : 14 |
697 | +cleaning up... |
698 | +SET GLOBAL logging_query_enable=false; |
699 | +SET GLOBAL logging_query_pcre=".+"; |
700 | +DROP SCHEMA Test; |
701 | +***done*** |
702 | |
703 | === added file 'plugin/logging_query/tests/r/select.result' |
704 | --- plugin/logging_query/tests/r/select.result 1970-01-01 00:00:00 +0000 |
705 | +++ plugin/logging_query/tests/r/select.result 2012-10-08 16:53:22 +0000 |
706 | @@ -0,0 +1,130 @@ |
707 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
708 | +Log file exists |
709 | +Number of queries logged : 1 |
710 | +Preparing the test bed... |
711 | +CREATE SCHEMA Select_Test; |
712 | +USE Select_Test; |
713 | +CREATE TABLE select_test_1 (id INT, type CHAR(20)); |
714 | +INSERT INTO select_test_1 VALUES (1,"basic select"),(2,"select distinct"),(3,"select with where"),(4,"select with orderby"); |
715 | +CREATE TABLE select_test_2 (id INT, time FLOAT); |
716 | +INSERT INTO select_test_2 VALUES (1,10.01),(2,9.38),(3,5.6),(4,6.7); |
717 | +prepare phase completed... |
718 | + |
719 | +Testing basic select queries. |
720 | +# The logging_query is not enabled and hence the following select queries should not be logged |
721 | +SELECT 1; |
722 | +1 |
723 | +1 |
724 | +SELECT "logging_query"; |
725 | +logging_query |
726 | +logging_query |
727 | +# This should print 1 to indicate the log file is still empty |
728 | +Number of queries logged : 1 |
729 | + |
730 | +# Enabling the logging_query plugin |
731 | +SET GLOBAL logging_query_enable=true; |
732 | + |
733 | +# The logging_query is enabled and the following select query should be logged |
734 | +SELECT 1; |
735 | +1 |
736 | +1 |
737 | +# This should print 3 indicating that the above query is logged |
738 | +Number of queries logged : 3 |
739 | +# Issuing another select query |
740 | +SELECT "hello world"; |
741 | +hello world |
742 | +hello world |
743 | +# This should print 4 indicating that the above query is logged |
744 | +Number of queries logged : 4 |
745 | + |
746 | +# Enabling the logging_query to log only SHOW queries |
747 | +SET GLOBAL logging_query_pcre="SHOW.+"; |
748 | + |
749 | +# The following query should be logged |
750 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
751 | +Variable_name Value |
752 | +logging_query_enable ON |
753 | +logging_query_pcre SHOW.+ |
754 | +logging_query_threshold_big_examined 0 |
755 | +logging_query_threshold_big_resultset 0 |
756 | +logging_query_threshold_slow 0 |
757 | +# This should print 6 indicating that the above query is logged |
758 | +Number of queries logged : 6 |
759 | + |
760 | +# The following select query should not be logged |
761 | +SELECT 1; |
762 | +1 |
763 | +1 |
764 | +# This should print 4 indicating that the above query is not logged |
765 | +Number of queries logged : 6 |
766 | +# Basic test completed... |
767 | + |
768 | +drilling the SELECT queries test. |
769 | +# Enabling the logging_query plugin to log SELECT queries |
770 | +# ( since here after, the test deals with variants of SELECT queries and all such should be checked against logging) |
771 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
772 | + |
773 | +# Testing for select with distinct |
774 | +# The following queries should be logged |
775 | +SELECT DISTINCT * FROM select_test_1; |
776 | +id type |
777 | +1 basic select |
778 | +2 select distinct |
779 | +3 select with where |
780 | +4 select with orderby |
781 | +SELECT DISTINCT * FROM select_test_2; |
782 | +id time |
783 | +1 10.01 |
784 | +2 9.38 |
785 | +3 5.6 |
786 | +4 6.7 |
787 | +# This should print 9 indicating that the above queries are logged |
788 | +Number of queries logged : 9 |
789 | + |
790 | +# Testing for select with where |
791 | +# The following queries should be logged |
792 | +SELECT * FROM select_test_1 WHERE id = 2; |
793 | +id type |
794 | +2 select distinct |
795 | +SELECT * FROM select_test_1 WHERE type = "select with where"; |
796 | +id type |
797 | +3 select with where |
798 | +SELECT time FROM select_test_2 WHERE id >= 2; |
799 | +time |
800 | +9.38 |
801 | +5.6 |
802 | +6.7 |
803 | +SELECT id FROM select_test_2 WHERE time < 6; |
804 | +id |
805 | +3 |
806 | +# This should print 13 indicating that the above queries are logged |
807 | +Number of queries logged : 13 |
808 | + |
809 | +# Testing for select with order by |
810 | +# The following queries should be logged |
811 | +SELECT * FROM select_test_2 ORDER BY id DESC; |
812 | +id time |
813 | +4 6.7 |
814 | +3 5.6 |
815 | +2 9.38 |
816 | +1 10.01 |
817 | +SELECT time FROM select_test_2 ORDER BY time; |
818 | +time |
819 | +5.6 |
820 | +6.7 |
821 | +9.38 |
822 | +10.01 |
823 | +SELECT id FROM select_test_2 ORDER BY time DESC; |
824 | +id |
825 | +1 |
826 | +2 |
827 | +4 |
828 | +3 |
829 | +# This should print 16 indicating all the above queries are logged |
830 | +Number of queries logged : 16 |
831 | + |
832 | +cleaning up... |
833 | +DROP SCHEMA Select_Test; |
834 | +SET GLOBAL logging_query_enable=false; |
835 | +SET GLOBAL logging_query_pcre=".+"; |
836 | +***done*** |
837 | |
838 | === modified file 'plugin/logging_query/tests/r/thresholds.result' |
839 | --- plugin/logging_query/tests/r/thresholds.result 2012-07-10 18:29:14 +0000 |
840 | +++ plugin/logging_query/tests/r/thresholds.result 2012-10-08 16:53:22 +0000 |
841 | @@ -14,16 +14,16 @@ |
842 | SELECT SLEEP(0.4); |
843 | SLEEP(0.4) |
844 | 0 |
845 | -1 |
846 | +Number of queries logged : 1 |
847 | SELECT SLEEP(0.5); |
848 | SLEEP(0.5) |
849 | 0 |
850 | -2 |
851 | +Number of queries logged : 2 |
852 | SET GLOBAL logging_query_threshold_slow=0; |
853 | SELECT SLEEP(1); |
854 | SLEEP(1) |
855 | 0 |
856 | -4 |
857 | +Number of queries logged : 4 |
858 | |
859 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
860 | Variable_name Value |
861 | @@ -32,12 +32,12 @@ |
862 | logging_query_threshold_big_examined 0 |
863 | logging_query_threshold_big_resultset 0 |
864 | logging_query_threshold_slow 0 |
865 | -2 |
866 | +Number of queries logged : 2 |
867 | SET GLOBAL logging_query_threshold_big_resultset=2; |
868 | SELECT "This should not be logged"; |
869 | This should not be logged |
870 | This should not be logged |
871 | -2 |
872 | +Number of queries logged : 2 |
873 | |
874 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
875 | Variable_name Value |
876 | @@ -46,9 +46,13 @@ |
877 | logging_query_threshold_big_examined 0 |
878 | logging_query_threshold_big_resultset 2 |
879 | logging_query_threshold_slow 0 |
880 | -2 |
881 | +Number of queries logged : 2 |
882 | SET GLOBAL logging_query_threshold_big_examined=2; |
883 | SELECT "This should not be logged"; |
884 | This should not be logged |
885 | This should not be logged |
886 | -2 |
887 | +Number of queries logged : 2 |
888 | +cleaning up... |
889 | +SET GLOBAL logging_query_enable=false; |
890 | +SET GLOBAL logging_query_pcre=".+"; |
891 | +***done*** |
892 | |
893 | === added file 'plugin/logging_query/tests/r/update.result' |
894 | --- plugin/logging_query/tests/r/update.result 1970-01-01 00:00:00 +0000 |
895 | +++ plugin/logging_query/tests/r/update.result 2012-10-08 16:53:22 +0000 |
896 | @@ -0,0 +1,62 @@ |
897 | +SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log"; |
898 | +Log file exists |
899 | +Number of queries logged : 1 |
900 | +preparing the test bed... |
901 | +# The logging_query plugin is not enabled and hence none of the queries in prepare phase should be logged |
902 | +CREATE SCHEMA Test_Update; |
903 | +USE Test_Update; |
904 | +CREATE TABLE test_info (id INT, name CHAR(10)); |
905 | +INSERT INTO test_info VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
906 | +# This should print 1 indicating that the log file is still empty |
907 | +Number of queries logged : 1 |
908 | + |
909 | +UPDATE test in progress... |
910 | +# The logging_query plugin is not enabled and the following update query should not be logged |
911 | +UPDATE test_info SET name="CREATE" WHERE id=1; |
912 | +# This should print 1 indicating that the log file is still empty |
913 | +Number of queries logged : 1 |
914 | + |
915 | +# Enabling the logging_query plugin |
916 | +SET GLOBAL logging_query_enable=true; |
917 | + |
918 | +# The logging_query plugin is enabled and the following update query should be logged |
919 | +UPDATE test_info SET name="SELECT" WHERE id=2; |
920 | +# This should print 3 indicating that the above query is logged |
921 | +Number of queries logged : 1 |
922 | + |
923 | +# Enabling the logging_query plugin to log only select queries |
924 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
925 | + |
926 | +# The following UPDATE query should not be logged |
927 | +UPDATE test_info SET name="INSERT" WHERE id=3; |
928 | +SELECT * FROM test_info; |
929 | +id name |
930 | +1 CREATE |
931 | +2 SELECT |
932 | +3 INSERT |
933 | +4 update |
934 | +5 delete |
935 | +# This should print 5 indicating that, only the UPDATE query is NOT logged |
936 | +Number of queries logged : 2 |
937 | + |
938 | +# Enabling the logging_query plugin to log UPDATE queries |
939 | +SET GLOBAL logging_query_pcre="UPDATE.+"; |
940 | + |
941 | +# The followihng UPDATE query should be logged |
942 | +UPDATE test_info SET name="UPDATE" WHERE id=6; |
943 | +# The above query will not update the table since a tuple with id=6 does not exist |
944 | +SELECT * FROM test_info; |
945 | +id name |
946 | +1 CREATE |
947 | +2 SELECT |
948 | +3 INSERT |
949 | +4 update |
950 | +5 delete |
951 | +# This should print 7 indicating that, only the UPDATE query is logged and not the select query |
952 | +Number of queries logged : 2 |
953 | + |
954 | +cleaning up... |
955 | +SET GLOBAL logging_query_enable=false; |
956 | +SET GLOBAL logging_query_pcre=".+"; |
957 | +DROP SCHEMA Test_Update; |
958 | +***done*** |
959 | |
960 | === added file 'plugin/logging_query/tests/t/blob.test' |
961 | --- plugin/logging_query/tests/t/blob.test 1970-01-01 00:00:00 +0000 |
962 | +++ plugin/logging_query/tests/t/blob.test 2012-10-08 16:53:22 +0000 |
963 | @@ -0,0 +1,84 @@ |
964 | + |
965 | +# ########################################################################################### |
966 | +# This test runs several tests against the BLOB type |
967 | +# ########################################################################################### |
968 | + |
969 | +# logging_query plugin is loaded into the system. This is to check that the file passed through the command line is opened or not |
970 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
971 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
972 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "log file does not exist"; fi |
973 | + |
974 | +# Clearing the log file |
975 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
976 | +# Checking if the file is cleared or not |
977 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
978 | +# The above command should print 1 indicating that the log file is empty |
979 | + |
980 | +--echo # The logging_query plugin is not enabled and hence none of the following queries should be logged |
981 | +DROP SCHEMA IF EXISTS Blob_Test; |
982 | +CREATE SCHEMA Blob_Test; |
983 | +USE Blob_Test; |
984 | +CREATE TABLE test_blob (data BLOB); |
985 | + |
986 | +--echo # Enabling the logging_query plugin |
987 | +SET GLOBAL logging_query_enable=true; |
988 | + |
989 | +# ########################################################################################### |
990 | +# Insert BLOB data |
991 | +# ########################################################################################### |
992 | + |
993 | +--echo Inserting blob data |
994 | +INSERT INTO test_blob VALUES (null); |
995 | +INSERT INTO test_blob VALUES (""); |
996 | +INSERT INTO test_blob VALUES ("A"); |
997 | +INSERT INTO test_blob VALUES ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
998 | +INSERT INTO test_blob VALUES ("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"); |
999 | + |
1000 | +# Testing if the above queries are logged |
1001 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1002 | + |
1003 | + |
1004 | +# ########################################################################################### |
1005 | +# Select BLOB data |
1006 | +# ########################################################################################### |
1007 | + |
1008 | +--echo Selecting blob data |
1009 | +SELECT data FROM test_blob WHERE data LIKE null; |
1010 | +SELECT data FROM test_blob WHERE data LIKE ""; |
1011 | +SELECT data FROM test_blob WHERE data LIKE "A"; |
1012 | +SELECT data FROM test_blob WHERE LENGTH(data) < 100; |
1013 | +SELECT data FROM test_blob WHERE LENGTH(data) > 1024; |
1014 | + |
1015 | + |
1016 | +# Testing if the above queries are logged |
1017 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1018 | + |
1019 | + |
1020 | +# ########################################################################################### |
1021 | +# Deleting BLOB data |
1022 | +# ########################################################################################### |
1023 | + |
1024 | +--echo Deleting blob data |
1025 | +DELETE FROM test_blob WHERE data LIKE null; |
1026 | +DELETE FROM test_blob WHERE LENGTH(data) > 1000; |
1027 | +DELETE FROM test_blob WHERE data = 'A'; |
1028 | + |
1029 | + |
1030 | +# Testing if the above queries are logged |
1031 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1032 | + |
1033 | + |
1034 | + |
1035 | +# #################################################################################################### |
1036 | +# Cleaning up |
1037 | +# #################################################################################################### |
1038 | +--echo cleaning up... |
1039 | +SET GLOBAL logging_query_enable=false; |
1040 | +DROP SCHEMA Blob_Test; |
1041 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1042 | +--echo ***done*** |
1043 | + |
1044 | +# #################################################################################################### |
1045 | +# Done |
1046 | +# #################################################################################################### |
1047 | + |
1048 | |
1049 | === added file 'plugin/logging_query/tests/t/create.test' |
1050 | --- plugin/logging_query/tests/t/create.test 1970-01-01 00:00:00 +0000 |
1051 | +++ plugin/logging_query/tests/t/create.test 2012-10-08 16:53:22 +0000 |
1052 | @@ -0,0 +1,80 @@ |
1053 | + |
1054 | +# ################################################################################## |
1055 | +# This tests the logging_query plugin for various create queries |
1056 | +# ################################################################################## |
1057 | + |
1058 | +--echo # Logging query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not |
1059 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1060 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1061 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1062 | + |
1063 | +--echo # Clearing the log file |
1064 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1065 | +--echo # Checking if the log file is cleared |
1066 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1067 | +--echo # The above command should print 1 indicating that the file is empty |
1068 | +--echo # Preparation phase completed |
1069 | +--echo |
1070 | + |
1071 | +--echo # Starting the test |
1072 | +--echo # The logging_query is not enabled and hence the following query should not be logged |
1073 | +DROP SCHEMA IF EXISTS test; |
1074 | +CREATE SCHEMA test; |
1075 | +--echo # This should print 1 to indicate the log file is still empty |
1076 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1077 | + |
1078 | +--echo # Enabling the logging_query plugin |
1079 | +SET GLOBAL logging_query_enable=true; |
1080 | + |
1081 | +--echo # The following queries should be logged |
1082 | +DROP SCHEMA IF EXISTS test_db; |
1083 | +CREATE SCHEMA test_db; |
1084 | +USE test_db; |
1085 | +--echo # This should print 6 indicating that the above queries are logged |
1086 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1087 | + |
1088 | +--echo # Issuing another CREATE query. This should be logged |
1089 | +CREATE TABLE Test_Entries (test_id INT, test_name VARCHAR(10)); |
1090 | +--echo # This should print 7 to indicate that the above query is logged |
1091 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1092 | + |
1093 | +--echo # Enabling logging_query pluging for only SELECT queries |
1094 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
1095 | + |
1096 | +--echo # The following CREATE query should not be logged |
1097 | +CREATE TABLE Test_Entries_2 (test_id INT, test_name VARCHAR(10)); |
1098 | +--echo # This should print 8 to indicate that the above query is not logged |
1099 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1100 | +--echo # The following SELECT query should be logged |
1101 | +SELECT * FROM Test_Entries_2; |
1102 | +--echo # This should print 9 to indicate that the above query is logged |
1103 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1104 | + |
1105 | +--echo # Enabling logging_query plugin for only CREATE queries |
1106 | +SET GLOBAL logging_query_pcre="CREATE.+"; |
1107 | + |
1108 | +--echo # The following CREATE query should be logged |
1109 | +DROP SCHEMA IF EXISTS test_db_2; |
1110 | +CREATE SCHEMA test_db_2; |
1111 | +--echo # This should print 11 |
1112 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1113 | +--echo # The following SELECT query should not be logged |
1114 | +SELECT * FROM Test_Entries_2; |
1115 | +--echo # This should print 11 indicating that the above query is not logged |
1116 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1117 | + |
1118 | +# ################################################################################### |
1119 | +# Clean up |
1120 | +# ################################################################################### |
1121 | +--echo cleaning up... |
1122 | +DROP SCHEMA test; |
1123 | +DROP SCHEMA test_db; |
1124 | +DROP SCHEMA test_db_2; |
1125 | +SET GLOBAL logging_query_enable=false; |
1126 | +SET GLOBAL logging_query_pcre=".+"; |
1127 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1128 | +--echo ***done*** |
1129 | + |
1130 | +# ################################################################################### |
1131 | +# Done |
1132 | +# ################################################################################### |
1133 | |
1134 | === added file 'plugin/logging_query/tests/t/datatypes_datetime.test' |
1135 | --- plugin/logging_query/tests/t/datatypes_datetime.test 1970-01-01 00:00:00 +0000 |
1136 | +++ plugin/logging_query/tests/t/datatypes_datetime.test 2012-10-08 16:53:22 +0000 |
1137 | @@ -0,0 +1,151 @@ |
1138 | + |
1139 | +# ############################################################################################################################################## |
1140 | +# Test for Drizzle's datatypes |
1141 | +# Test whether the logging_query plugin logs each case of the datatype (we enable the plugin throughout the test and check if it logs each case) |
1142 | +# cases: |
1143 | +# 1.Type |
1144 | +# 2.Range |
1145 | +# 3.Select, Insert, Delete queries |
1146 | +# ############################################################################################################################################## |
1147 | + |
1148 | +# logging_query plugin is loaded into the system and this checks if the file we passed through the command line is opened or not |
1149 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1150 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1151 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1152 | + |
1153 | +# Clearing the log file |
1154 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1155 | +# Checking if the file is cleared or not |
1156 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1157 | +# The above command should print 1 indicating that the log file is empty |
1158 | + |
1159 | +# ################################################################################################### |
1160 | +# Preparing the test bed |
1161 | +# ################################################################################################### |
1162 | + |
1163 | +--echo # logging_query plugin is not enabled and hence none of the following queries should be logged |
1164 | +DROP SCHEMA IF EXISTS Test; |
1165 | +CREATE SCHEMA Test; |
1166 | +USE Test; |
1167 | + |
1168 | +--echo # Enabling the logging_query plugin |
1169 | +SET GLOBAL logging_query_enable=true; |
1170 | + |
1171 | +# ################################################################################################### |
1172 | +# DATE |
1173 | +# ################################################################################################### |
1174 | + |
1175 | +--echo #DATE |
1176 | +CREATE TABLE test_date (type DATE); |
1177 | +--echo # Inserting a record with DATE value within the range |
1178 | +INSERT INTO test_date VALUES ('1990-01-01'); |
1179 | +INSERT INTO test_date VALUES ('2012-01-01'); |
1180 | +--echo # Inserting a record with DATE value on range border |
1181 | +INSERT INTO test_date VALUES ('0001-01-01'); |
1182 | +INSERT INTO test_date VALUES ('9999-12-31'); |
1183 | +--echo # Selecting the record |
1184 | +SELECT type FROM test_date WHERE (EXTRACT(year FROM type) == 1990); |
1185 | +SELECT type FROM test_date WHERE (EXTRACT(month FROM type) == 01); |
1186 | +SELECT type FROM test_date WHERE (EXTRACT(day FROM type) == 31); |
1187 | +--echo # Deleting the record |
1188 | +DELETE FROM test_date WHERE (EXTRACT(year FROM type) == 0001); |
1189 | +DELETE FROM test_date WHERE (EXTRACT(month FROM type) == 01); |
1190 | +DELETE FROM test_date WHERE (EXTRACT(day FROM type) == 31); |
1191 | +--echo # Selecting the record ; this should return a NULL set |
1192 | +SELECT * FROM test_date; |
1193 | + |
1194 | +# Testing if the above queries are logged |
1195 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1196 | + |
1197 | + |
1198 | +# #################################################################################################### |
1199 | +# TIME |
1200 | +# #################################################################################################### |
1201 | + |
1202 | +--echo #TIME |
1203 | +CREATE TABLE test_time (type TIME); |
1204 | +--echo # Inserting a record with TIME value within the range |
1205 | +INSERT INTO test_time VALUES ('09:00:00'); |
1206 | +INSERT INTO test_time VALUES ('15:00:00'); |
1207 | +--echo # Inserting a record with TIME value on range border |
1208 | +INSERT INTO test_time VALUES ('00:00:00'); |
1209 | +INSERT INTO test_time VALUES ('23:59:59'); |
1210 | +--echo # Selecting the record |
1211 | +SELECT type FROM test_time WHERE (HOUR(type) == 09); |
1212 | +SELECT type FROM test_time WHERE (MINUTE(type) == 00); |
1213 | +SELECT type FROM test_time WHERE (SECOND(type) == 59); |
1214 | +--echo # Deleting the record |
1215 | +DELETE FROM test_time WHERE (HOUR(type) == 09); |
1216 | +DELETE FROM test_time WHERE (MINUTE(type) == 00); |
1217 | +DELETE FROM test_time WHERE (SECOND(type) == 59); |
1218 | +--echo # Selecting the record ; this should return a NULL set |
1219 | +SELECT * FROM test_time; |
1220 | + |
1221 | +# Testing if the above queries are logged |
1222 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1223 | + |
1224 | + |
1225 | +# #################################################################################################### |
1226 | +# DATETIME |
1227 | +# #################################################################################################### |
1228 | + |
1229 | +--echo #DATETIME |
1230 | +CREATE TABLE test_datetime (type DATETIME); |
1231 | +--echo # Inserting a record with DATETIME value within the range |
1232 | +INSERT INTO test_datetime VALUES ('1992-07-22 07:50:30'); |
1233 | +INSERT INTO test_datetime VALUES ('2012-09-29 20:49:50'); |
1234 | +--echo # Insertingt a record with DATETIME value on range border |
1235 | +INSERT INTO test_datetime VALUES ('0001-01-01 00:00:00'); |
1236 | +INSERT INTO test_datetime VALUES ('9999-12-31 23:59:59'); |
1237 | +--echo # Selecting the record |
1238 | +SELECT type FROM test_datetime WHERE (EXTRACT(year FROM type) == 1992); |
1239 | +SELECT type FROM test_datetime WHERE (HOUR(type) == 07); |
1240 | +--echo # Deleting the record |
1241 | +DELETE FROM test_datetime WHERE (EXTRACT(year FROM type) == 2012); |
1242 | +DELETE FROM test_datetime WHERE (MINUTE(type) == 50); |
1243 | +--echo # Selecting the records ; this should return 2 records |
1244 | +SELECT * FROM test_datetime; |
1245 | + |
1246 | + |
1247 | +# Testing if the above queries are logged |
1248 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1249 | + |
1250 | + |
1251 | +# #################################################################################################### |
1252 | +# TIMESTAMP(6) |
1253 | +# #################################################################################################### |
1254 | + |
1255 | +--echo #TIMESTAMP(6) |
1256 | +CREATE TABLE test_timestamp (type TIMESTAMP(6)); |
1257 | +--echo # Inserting a record with TIMESTAMP value within the range |
1258 | +INSERT INTO test_timestamp VALUES ('1992-07-22 07:50:23.324543'); |
1259 | +INSERT INTO test_timestamp VALUES ('2012-09-29 23:12:20.232109'); |
1260 | +--echo # Inserting a record with TIMESTAMP value on range border |
1261 | +INSERT INTO test_timestamp VALUES ('1970-01-01 00:00:01.000000'); |
1262 | +INSERT INTO test_timestamp VALUES ('2038-01-19 03:14:07.999999'); |
1263 | +--echo # Selecting the record |
1264 | +SELECT type FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1970); |
1265 | +SELECT type FROM test_timestamp WHERE (HOUR(type) == 03); |
1266 | +--echo # Deleting the record |
1267 | +DELETE FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1992); |
1268 | +DELETE FROM test_timestamp WHERE (MINUTE(type) == 12); |
1269 | +--echo # Selecting the records ; this should return 2 records |
1270 | +SELECT * FROM test_timestamp; |
1271 | + |
1272 | + |
1273 | +# Testing if the above queries are logged |
1274 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1275 | + |
1276 | + |
1277 | +# #################################################################################################### |
1278 | +# Cleaning up |
1279 | +# #################################################################################################### |
1280 | +--echo cleaning up... |
1281 | +SET GLOBAL logging_query_enable=false; |
1282 | +DROP SCHEMA Test; |
1283 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1284 | +--echo ***done*** |
1285 | + |
1286 | +# #################################################################################################### |
1287 | +# Done |
1288 | +# #################################################################################################### |
1289 | |
1290 | === added file 'plugin/logging_query/tests/t/datatypes_numeric.test' |
1291 | --- plugin/logging_query/tests/t/datatypes_numeric.test 1970-01-01 00:00:00 +0000 |
1292 | +++ plugin/logging_query/tests/t/datatypes_numeric.test 2012-10-08 16:53:22 +0000 |
1293 | @@ -0,0 +1,126 @@ |
1294 | + |
1295 | +# ############################################################################################################################################## |
1296 | +# Test for Drizzle's datatypes |
1297 | +# Test whether the logging_query plugin logs each case of the datatype (we enable the plugin throughout the test and check if it logs each case) |
1298 | +# cases: |
1299 | +# 1.Type |
1300 | +# 2.Range |
1301 | +# 3.Select, Insert, Delete queries |
1302 | +# ############################################################################################################################################## |
1303 | + |
1304 | +# logging_query plugin is loaded into the system and this checks if the file we passed through the command line is opened or not |
1305 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1306 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1307 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1308 | + |
1309 | +# Clearing the log file |
1310 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1311 | +# Checking if the file is cleared or not |
1312 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1313 | +# The above command should print 1 indicating that the log file is empty |
1314 | + |
1315 | +# ################################################################################################### |
1316 | +# Preparing the test bed |
1317 | +# ################################################################################################### |
1318 | + |
1319 | +--echo # logging_query plugin is not enabled and hence none of the following queries should be logged |
1320 | +DROP SCHEMA IF EXISTS Test; |
1321 | +CREATE SCHEMA Test; |
1322 | +USE Test; |
1323 | + |
1324 | +--echo # Enabling the logging_query plugin |
1325 | +SET GLOBAL logging_query_enable=true; |
1326 | + |
1327 | +# #################################################################################################### |
1328 | +# INTEGER |
1329 | +# #################################################################################################### |
1330 | + |
1331 | +--echo #INTEGER |
1332 | +CREATE TABLE test_integer (type INTEGER); |
1333 | +--echo # Inserting a record with INTEGER value within range |
1334 | +INSERT INTO test_integer VALUES (2147483645); |
1335 | +INSERT INTO test_integer VALUES (-2147483645); |
1336 | +--echo # Inserting a record with INTEGER value on range borders |
1337 | +INSERT INTO test_integer VALUES (2147483647); |
1338 | +INSERT INTO test_integer VALUES (-2147483648); |
1339 | +--echo # Selecting the record from table |
1340 | +SELECT type FROM test_integer WHERE type > 0; |
1341 | +SELECT type FROM test_integer WHERE type < 0; |
1342 | +--echo # Deleting a record from table |
1343 | +DELETE FROM test_integer WHERE type > 0; |
1344 | +--echo # This SELECT should return only two records |
1345 | +SELECT * FROM test_integer; |
1346 | +--echo # Deleting a record from table |
1347 | +DELETE FROM test_integer WHERE type < 0; |
1348 | +--echo # This SELECT should return a NULL set |
1349 | +SELECT * FROM test_integer; |
1350 | + |
1351 | +# Testing if the above queries are logged |
1352 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1353 | + |
1354 | + |
1355 | +# #################################################################################################### |
1356 | +# BIGINT |
1357 | +# #################################################################################################### |
1358 | + |
1359 | +--echo #BIGINT |
1360 | +CREATE TABLE test_bigint (type BIGINT); |
1361 | +--echo # Inserting a record with BIGINT value within range |
1362 | +INSERT INTO test_bigint VALUES (9223372036854775805); |
1363 | +INSERT INTO test_bigint VALUES (-9223372036854775805); |
1364 | +--echo # Inserting a record with BIGINT value on range borders |
1365 | +INSERT INTO test_bigint VALUES (9223372036854775807); |
1366 | +INSERT INTO test_bigint VALUES (-9223372036854775808); |
1367 | +--echo # Selecting the record from table |
1368 | +SELECT type FROM test_bigint WHERE type > 0; |
1369 | +SELECT type FROM test_bigint WHERE type < 0; |
1370 | +--echo # Deleting a record from table |
1371 | +DELETE FROM test_bigint WHERE type > 0; |
1372 | +--echo # This SELECT should return only two records |
1373 | +SELECT * FROM test_bigint; |
1374 | +--echo # Deleting a record from table |
1375 | +DELETE FROM test_bigint WHERE type < 0; |
1376 | +--echo # This SELECT should return a NULL set |
1377 | +SELECT * FROM test_bigint; |
1378 | + |
1379 | +# Testing if the above queries are logged |
1380 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1381 | + |
1382 | + |
1383 | +# #################################################################################################### |
1384 | +# DOUBLE |
1385 | +# #################################################################################################### |
1386 | + |
1387 | +--echo #DOUBLE |
1388 | +CREATE TABLE test_double (type DOUBLE); |
1389 | +--echo #Inserting a record with DOUBLE value within range |
1390 | +INSERT INTO test_double VALUES (-1.7976931348623155E+308); |
1391 | +INSERT INTO test_double VALUES (1.7976931348623157E+308); |
1392 | +--echo # Selecting the record from table |
1393 | +SELECT type FROM test_double WHERE type > 0; |
1394 | +SELECT type FROM test_double WHERE type < 0; |
1395 | +--echo # Deleting a record from table |
1396 | +DELETE FROM test_double WHERE type > 0; |
1397 | +--echo # This SELECT should return only one record |
1398 | +SELECT * FROM test_double; |
1399 | +--echo # Deleting a record from table |
1400 | +DELETE FROM test_double WHERE type < 0; |
1401 | +--echo # This SELECT should return a NULL set |
1402 | +SELECT * FROM test_double; |
1403 | + |
1404 | +# Testing if the above queries are logged |
1405 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1406 | + |
1407 | + |
1408 | +# #################################################################################################### |
1409 | +# Cleaning up |
1410 | +# #################################################################################################### |
1411 | +--echo cleaning up... |
1412 | +SET GLOBAL logging_query_enable=false; |
1413 | +DROP SCHEMA Test; |
1414 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1415 | +--echo ***done*** |
1416 | + |
1417 | +# #################################################################################################### |
1418 | +# Done |
1419 | +# #################################################################################################### |
1420 | |
1421 | === added file 'plugin/logging_query/tests/t/datatypes_string.test' |
1422 | --- plugin/logging_query/tests/t/datatypes_string.test 1970-01-01 00:00:00 +0000 |
1423 | +++ plugin/logging_query/tests/t/datatypes_string.test 2012-10-08 16:53:22 +0000 |
1424 | @@ -0,0 +1,111 @@ |
1425 | + |
1426 | +# ############################################################################################################################################## |
1427 | +# Test for Drizzle's datatypes |
1428 | +# Test whether the logging_query plugin logs each case of the datatype (we enable the plugin throughout the test and check if it logs each case) |
1429 | +# cases: |
1430 | +# 1.Type |
1431 | +# 2.Range |
1432 | +# 3.Select, Insert, Delete queries |
1433 | +# ############################################################################################################################################## |
1434 | + |
1435 | +# logging_query plugin is loaded into the system and this checks if the file we passed through the command line is opened or not |
1436 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1437 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1438 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1439 | + |
1440 | +# Clearing the log file |
1441 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1442 | +# Checking if the file is cleared or not |
1443 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1444 | +# The above command should print 1 indicating that the log file is empty |
1445 | + |
1446 | +# ################################################################################################### |
1447 | +# Preparing the test bed |
1448 | +# ################################################################################################### |
1449 | + |
1450 | +--echo # logging_query plugin is not enabled and hence none of the following queries should be logged |
1451 | +DROP SCHEMA IF EXISTS Test; |
1452 | +CREATE SCHEMA Test; |
1453 | +USE Test; |
1454 | + |
1455 | +--echo # Enabling the logging_query plugin |
1456 | +SET GLOBAL logging_query_enable=true; |
1457 | + |
1458 | +# ################################################################################################### |
1459 | +# VARCHAR |
1460 | +# ################################################################################################### |
1461 | + |
1462 | +--echo #VARCHAR |
1463 | +CREATE TABLE test_varchar (type VARCHAR(10)); |
1464 | +--echo # Inserting a record with VARCHAR length within range |
1465 | +INSERT INTO test_varchar VALUES ('varchar'); |
1466 | +INSERT INTO test_varchar VALUES ('sql'); |
1467 | +--echo # Inserting a record with VARCHAR length on range borders |
1468 | +INSERT INTO test_varchar VALUES ('drizzle-DB'); |
1469 | +INSERT INTO test_varchar VALUES (''); |
1470 | +--echo # Selecting records from table |
1471 | +SELECT type FROM test_varchar WHERE LENGTH(type) = 3; |
1472 | +SELECT type FROM test_varchar WHERE LENGTH(type) = 0; |
1473 | +--echo # Deleting records |
1474 | +DELETE FROM test_varchar WHERE type LIKE REVERSE('rahcrav'); |
1475 | +DELETE FROM test_varchar WHERE type LIKE SUBSTRING('mysql',3); |
1476 | +--echo # Selecting records from table ; this should return 2 rows |
1477 | +SELECT * FROM test_varchar; |
1478 | + |
1479 | + |
1480 | +# Testing if the above queries are logged |
1481 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1482 | + |
1483 | + |
1484 | + |
1485 | +# #################################################################################################### |
1486 | +# ENUM |
1487 | +# #################################################################################################### |
1488 | + |
1489 | +--echo #ENUM |
1490 | +CREATE TABLE test_enum (type ENUM('one','two','three','four','five','six','seven','eight','nine','ten')); |
1491 | +--echo # Inserting a record with ENUM value within range |
1492 | +INSERT INTO test_enum VALUES (3); |
1493 | +INSERT INTO test_enum VALUES (7); |
1494 | +--echo # Inserting a record with ENUM value on range border |
1495 | +INSERT INTO test_enum VALUES (1); |
1496 | +INSERT INTO test_enum VALUES (9); |
1497 | +--echo # Selecting records from table |
1498 | +SELECT type FROM test_enum WHERE type > 5; |
1499 | +SELECT type FROM test_enum WHERE type < 5; |
1500 | +--echo # Deleting records |
1501 | +DELETE FROM test_enum WHERE type = 9; |
1502 | +DELETE FROM test_enum WHERE type > 1; |
1503 | +--echo # Selecting records from table ; this should return 1 row |
1504 | +SELECT * FROM test_enum; |
1505 | + |
1506 | + |
1507 | +# Testing if the above queries are logged |
1508 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1509 | + |
1510 | + |
1511 | + |
1512 | +# #################################################################################################### |
1513 | +# Cleaning up |
1514 | +# #################################################################################################### |
1515 | +--echo cleaning up... |
1516 | +SET GLOBAL logging_query_enable=false; |
1517 | +DROP SCHEMA Test; |
1518 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1519 | +--echo ***done*** |
1520 | + |
1521 | +# #################################################################################################### |
1522 | +# Done |
1523 | +# #################################################################################################### |
1524 | + |
1525 | + |
1526 | + |
1527 | + |
1528 | + |
1529 | + |
1530 | + |
1531 | + |
1532 | + |
1533 | + |
1534 | + |
1535 | + |
1536 | |
1537 | === added file 'plugin/logging_query/tests/t/delete.test' |
1538 | --- plugin/logging_query/tests/t/delete.test 1970-01-01 00:00:00 +0000 |
1539 | +++ plugin/logging_query/tests/t/delete.test 2012-10-08 16:53:22 +0000 |
1540 | @@ -0,0 +1,152 @@ |
1541 | + |
1542 | +# ############################################################################################# |
1543 | +# This tests the logging_query plugin for delete, truncate and drop statements |
1544 | +# ############################################################################################# |
1545 | + |
1546 | +# logging_query plugin is loaded into the system. This checks if the file passed through the command line argument is opened or not |
1547 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1548 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1549 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1550 | + |
1551 | +# Clearing the log file |
1552 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1553 | +# Checking if the log file is cleared |
1554 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1555 | +# The above command should print 1 indicating the log file is empty |
1556 | + |
1557 | +# ############################################################################################# |
1558 | +# Preparing the test bed |
1559 | +# ############################################################################################# |
1560 | +--echo Preparing the test bed... |
1561 | + |
1562 | +--echo # The logging_query plugin is not yet enabled and hence none of the queries in the prepare phase should be logged |
1563 | +DROP SCHEMA IF EXISTS Test_Delete; |
1564 | +CREATE SCHEMA Test_Delete; |
1565 | +DROP SCHEMA IF EXISTS Test_Truncate; |
1566 | +CREATE SCHEMA Test_Truncate; |
1567 | +DROP SCHEMA IF EXISTS Test_Drop; |
1568 | +CREATE SCHEMA Test_Drop; |
1569 | +--echo # Preparing test bed for DELETE test |
1570 | +USE Test_Delete; |
1571 | +CREATE TABLE test_delete_1 ( test_id INT, test_name CHAR(10) ); |
1572 | +INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
1573 | +CREATE TABLE test_delete_2 ( test_id INT, test_name VARCHAR(10) ); |
1574 | +INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
1575 | +--echo # Preparing test bed for TRUNCATE test |
1576 | +USE Test_Truncate; |
1577 | +CREATE TABLE test_truncate_1 ( test_id INT, test_name CHAR(10) ); |
1578 | +INSERT INTO test_truncate_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
1579 | +CREATE TABLE test_truncate_2 ( test_id INT, test_name CHAR(10) ); |
1580 | +INSERT INTO test_truncate_2 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
1581 | +--echo # Preparing test bed for DROP test |
1582 | +USE Test_Drop; |
1583 | +CREATE TABLE test_drop ( test_id INT, test_name CHAR(10) ); |
1584 | +CREATE INDEX index_id ON test_drop ( test_id ); |
1585 | +INSERT INTO test_drop VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
1586 | + |
1587 | +--echo # This should print 1 indicating that, the log file is still empty |
1588 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1589 | + |
1590 | + |
1591 | + |
1592 | +--echo # enabling the logging_query plugin |
1593 | +SET GLOBAL logging_query_enable=true; |
1594 | +--echo # Now the tests begin!!! |
1595 | + |
1596 | +# ############################################################################################# |
1597 | +# Test: DELETE |
1598 | +# ############################################################################################# |
1599 | +--echo DELETE test in progress... |
1600 | +USE Test_Delete; |
1601 | + |
1602 | +--echo # The following 2 queries should be logged |
1603 | +DELETE FROM test_delete_1; |
1604 | +--echo # The following query should return a null set |
1605 | +SELECT * FROM test_delete_1; |
1606 | + |
1607 | +--echo # enabling the logging_query plugin to log only DELETE queries |
1608 | +SET GLOBAL logging_query_pcre="DELETE.+"; |
1609 | + |
1610 | +--echo # The following DELETE queries should be logged |
1611 | +DELETE FROM test_delete_2 WHERE test_id = 1; |
1612 | +DELETE FROM test_delete_2 WHERE test_name = "select"; |
1613 | +--echo # The following query should select only tuples with id = (3,4,5) and this query should not be logged |
1614 | +SELECT * FROM test_delete_2; |
1615 | + |
1616 | +--echo # enabling the logging_query plugin to log SELECT queries |
1617 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
1618 | + |
1619 | +--echo # The following DELETE query should not be logged |
1620 | +DELETE FROM test_delete_2; |
1621 | +--echo # The following SELECT query should return a null set and should be logged |
1622 | +SELECT * FROM test_delete_2; |
1623 | + |
1624 | +--echo # Delete test is completed. Now checking the logging_query.log file. This should print 10 |
1625 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1626 | + |
1627 | + |
1628 | +# ############################################################################################# |
1629 | +# Test: TRUNCATE |
1630 | +# ############################################################################################# |
1631 | +--echo TRUNCATE test in progress... |
1632 | +USE Test_Truncate; |
1633 | + |
1634 | +--echo # enabling the logging_query plugin to log TRUNCATE queries |
1635 | +SET GLOBAL logging_query_pcre="TRUNCATE.+"; |
1636 | + |
1637 | +--echo # The following TRUNCATE query should be logged |
1638 | +TRUNCATE TABLE test_truncate_1; |
1639 | +--echo # This SELECT query should not be logged ; this should return a null set |
1640 | +SELECT * FROM test_truncate_1; |
1641 | + |
1642 | +--echo # enabling the logging_query plugin to log RENAME query |
1643 | +SET GLOBAL logging_query_pcre="RENAME.+"; |
1644 | + |
1645 | +--echo # The following RENAME query should be logged |
1646 | +RENAME TABLE test_truncate_2 TO test_truncate; |
1647 | +--echo # This TRUNCATE query should not be logged |
1648 | +TRUNCATE TABLE test_truncate; |
1649 | +--echo # This SELECT query should not be logged ; this should return a null set |
1650 | +SELECT * FROM test_truncate; |
1651 | + |
1652 | +--echo # Truncate test is completed. Now checking the logging_query.log file. This should print 14 |
1653 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1654 | + |
1655 | + |
1656 | +# ############################################################################################# |
1657 | +# Test: Drop |
1658 | +# ############################################################################################# |
1659 | +--echo DROP test in progress... |
1660 | +USE Test_Drop; |
1661 | + |
1662 | +--echo # enabling the logging_query plugin to log DROP queries |
1663 | +SET GLOBAL logging_query_pcre="DROP.+"; |
1664 | + |
1665 | +--echo # dropping an index ; this query should be logged since it is a DROP query ( though implemented through ALTER query ) |
1666 | +ALTER TABLE test_drop DROP INDEX index_id; |
1667 | + |
1668 | +--echo # dropping a table ; this query should be logged |
1669 | +DROP TABLE test_drop; |
1670 | + |
1671 | +--echo # dropping a schema ; this query should be logged |
1672 | +DROP SCHEMA Test_Drop; |
1673 | + |
1674 | +--echo # Drop test is completed. Now checking the logging_query.log file. This should print 18 |
1675 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1676 | + |
1677 | + |
1678 | +# ############################################################################################# |
1679 | +# Cleaning up |
1680 | +# ############################################################################################# |
1681 | +--echo cleaning up... |
1682 | +SET GLOBAL logging_query_enable=false; |
1683 | +SET GLOBAL logging_query_pcre=".+"; |
1684 | +DROP SCHEMA IF EXISTS Test_Delete; |
1685 | +DROP SCHEMA IF EXISTS Test_Truncate; |
1686 | +DROP SCHEMA IF EXISTS Test_Drop; |
1687 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1688 | +--echo ***done*** |
1689 | + |
1690 | +# ############################################################################################# |
1691 | +# Done |
1692 | +# ############################################################################################# |
1693 | |
1694 | === modified file 'plugin/logging_query/tests/t/file.bak' |
1695 | --- plugin/logging_query/tests/t/file.bak 2012-09-30 18:45:40 +0000 |
1696 | +++ plugin/logging_query/tests/t/file.bak 2012-10-08 16:53:22 +0000 |
1697 | @@ -1,81 +1,90 @@ |
1698 | |
1699 | -# ########################################################################### |
1700 | +# ################################################################################### |
1701 | # This tests the dynamic behaviour of logging_query plugin |
1702 | -# ########################################################################### |
1703 | +# ################################################################################### |
1704 | |
1705 | # Logging_query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not. |
1706 | --replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1707 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1708 | --exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1709 | # Clear log file. |
1710 | --exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1711 | # Double-check that log file is clear. |
1712 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1713 | |
1714 | -# Since logging_query_enable is OFF by default, this should not be logged into the log file. |
1715 | +--echo # Since logging_query_enable is OFF by default, this should not be logged into the log file. |
1716 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1717 | |
1718 | -#This should not print anything |
1719 | +--echo #This should not print anything |
1720 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1721 | |
1722 | -#Enabling logging_query plugin |
1723 | +--echo #Enabling logging_query plugin |
1724 | SET GLOBAL logging_query_enable=true; |
1725 | |
1726 | -#Now as logging_query_enable is set to true, this should be logged. |
1727 | +--echo #Now as logging_query_enable is set to true, this should be logged. |
1728 | SELECT 1; |
1729 | |
1730 | -#This should print the content of log file as SET GLOBAL query and SELECT query |
1731 | +--echo #This should print the content of log file as SET GLOBAL query and SELECT query |
1732 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1733 | |
1734 | -#Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now. |
1735 | +--echo #Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now. |
1736 | SET GLOBAL logging_query_pcre="SHOW.+"; |
1737 | |
1738 | -#This should not be logged |
1739 | +--echo #This should not be logged |
1740 | SELECT @@logging_query_enable; |
1741 | |
1742 | -#This should print the content of log file updated with |
1743 | +--echo #This should print the content of log file updated with |
1744 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1745 | |
1746 | -#This should be logged |
1747 | +--echo #This should be logged |
1748 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1749 | |
1750 | -#This should print the content of log file updated with SHOW query as it matched the regex. |
1751 | +--echo #This should print the content of log file updated with SHOW query as it matched the regex. |
1752 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1753 | |
1754 | -#Now changing the query log filename |
1755 | +--echo #Now changing the query log filename |
1756 | --replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1757 | eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query1.log"; |
1758 | --replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1759 | -#--exec if [ -f $DRIZZLETEST_VARDIR/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi |
1760 | +--echo #--exec if [ -f $DRIZZLETEST_VARDIR/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi |
1761 | |
1762 | -# Clear log file. |
1763 | +--echo # Clear log file. |
1764 | --exec echo "" > $DRIZZLETEST_VARDIR/logging_query1.log |
1765 | |
1766 | -# Double-check that log file is clear. |
1767 | +--echo # Double-check that log file is clear. |
1768 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1769 | |
1770 | -#This should not be logged. Neither into new log file. Nor into new log file. |
1771 | +--echo #This should not be logged. Neither into new log file. Nor into new log file. |
1772 | SELECT @@logging_query_enable; |
1773 | |
1774 | -#Checking the content of both the files. |
1775 | +--echo #Checking the content of both the files. |
1776 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1777 | |
1778 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1779 | |
1780 | -#This should be logged into new log file |
1781 | +--echo #This should be logged into new log file |
1782 | SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1783 | |
1784 | -#Checking the contents of boh the log files. |
1785 | +--echo #Checking the contents of boh the log files. |
1786 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1787 | |
1788 | --exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1789 | |
1790 | -#Changing log file to null string. This should throw error. |
1791 | +--echo #Changing log file to null string. This should throw error. |
1792 | --error ER_WRONG_ARGUMENTS |
1793 | eval SET GLOBAL logging_query_filename=""; |
1794 | |
1795 | ---exec rm $DRIZZLETEST_VARDIR/logging_query*.log |
1796 | +# ################################################################################### |
1797 | +# Clean up |
1798 | +# ################################################################################### |
1799 | +--echo cleaning up... |
1800 | +SET GLOBAL logging_query_enable=false; |
1801 | +SET GLOBAL logging_query_pcre="*"; |
1802 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1803 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1804 | +--echo ***done*** |
1805 | |
1806 | -# ########################################################################### |
1807 | +# ################################################################################### |
1808 | # Done. |
1809 | -# ########################################################################### |
1810 | +# ################################################################################### |
1811 | |
1812 | |
1813 | === added file 'plugin/logging_query/tests/t/insert.test' |
1814 | --- plugin/logging_query/tests/t/insert.test 1970-01-01 00:00:00 +0000 |
1815 | +++ plugin/logging_query/tests/t/insert.test 2012-10-08 16:53:22 +0000 |
1816 | @@ -0,0 +1,87 @@ |
1817 | + |
1818 | +# #################################################################################################### |
1819 | +# This tests the logging_query plugin for various insert statements |
1820 | +# #################################################################################################### |
1821 | + |
1822 | +# logging_query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not |
1823 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1824 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1825 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1826 | + |
1827 | +# Clearing the log file |
1828 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1829 | +# Checking if the log file is cleared |
1830 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1831 | +# The above command should print 1 to indicate the log file is empty |
1832 | + |
1833 | +# #################################################################################################### |
1834 | +# Preparing the test bed |
1835 | +# #################################################################################################### |
1836 | +--echo preparing the test bed... |
1837 | + |
1838 | +--echo # The logging_query plugin is not enabled and hence the following queries should not be logged |
1839 | +DROP SCHEMA IF EXISTS Test; |
1840 | +CREATE SCHEMA Test; |
1841 | +USE Test; |
1842 | +CREATE TABLE test_info (test_id INT, test_name VARCHAR(10)); |
1843 | +INSERT INTO test_info (test_id,test_name) VALUES (0,null); |
1844 | +--echo # This should print 1 indicating the log file is still empty |
1845 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1846 | +--echo |
1847 | + |
1848 | +--echo # Now the test begins!!! |
1849 | +--echo # Enabling the logging_query plugin |
1850 | +SET GLOBAL logging_query_enable=true; |
1851 | + |
1852 | +--echo # The following queries should be logged |
1853 | +INSERT INTO test_info (test_id) VALUES (1); |
1854 | +INSERT INTO test_info (test_id,test_name) VALUES (1,"create"); |
1855 | +INSERT INTO test_info VALUES (2,"select"); |
1856 | +SELECT * FROM test_info; |
1857 | +--echo # This should print 6 indicating that, all of the above queries are logged |
1858 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1859 | + |
1860 | +--echo # Enabling the logging_query plugin to log only INSERT queries |
1861 | +SET GLOBAL logging_query_pcre="INSERT.+"; |
1862 | + |
1863 | +--echo # The following INSERT query should be logged |
1864 | +INSERT INTO test_info (test_id,test_name) VALUES (3,"insert"); |
1865 | +INSERT INTO test_info VALUES (4,"drop"),(5,"delete"); |
1866 | +SELECT test_name FROM test_info; |
1867 | +DELETE FROM test_info WHERE test_id = 0; |
1868 | +SELECT * FROM test_info; |
1869 | +--echo # This should print 9 indicating that, only the INSERT queries were logged |
1870 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1871 | + |
1872 | +--echo # Enabling the logging_query plugin to log SELECT queries |
1873 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
1874 | + |
1875 | +--echo # The following INSERT queries should NOT be logged |
1876 | +INSERT INTO test_info VALUES (5,"delete"); |
1877 | +SELECT test_name AS tests FROM test_info; |
1878 | +SELECT * FROM test_info WHERE test_id > 3; |
1879 | +--echo # This should print 12 indicating that, the INSERT query is NOT logged |
1880 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1881 | + |
1882 | +--echo # Enabling the logging_query plugin to log DELETE queries |
1883 | +SET GLOBAL logging_query_pcre="DELETE.+"; |
1884 | + |
1885 | +--echo # The following INSERT queries should NOT be logged |
1886 | +INSERT INTO test_info VALUES (6,""),(7,"enums"); |
1887 | +DELETE FROM test_info WHERE test_id=6 OR 7; |
1888 | +--echo # This should print 14 indicating that, the INSERT query is NOT Logged |
1889 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1890 | + |
1891 | +# #################################################################################################### |
1892 | +# Cleaning up |
1893 | +# #################################################################################################### |
1894 | +--echo cleaning up... |
1895 | +SET GLOBAL logging_query_enable=false; |
1896 | +SET GLOBAL logging_query_pcre=".+"; |
1897 | +DROP SCHEMA Test; |
1898 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1899 | +--echo ***done*** |
1900 | + |
1901 | +# #################################################################################################### |
1902 | +# Done |
1903 | +# #################################################################################################### |
1904 | |
1905 | === added file 'plugin/logging_query/tests/t/select.test' |
1906 | --- plugin/logging_query/tests/t/select.test 1970-01-01 00:00:00 +0000 |
1907 | +++ plugin/logging_query/tests/t/select.test 2012-10-08 16:53:22 +0000 |
1908 | @@ -0,0 +1,128 @@ |
1909 | + |
1910 | +# ################################################################################## |
1911 | +# This tests the logging_query plugin for various select instances |
1912 | +# ################################################################################## |
1913 | + |
1914 | +# Logging query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not |
1915 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1916 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1917 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1918 | + |
1919 | +# Clearing the log file |
1920 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1921 | +# Checking if the log file is cleared |
1922 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1923 | +# The above command should print 1 to indicate that the log file is empty |
1924 | + |
1925 | +# ################################################################################## |
1926 | +# Preparing the test bed |
1927 | +# ################################################################################## |
1928 | +--echo Preparing the test bed... |
1929 | +CREATE SCHEMA Select_Test; |
1930 | +USE Select_Test; |
1931 | +CREATE TABLE select_test_1 (id INT, type CHAR(20)); |
1932 | +INSERT INTO select_test_1 VALUES (1,"basic select"),(2,"select distinct"),(3,"select with where"),(4,"select with orderby"); |
1933 | +CREATE TABLE select_test_2 (id INT, time FLOAT); |
1934 | +INSERT INTO select_test_2 VALUES (1,10.01),(2,9.38),(3,5.6),(4,6.7); |
1935 | +--echo prepare phase completed... |
1936 | +--echo |
1937 | + |
1938 | +# ################################################################################### |
1939 | +# Basic SELECT queries |
1940 | +# ################################################################################### |
1941 | +--echo Testing basic select queries. |
1942 | +--echo # The logging_query is not enabled and hence the following select queries should not be logged |
1943 | +SELECT 1; |
1944 | +SELECT "logging_query"; |
1945 | +--echo # This should print 1 to indicate the log file is still empty |
1946 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1947 | +--echo |
1948 | + |
1949 | +--echo # Enabling the logging_query plugin |
1950 | +SET GLOBAL logging_query_enable=true; |
1951 | +--echo |
1952 | + |
1953 | +--echo # The logging_query is enabled and the following select query should be logged |
1954 | +SELECT 1; |
1955 | +--echo # This should print 3 indicating that the above query is logged |
1956 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1957 | +--echo # Issuing another select query |
1958 | +SELECT "hello world"; |
1959 | +--echo # This should print 4 indicating that the above query is logged |
1960 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1961 | +--echo |
1962 | + |
1963 | +--echo # Enabling the logging_query to log only SHOW queries |
1964 | +SET GLOBAL logging_query_pcre="SHOW.+"; |
1965 | +--echo |
1966 | + |
1967 | +--echo # The following query should be logged |
1968 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1969 | +--echo # This should print 6 indicating that the above query is logged |
1970 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1971 | +--echo |
1972 | + |
1973 | +--echo # The following select query should not be logged |
1974 | +SELECT 1; |
1975 | +--echo # This should print 4 indicating that the above query is not logged |
1976 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1977 | +--echo # Basic test completed... |
1978 | +--echo |
1979 | + |
1980 | + |
1981 | +--echo drilling the SELECT queries test. |
1982 | +--echo # Enabling the logging_query plugin to log SELECT queries |
1983 | +--echo # ( since here after, the test deals with variants of SELECT queries and all such should be checked against logging) |
1984 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
1985 | +--echo |
1986 | + |
1987 | +# ################################################################################## |
1988 | +# SELECT with DISTINCT |
1989 | +# ################################################################################## |
1990 | +--echo # Testing for select with distinct |
1991 | +--echo # The following queries should be logged |
1992 | +SELECT DISTINCT * FROM select_test_1; |
1993 | +SELECT DISTINCT * FROM select_test_2; |
1994 | +--echo # This should print 9 indicating that the above queries are logged |
1995 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1996 | +--echo |
1997 | + |
1998 | +# ################################################################################## |
1999 | +# SELECT with WHERE |
2000 | +# ################################################################################## |
2001 | +--echo # Testing for select with where |
2002 | +--echo # The following queries should be logged |
2003 | +SELECT * FROM select_test_1 WHERE id = 2; |
2004 | +SELECT * FROM select_test_1 WHERE type = "select with where"; |
2005 | +SELECT time FROM select_test_2 WHERE id >= 2; |
2006 | +SELECT id FROM select_test_2 WHERE time < 6; |
2007 | +--echo # This should print 13 indicating that the above queries are logged |
2008 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2009 | +--echo |
2010 | + |
2011 | +# ################################################################################## |
2012 | +# SELECT with ORDER BY |
2013 | +# ################################################################################## |
2014 | +--echo # Testing for select with order by |
2015 | +--echo # The following queries should be logged |
2016 | +SELECT * FROM select_test_2 ORDER BY id DESC; |
2017 | +SELECT time FROM select_test_2 ORDER BY time; |
2018 | +SELECT id FROM select_test_2 ORDER BY time DESC; |
2019 | +--echo # This should print 16 indicating all the above queries are logged |
2020 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2021 | +--echo |
2022 | + |
2023 | + |
2024 | +# ################################################################################## |
2025 | +# Cleaning up |
2026 | +# ################################################################################## |
2027 | +--echo cleaning up... |
2028 | +DROP SCHEMA Select_Test; |
2029 | +SET GLOBAL logging_query_enable=false; |
2030 | +SET GLOBAL logging_query_pcre=".+"; |
2031 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
2032 | +--echo ***done*** |
2033 | + |
2034 | +# ################################################################################## |
2035 | +# Done |
2036 | +# ################################################################################## |
2037 | |
2038 | === modified file 'plugin/logging_query/tests/t/thresholds.bak' |
2039 | --- plugin/logging_query/tests/t/thresholds.bak 2012-09-30 21:58:50 +0000 |
2040 | +++ plugin/logging_query/tests/t/thresholds.bak 2012-10-08 16:53:22 +0000 |
2041 | @@ -80,7 +80,11 @@ |
2042 | # ############################################################################ |
2043 | # Clean up. |
2044 | # ############################################################################ |
2045 | +--echo cleaning up... |
2046 | +SET GLOBAL logging_query_enable=false; |
2047 | +SET GLOBAL logging_query_pcre=".+"; |
2048 | --exec rm $DRIZZLETEST_VARDIR/logging_query*.log |
2049 | +--echo ***done*** |
2050 | |
2051 | # ########################################################################### |
2052 | # Done. |
2053 | |
2054 | === added file 'plugin/logging_query/tests/t/update.test' |
2055 | --- plugin/logging_query/tests/t/update.test 1970-01-01 00:00:00 +0000 |
2056 | +++ plugin/logging_query/tests/t/update.test 2012-10-08 16:53:22 +0000 |
2057 | @@ -0,0 +1,88 @@ |
2058 | + |
2059 | +# ######################################################################################### |
2060 | +# This tests the logging_query plugin for various update statements |
2061 | +# ######################################################################################### |
2062 | + |
2063 | +# The logging_query plugin is loaded into the system. This checks if the file which we sent through the command line is opened or not |
2064 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
2065 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
2066 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
2067 | + |
2068 | +# Clearing the log file |
2069 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2070 | +# Checking if the log file is empty or not |
2071 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2072 | +# The above command should print 1 indicating that the log file is still empty |
2073 | + |
2074 | +# ######################################################################################### |
2075 | +# Preparing the test bed |
2076 | +# ######################################################################################### |
2077 | +--echo preparing the test bed... |
2078 | + |
2079 | +--echo # The logging_query plugin is not enabled and hence none of the queries in prepare phase should be logged |
2080 | +CREATE SCHEMA Test_Update; |
2081 | +USE Test_Update; |
2082 | +CREATE TABLE test_info (id INT, name CHAR(10)); |
2083 | +INSERT INTO test_info VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
2084 | +--echo # This should print 1 indicating that the log file is still empty |
2085 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2086 | +--echo |
2087 | + |
2088 | +# ######################################################################################### |
2089 | +# UPDATE test |
2090 | +# ######################################################################################### |
2091 | +--echo UPDATE test in progress... |
2092 | + |
2093 | +--echo # The logging_query plugin is not enabled and the following update query should not be logged |
2094 | +UPDATE test_info SET name="CREATE" WHERE id=1; |
2095 | +--echo # This should print 1 indicating that the log file is still empty |
2096 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2097 | +--echo |
2098 | + |
2099 | +--echo # Enabling the logging_query plugin |
2100 | +SET GLOBAL logging_query_enable=true; |
2101 | +--echo |
2102 | + |
2103 | +--echo # The logging_query plugin is enabled and the following update query should be logged |
2104 | +UPDATE test_info SET name="SELECT" WHERE id=2; |
2105 | +--echo # This should print 3 indicating that the above query is logged |
2106 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2107 | +--echo |
2108 | + |
2109 | +--echo # Enabling the logging_query plugin to log only select queries |
2110 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
2111 | +--echo |
2112 | + |
2113 | +--echo # The following UPDATE query should not be logged |
2114 | +UPDATE test_info SET name="INSERT" WHERE id=3; |
2115 | +SELECT * FROM test_info; |
2116 | +--echo # This should print 5 indicating that, only the UPDATE query is NOT logged |
2117 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2118 | +--echo |
2119 | + |
2120 | +--echo # Enabling the logging_query plugin to log UPDATE queries |
2121 | +SET GLOBAL logging_query_pcre="UPDATE.+"; |
2122 | +--echo |
2123 | + |
2124 | +--echo # The followihng UPDATE query should be logged |
2125 | +UPDATE test_info SET name="UPDATE" WHERE id=6; |
2126 | +--echo # The above query will not update the table since a tuple with id=6 does not exist |
2127 | +SELECT * FROM test_info; |
2128 | +--echo # This should print 7 indicating that, only the UPDATE query is logged and not the select query |
2129 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2130 | +--echo |
2131 | + |
2132 | +# ######################################################################################### |
2133 | +# Clean up |
2134 | +# ######################################################################################### |
2135 | +--echo cleaning up... |
2136 | +SET GLOBAL logging_query_enable=false; |
2137 | +SET GLOBAL logging_query_pcre=".+"; |
2138 | +DROP SCHEMA Test_Update; |
2139 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
2140 | +--echo ***done*** |
2141 | + |
2142 | +# ######################################################################################### |
2143 | +# Done |
2144 | +# ######################################################################################### |
2145 | + |
Needs one bit of work in file.test: vardir_ value DRIZZLETEST_VARDIR
The only issue is that the .result file contains the actual DRIZZLETEST_VARDIR value
This needs to be fixed either with disable_query_log to keep the output of the .result file (though echo output should indicate the action is being performed) or via the replace_result function to mask the actual DRIZZLETEST_VARDIR value (you'll need to capture it early in the test like:
actual_vardir_value = $DRIZZLETEST_VARDIR
...
--replace_result $actual_
replace_result would be preferable, but anything to eliminate the capture of a hard variable value in the .result file is good (so the test can run on anyone's machine regardless of where DRIZZLETEST_VARDIR may be)
=== modified file 'plugin/ logging_ query/tests/ t/file. test' logging_ query/tests/ t/file. test 2012-09-21 22:52:11 +0000 logging_ query/tests/ t/file. test 2012-10-08 16:52:26 +0000 query_enable= false; query_pcre= "*"; query_filename= "$DRIZZLETEST_ VARDIR/ logging_ query.log" ; VARDIR/ logging_ query.log
--- plugin/
+++ plugin/
@@ -80,6 +80,11 @@
--echo cleaning up...
SET GLOBAL logging_
SET GLOBAL logging_
+# Here is where you either need to use:
+# disable_query_log, enable_query_log OR
+# replace_result from_val to_val [from_val to_val] ...
+# to capture what DRIZZLETEST_VARDIR really is and to mask it
+
eval SET GLOBAL logging_
--exec rm $DRIZZLETEST_
--echo ***done***