Merge lp:~sharan-monikantan/drizzle/trunk-bug-723915-fixed into lp:drizzle
- trunk-bug-723915-fixed
- Merge into 7.2
Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~sharan-monikantan/drizzle/trunk-bug-723915-fixed | ||||
Merge into: | lp:drizzle | ||||
Diff against target: |
2381 lines (+2002/-187) 25 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 (+0/-81) plugin/logging_query/tests/t/file.test (+92/-0) 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 (+0/-87) plugin/logging_query/tests/t/thresholds.test (+91/-0) plugin/logging_query/tests/t/update.test (+88/-0) |
||||
To merge this branch: | bzr merge lp:~sharan-monikantan/drizzle/trunk-bug-723915-fixed | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Patrick Crews | Approve | ||
Review via email: mp+128576@code.launchpad.net |
Commit message
Description of the change
The test suite for logging_query plugin has been updated with a lot of intense tests.
Brian Aker (brianaker) wrote : | # |
The first run of this spit out some test errors. I can run it again once the current patches make it through.
Sharan Kumar (sharan-monikantan) wrote : | # |
> Running again.
Is the test running without errors? Will this patch make it to the trunk?
Brian Aker (brianaker) wrote : | # |
Still running:
https:/
On Oct 17, 2012, at 10:21 PM, M.Sharan Kumar <email address hidden> wrote:
>> Running again.
> Is the test running without errors? Will this patch make it to the trunk?
> --
> https:/
> Your team Drizzle Trunk is subscribed to branch lp:drizzle.
Brian Aker (brianaker) wrote : | # |
Still failing:
https:/
If you are on an Ubuntu box you can simulate this entire test run by running:
./bootstrap jenkins
Sharan Kumar (sharan-monikantan) wrote : | # |
> Still failing:
>
> https:/
> matrix/
>
> If you are on an Ubuntu box you can simulate this entire test run by running:
>
> ./bootstrap jenkins
Something which I traced yesterday. The statements like 'SET GLOBAL logging_
Brian Aker (brianaker) wrote : | # |
From Jenkins:
https:/
logging_
--- ./plugin/
+++ ./plugin/
@@ -98,7 +98,7 @@
id
3
# This should print 13 indicating that the above queries are logged
-Number of queries logged : 13
+Number of queries logged : 12
# Testing for select with order by
# The following queries should be logged
drizzletest: Result content mismatch
Stopping All Servers
Restoring snapshot of databases
Resuming Tests
logging_
logging_
--- ./plugin/
+++ ./plugin/
@@ -37,7 +37,7 @@
4 update
5 delete
# This should print 5 indicating that, only the UPDATE query is NOT logged
-Number of queries logged : 2
+Number of queries logged : 1
# Enabling the logging_query plugin to log UPDATE queries
SET GLOBAL logging_
drizzletest: Result content mismatch
Unmerged revisions
- 2597. 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
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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 | +New log file exists |
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="DRIZZLETEST_VARDIR/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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 20:02:27 +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 | === removed 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 1970-01-01 00:00:00 +0000 |
1697 | @@ -1,81 +0,0 @@ |
1698 | - |
1699 | -# ########################################################################### |
1700 | -# This tests the dynamic behaviour of logging_query plugin |
1701 | -# ########################################################################### |
1702 | - |
1703 | -# Logging_query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not. |
1704 | ---replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1705 | ---exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1706 | -# Clear log file. |
1707 | ---exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1708 | -# Double-check that log file is clear. |
1709 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1710 | - |
1711 | -# Since logging_query_enable is OFF by default, this should not be logged into the log file. |
1712 | -SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1713 | - |
1714 | -#This should not print anything |
1715 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1716 | - |
1717 | -#Enabling logging_query plugin |
1718 | -SET GLOBAL logging_query_enable=true; |
1719 | - |
1720 | -#Now as logging_query_enable is set to true, this should be logged. |
1721 | -SELECT 1; |
1722 | - |
1723 | -#This should print the content of log file as SET GLOBAL query and SELECT query |
1724 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1725 | - |
1726 | -#Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now. |
1727 | -SET GLOBAL logging_query_pcre="SHOW.+"; |
1728 | - |
1729 | -#This should not be logged |
1730 | -SELECT @@logging_query_enable; |
1731 | - |
1732 | -#This should print the content of log file updated with |
1733 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1734 | - |
1735 | -#This should be logged |
1736 | -SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1737 | - |
1738 | -#This should print the content of log file updated with SHOW query as it matched the regex. |
1739 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1740 | - |
1741 | -#Now changing the query log filename |
1742 | ---replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1743 | -eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query1.log"; |
1744 | ---replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1745 | -#--exec if [ -f $DRIZZLETEST_VARDIR/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi |
1746 | - |
1747 | -# Clear log file. |
1748 | ---exec echo "" > $DRIZZLETEST_VARDIR/logging_query1.log |
1749 | - |
1750 | -# Double-check that log file is clear. |
1751 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1752 | - |
1753 | -#This should not be logged. Neither into new log file. Nor into new log file. |
1754 | -SELECT @@logging_query_enable; |
1755 | - |
1756 | -#Checking the content of both the files. |
1757 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1758 | - |
1759 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1760 | - |
1761 | -#This should be logged into new log file |
1762 | -SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1763 | - |
1764 | -#Checking the contents of boh the log files. |
1765 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1766 | - |
1767 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1768 | - |
1769 | -#Changing log file to null string. This should throw error. |
1770 | ---error ER_WRONG_ARGUMENTS |
1771 | -eval SET GLOBAL logging_query_filename=""; |
1772 | - |
1773 | ---exec rm $DRIZZLETEST_VARDIR/logging_query*.log |
1774 | - |
1775 | -# ########################################################################### |
1776 | -# Done. |
1777 | -# ########################################################################### |
1778 | - |
1779 | |
1780 | === added file 'plugin/logging_query/tests/t/file.test' |
1781 | --- plugin/logging_query/tests/t/file.test 1970-01-01 00:00:00 +0000 |
1782 | +++ plugin/logging_query/tests/t/file.test 2012-10-08 20:02:27 +0000 |
1783 | @@ -0,0 +1,92 @@ |
1784 | + |
1785 | +# ################################################################################### |
1786 | +# This tests the dynamic behaviour of logging_query plugin |
1787 | +# ################################################################################### |
1788 | + |
1789 | +# Logging_query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not. |
1790 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1791 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1792 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1793 | +# Clear log file. |
1794 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1795 | +# Double-check that log file is clear. |
1796 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1797 | + |
1798 | +--echo # Since logging_query_enable is OFF by default, this should not be logged into the log file. |
1799 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1800 | + |
1801 | +--echo #This should not print anything |
1802 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1803 | + |
1804 | +--echo #Enabling logging_query plugin |
1805 | +SET GLOBAL logging_query_enable=true; |
1806 | + |
1807 | +--echo #Now as logging_query_enable is set to true, this should be logged. |
1808 | +SELECT 1; |
1809 | + |
1810 | +--echo #This should print the content of log file as SET GLOBAL query and SELECT query |
1811 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1812 | + |
1813 | +--echo #Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now. |
1814 | +SET GLOBAL logging_query_pcre="SHOW.+"; |
1815 | + |
1816 | +--echo #This should not be logged |
1817 | +SELECT @@logging_query_enable; |
1818 | + |
1819 | +--echo #This should print the content of log file updated with |
1820 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1821 | + |
1822 | +--echo #This should be logged |
1823 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1824 | + |
1825 | +--echo #This should print the content of log file updated with SHOW query as it matched the regex. |
1826 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1827 | + |
1828 | +--echo #Now changing the query log filename |
1829 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1830 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query1.log"; |
1831 | + |
1832 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1833 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi |
1834 | + |
1835 | +--echo # Clear log file. |
1836 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query1.log |
1837 | + |
1838 | +--echo # Double-check that log file is clear. |
1839 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1840 | + |
1841 | +--echo #This should not be logged. Neither into new log file. Nor into new log file. |
1842 | +SELECT @@logging_query_enable; |
1843 | + |
1844 | +--echo #Checking the content of both the files. |
1845 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1846 | + |
1847 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1848 | + |
1849 | +--echo #This should be logged into new log file |
1850 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
1851 | + |
1852 | +--echo #Checking the contents of boh the log files. |
1853 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1854 | + |
1855 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log |
1856 | + |
1857 | +--echo #Changing log file to null string. This should throw error. |
1858 | +--error ER_WRONG_ARGUMENTS |
1859 | +eval SET GLOBAL logging_query_filename=""; |
1860 | + |
1861 | +# ################################################################################### |
1862 | +# Clean up |
1863 | +# ################################################################################### |
1864 | +--echo cleaning up... |
1865 | +SET GLOBAL logging_query_enable=false; |
1866 | +SET GLOBAL logging_query_pcre="*"; |
1867 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1868 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1869 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1870 | +--echo ***done*** |
1871 | + |
1872 | +# ################################################################################### |
1873 | +# Done. |
1874 | +# ################################################################################### |
1875 | + |
1876 | |
1877 | === added file 'plugin/logging_query/tests/t/insert.test' |
1878 | --- plugin/logging_query/tests/t/insert.test 1970-01-01 00:00:00 +0000 |
1879 | +++ plugin/logging_query/tests/t/insert.test 2012-10-08 20:02:27 +0000 |
1880 | @@ -0,0 +1,87 @@ |
1881 | + |
1882 | +# #################################################################################################### |
1883 | +# This tests the logging_query plugin for various insert statements |
1884 | +# #################################################################################################### |
1885 | + |
1886 | +# logging_query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not |
1887 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1888 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1889 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1890 | + |
1891 | +# Clearing the log file |
1892 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1893 | +# Checking if the log file is cleared |
1894 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1895 | +# The above command should print 1 to indicate the log file is empty |
1896 | + |
1897 | +# #################################################################################################### |
1898 | +# Preparing the test bed |
1899 | +# #################################################################################################### |
1900 | +--echo preparing the test bed... |
1901 | + |
1902 | +--echo # The logging_query plugin is not enabled and hence the following queries should not be logged |
1903 | +DROP SCHEMA IF EXISTS Test; |
1904 | +CREATE SCHEMA Test; |
1905 | +USE Test; |
1906 | +CREATE TABLE test_info (test_id INT, test_name VARCHAR(10)); |
1907 | +INSERT INTO test_info (test_id,test_name) VALUES (0,null); |
1908 | +--echo # This should print 1 indicating the log file is still empty |
1909 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1910 | +--echo |
1911 | + |
1912 | +--echo # Now the test begins!!! |
1913 | +--echo # Enabling the logging_query plugin |
1914 | +SET GLOBAL logging_query_enable=true; |
1915 | + |
1916 | +--echo # The following queries should be logged |
1917 | +INSERT INTO test_info (test_id) VALUES (1); |
1918 | +INSERT INTO test_info (test_id,test_name) VALUES (1,"create"); |
1919 | +INSERT INTO test_info VALUES (2,"select"); |
1920 | +SELECT * FROM test_info; |
1921 | +--echo # This should print 6 indicating that, all of the above queries are logged |
1922 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1923 | + |
1924 | +--echo # Enabling the logging_query plugin to log only INSERT queries |
1925 | +SET GLOBAL logging_query_pcre="INSERT.+"; |
1926 | + |
1927 | +--echo # The following INSERT query should be logged |
1928 | +INSERT INTO test_info (test_id,test_name) VALUES (3,"insert"); |
1929 | +INSERT INTO test_info VALUES (4,"drop"),(5,"delete"); |
1930 | +SELECT test_name FROM test_info; |
1931 | +DELETE FROM test_info WHERE test_id = 0; |
1932 | +SELECT * FROM test_info; |
1933 | +--echo # This should print 9 indicating that, only the INSERT queries were logged |
1934 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1935 | + |
1936 | +--echo # Enabling the logging_query plugin to log SELECT queries |
1937 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
1938 | + |
1939 | +--echo # The following INSERT queries should NOT be logged |
1940 | +INSERT INTO test_info VALUES (5,"delete"); |
1941 | +SELECT test_name AS tests FROM test_info; |
1942 | +SELECT * FROM test_info WHERE test_id > 3; |
1943 | +--echo # This should print 12 indicating that, the INSERT query is NOT logged |
1944 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1945 | + |
1946 | +--echo # Enabling the logging_query plugin to log DELETE queries |
1947 | +SET GLOBAL logging_query_pcre="DELETE.+"; |
1948 | + |
1949 | +--echo # The following INSERT queries should NOT be logged |
1950 | +INSERT INTO test_info VALUES (6,""),(7,"enums"); |
1951 | +DELETE FROM test_info WHERE test_id=6 OR 7; |
1952 | +--echo # This should print 14 indicating that, the INSERT query is NOT Logged |
1953 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1954 | + |
1955 | +# #################################################################################################### |
1956 | +# Cleaning up |
1957 | +# #################################################################################################### |
1958 | +--echo cleaning up... |
1959 | +SET GLOBAL logging_query_enable=false; |
1960 | +SET GLOBAL logging_query_pcre=".+"; |
1961 | +DROP SCHEMA Test; |
1962 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
1963 | +--echo ***done*** |
1964 | + |
1965 | +# #################################################################################################### |
1966 | +# Done |
1967 | +# #################################################################################################### |
1968 | |
1969 | === added file 'plugin/logging_query/tests/t/select.test' |
1970 | --- plugin/logging_query/tests/t/select.test 1970-01-01 00:00:00 +0000 |
1971 | +++ plugin/logging_query/tests/t/select.test 2012-10-08 20:02:27 +0000 |
1972 | @@ -0,0 +1,128 @@ |
1973 | + |
1974 | +# ################################################################################## |
1975 | +# This tests the logging_query plugin for various select instances |
1976 | +# ################################################################################## |
1977 | + |
1978 | +# Logging query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not |
1979 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
1980 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
1981 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
1982 | + |
1983 | +# Clearing the log file |
1984 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
1985 | +# Checking if the log file is cleared |
1986 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
1987 | +# The above command should print 1 to indicate that the log file is empty |
1988 | + |
1989 | +# ################################################################################## |
1990 | +# Preparing the test bed |
1991 | +# ################################################################################## |
1992 | +--echo Preparing the test bed... |
1993 | +CREATE SCHEMA Select_Test; |
1994 | +USE Select_Test; |
1995 | +CREATE TABLE select_test_1 (id INT, type CHAR(20)); |
1996 | +INSERT INTO select_test_1 VALUES (1,"basic select"),(2,"select distinct"),(3,"select with where"),(4,"select with orderby"); |
1997 | +CREATE TABLE select_test_2 (id INT, time FLOAT); |
1998 | +INSERT INTO select_test_2 VALUES (1,10.01),(2,9.38),(3,5.6),(4,6.7); |
1999 | +--echo prepare phase completed... |
2000 | +--echo |
2001 | + |
2002 | +# ################################################################################### |
2003 | +# Basic SELECT queries |
2004 | +# ################################################################################### |
2005 | +--echo Testing basic select queries. |
2006 | +--echo # The logging_query is not enabled and hence the following select queries should not be logged |
2007 | +SELECT 1; |
2008 | +SELECT "logging_query"; |
2009 | +--echo # This should print 1 to indicate the log file is still empty |
2010 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2011 | +--echo |
2012 | + |
2013 | +--echo # Enabling the logging_query plugin |
2014 | +SET GLOBAL logging_query_enable=true; |
2015 | +--echo |
2016 | + |
2017 | +--echo # The logging_query is enabled and the following select query should be logged |
2018 | +SELECT 1; |
2019 | +--echo # This should print 3 indicating that the above query is logged |
2020 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2021 | +--echo # Issuing another select query |
2022 | +SELECT "hello world"; |
2023 | +--echo # This should print 4 indicating that the above query is logged |
2024 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2025 | +--echo |
2026 | + |
2027 | +--echo # Enabling the logging_query to log only SHOW queries |
2028 | +SET GLOBAL logging_query_pcre="SHOW.+"; |
2029 | +--echo |
2030 | + |
2031 | +--echo # The following query should be logged |
2032 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
2033 | +--echo # This should print 6 indicating that the above query is logged |
2034 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2035 | +--echo |
2036 | + |
2037 | +--echo # The following select query should not be logged |
2038 | +SELECT 1; |
2039 | +--echo # This should print 4 indicating that the above query is not logged |
2040 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2041 | +--echo # Basic test completed... |
2042 | +--echo |
2043 | + |
2044 | + |
2045 | +--echo drilling the SELECT queries test. |
2046 | +--echo # Enabling the logging_query plugin to log SELECT queries |
2047 | +--echo # ( since here after, the test deals with variants of SELECT queries and all such should be checked against logging) |
2048 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
2049 | +--echo |
2050 | + |
2051 | +# ################################################################################## |
2052 | +# SELECT with DISTINCT |
2053 | +# ################################################################################## |
2054 | +--echo # Testing for select with distinct |
2055 | +--echo # The following queries should be logged |
2056 | +SELECT DISTINCT * FROM select_test_1; |
2057 | +SELECT DISTINCT * FROM select_test_2; |
2058 | +--echo # This should print 9 indicating that the above queries are logged |
2059 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2060 | +--echo |
2061 | + |
2062 | +# ################################################################################## |
2063 | +# SELECT with WHERE |
2064 | +# ################################################################################## |
2065 | +--echo # Testing for select with where |
2066 | +--echo # The following queries should be logged |
2067 | +SELECT * FROM select_test_1 WHERE id = 2; |
2068 | +SELECT * FROM select_test_1 WHERE type = "select with where"; |
2069 | +SELECT time FROM select_test_2 WHERE id >= 2; |
2070 | +SELECT id FROM select_test_2 WHERE time < 6; |
2071 | +--echo # This should print 13 indicating that the above queries are logged |
2072 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2073 | +--echo |
2074 | + |
2075 | +# ################################################################################## |
2076 | +# SELECT with ORDER BY |
2077 | +# ################################################################################## |
2078 | +--echo # Testing for select with order by |
2079 | +--echo # The following queries should be logged |
2080 | +SELECT * FROM select_test_2 ORDER BY id DESC; |
2081 | +SELECT time FROM select_test_2 ORDER BY time; |
2082 | +SELECT id FROM select_test_2 ORDER BY time DESC; |
2083 | +--echo # This should print 16 indicating all the above queries are logged |
2084 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2085 | +--echo |
2086 | + |
2087 | + |
2088 | +# ################################################################################## |
2089 | +# Cleaning up |
2090 | +# ################################################################################## |
2091 | +--echo cleaning up... |
2092 | +DROP SCHEMA Select_Test; |
2093 | +SET GLOBAL logging_query_enable=false; |
2094 | +SET GLOBAL logging_query_pcre=".+"; |
2095 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
2096 | +--echo ***done*** |
2097 | + |
2098 | +# ################################################################################## |
2099 | +# Done |
2100 | +# ################################################################################## |
2101 | |
2102 | === removed file 'plugin/logging_query/tests/t/thresholds.bak' |
2103 | --- plugin/logging_query/tests/t/thresholds.bak 2012-09-30 21:58:50 +0000 |
2104 | +++ plugin/logging_query/tests/t/thresholds.bak 1970-01-01 00:00:00 +0000 |
2105 | @@ -1,87 +0,0 @@ |
2106 | - |
2107 | -# ########################################################################### |
2108 | -# This tests the various logging_query_threshold_ variables. |
2109 | -# ########################################################################### |
2110 | - |
2111 | -# First make sure the logging_query plugin is enabled. |
2112 | ---replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
2113 | -eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
2114 | -eval SET GLOBAL logging_query_pcre=".+"; |
2115 | ---replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
2116 | -SET GLOBAL logging_query_enable=true; |
2117 | - |
2118 | -# Make sure we have all our threshold variables and that they're all |
2119 | -# off (zero) by default. |
2120 | -SHOW VARIABLES LIKE 'logging_query_threshold%'; |
2121 | - |
2122 | -# ########################################################################### |
2123 | -# logging_query_threshold_slow |
2124 | -# ########################################################################### |
2125 | - |
2126 | -# Set a 0.5s execution time threshold. |
2127 | -SET GLOBAL logging_query_threshold_slow=500000; |
2128 | -SELECT @@logging_query_threshold_slow; |
2129 | - |
2130 | -# Clear log file. |
2131 | ---exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2132 | -# Double-check that log file is clear. |
2133 | ---cat_file $DRIZZLETEST_VARDIR/logging_query.log |
2134 | - |
2135 | -# This query should *not* log since it's below the threshold. |
2136 | -SELECT SLEEP(0.4); |
2137 | -# This should not print anything. |
2138 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2139 | - |
2140 | -# This query should log since it's just a few microseconds past the threshold. |
2141 | -SELECT SLEEP(0.5); |
2142 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2143 | - |
2144 | -# Set query_log_threshold_execution_time back to zero. |
2145 | -SET GLOBAL logging_query_threshold_slow=0; |
2146 | -#This should be logged |
2147 | -SELECT SLEEP(1); |
2148 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2149 | - |
2150 | -# Clear log file. |
2151 | ---exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2152 | -# Double-check that log file is clear. |
2153 | ---cat_file $DRIZZLETEST_VARDIR/logging_query.log |
2154 | - |
2155 | -# ########################################################################### |
2156 | -# logging_query_threshold_big_resultset |
2157 | -# ########################################################################### |
2158 | -# This should be logged |
2159 | -SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
2160 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2161 | -SET GLOBAL logging_query_threshold_big_resultset=2; |
2162 | - |
2163 | -#This should not be logged |
2164 | -SELECT "This should not be logged"; |
2165 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2166 | - |
2167 | -# Clear log file. |
2168 | ---exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2169 | -# Double-check that log file is clear. |
2170 | ---cat_file $DRIZZLETEST_VARDIR/logging_query.log |
2171 | - |
2172 | -# ########################################################################### |
2173 | -# logging_query_threshold_big_examined |
2174 | -# ########################################################################### |
2175 | -# This should be logged |
2176 | -SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
2177 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2178 | - |
2179 | -#Changing threshold_big_examined to 2, so that queries which examine less that 2 rows will not be logged |
2180 | -SET GLOBAL logging_query_threshold_big_examined=2; |
2181 | -#This should not be logged |
2182 | -SELECT "This should not be logged"; |
2183 | ---exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2184 | - |
2185 | -# ############################################################################ |
2186 | -# Clean up. |
2187 | -# ############################################################################ |
2188 | ---exec rm $DRIZZLETEST_VARDIR/logging_query*.log |
2189 | - |
2190 | -# ########################################################################### |
2191 | -# Done. |
2192 | -# ########################################################################### |
2193 | |
2194 | === added file 'plugin/logging_query/tests/t/thresholds.test' |
2195 | --- plugin/logging_query/tests/t/thresholds.test 1970-01-01 00:00:00 +0000 |
2196 | +++ plugin/logging_query/tests/t/thresholds.test 2012-10-08 20:02:27 +0000 |
2197 | @@ -0,0 +1,91 @@ |
2198 | + |
2199 | +# ########################################################################### |
2200 | +# This tests the various logging_query_threshold_ variables. |
2201 | +# ########################################################################### |
2202 | + |
2203 | +# First make sure the logging_query plugin is enabled. |
2204 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
2205 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
2206 | +eval SET GLOBAL logging_query_pcre=".+"; |
2207 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
2208 | +SET GLOBAL logging_query_enable=true; |
2209 | + |
2210 | +# Make sure we have all our threshold variables and that they're all |
2211 | +# off (zero) by default. |
2212 | +SHOW VARIABLES LIKE 'logging_query_threshold%'; |
2213 | + |
2214 | +# ########################################################################### |
2215 | +# logging_query_threshold_slow |
2216 | +# ########################################################################### |
2217 | + |
2218 | +# Set a 0.5s execution time threshold. |
2219 | +SET GLOBAL logging_query_threshold_slow=500000; |
2220 | +SELECT @@logging_query_threshold_slow; |
2221 | + |
2222 | +# Clear log file. |
2223 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2224 | +# Double-check that log file is clear. |
2225 | +--cat_file $DRIZZLETEST_VARDIR/logging_query.log |
2226 | + |
2227 | +# This query should *not* log since it's below the threshold. |
2228 | +SELECT SLEEP(0.4); |
2229 | +# This should not print anything. |
2230 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2231 | + |
2232 | +# This query should log since it's just a few microseconds past the threshold. |
2233 | +SELECT SLEEP(0.5); |
2234 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2235 | + |
2236 | +# Set query_log_threshold_execution_time back to zero. |
2237 | +SET GLOBAL logging_query_threshold_slow=0; |
2238 | +#This should be logged |
2239 | +SELECT SLEEP(1); |
2240 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2241 | + |
2242 | +# Clear log file. |
2243 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2244 | +# Double-check that log file is clear. |
2245 | +--cat_file $DRIZZLETEST_VARDIR/logging_query.log |
2246 | + |
2247 | +# ########################################################################### |
2248 | +# logging_query_threshold_big_resultset |
2249 | +# ########################################################################### |
2250 | +# This should be logged |
2251 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
2252 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2253 | +SET GLOBAL logging_query_threshold_big_resultset=2; |
2254 | + |
2255 | +#This should not be logged |
2256 | +SELECT "This should not be logged"; |
2257 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2258 | + |
2259 | +# Clear log file. |
2260 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2261 | +# Double-check that log file is clear. |
2262 | +--cat_file $DRIZZLETEST_VARDIR/logging_query.log |
2263 | + |
2264 | +# ########################################################################### |
2265 | +# logging_query_threshold_big_examined |
2266 | +# ########################################################################### |
2267 | +# This should be logged |
2268 | +SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%"; |
2269 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2270 | + |
2271 | +#Changing threshold_big_examined to 2, so that queries which examine less that 2 rows will not be logged |
2272 | +SET GLOBAL logging_query_threshold_big_examined=2; |
2273 | +#This should not be logged |
2274 | +SELECT "This should not be logged"; |
2275 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2276 | + |
2277 | +# ############################################################################ |
2278 | +# Clean up. |
2279 | +# ############################################################################ |
2280 | +--echo cleaning up... |
2281 | +SET GLOBAL logging_query_enable=false; |
2282 | +SET GLOBAL logging_query_pcre=".+"; |
2283 | +--exec rm $DRIZZLETEST_VARDIR/logging_query*.log |
2284 | +--echo ***done*** |
2285 | + |
2286 | +# ########################################################################### |
2287 | +# Done. |
2288 | +# ########################################################################### |
2289 | |
2290 | === added file 'plugin/logging_query/tests/t/update.test' |
2291 | --- plugin/logging_query/tests/t/update.test 1970-01-01 00:00:00 +0000 |
2292 | +++ plugin/logging_query/tests/t/update.test 2012-10-08 20:02:27 +0000 |
2293 | @@ -0,0 +1,88 @@ |
2294 | + |
2295 | +# ######################################################################################### |
2296 | +# This tests the logging_query plugin for various update statements |
2297 | +# ######################################################################################### |
2298 | + |
2299 | +# 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 |
2300 | +--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR |
2301 | +eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log"; |
2302 | +--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi |
2303 | + |
2304 | +# Clearing the log file |
2305 | +--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log |
2306 | +# Checking if the log file is empty or not |
2307 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2308 | +# The above command should print 1 indicating that the log file is still empty |
2309 | + |
2310 | +# ######################################################################################### |
2311 | +# Preparing the test bed |
2312 | +# ######################################################################################### |
2313 | +--echo preparing the test bed... |
2314 | + |
2315 | +--echo # The logging_query plugin is not enabled and hence none of the queries in prepare phase should be logged |
2316 | +CREATE SCHEMA Test_Update; |
2317 | +USE Test_Update; |
2318 | +CREATE TABLE test_info (id INT, name CHAR(10)); |
2319 | +INSERT INTO test_info VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete"); |
2320 | +--echo # This should print 1 indicating that the log file is still empty |
2321 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2322 | +--echo |
2323 | + |
2324 | +# ######################################################################################### |
2325 | +# UPDATE test |
2326 | +# ######################################################################################### |
2327 | +--echo UPDATE test in progress... |
2328 | + |
2329 | +--echo # The logging_query plugin is not enabled and the following update query should not be logged |
2330 | +UPDATE test_info SET name="CREATE" WHERE id=1; |
2331 | +--echo # This should print 1 indicating that the log file is still empty |
2332 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2333 | +--echo |
2334 | + |
2335 | +--echo # Enabling the logging_query plugin |
2336 | +SET GLOBAL logging_query_enable=true; |
2337 | +--echo |
2338 | + |
2339 | +--echo # The logging_query plugin is enabled and the following update query should be logged |
2340 | +UPDATE test_info SET name="SELECT" WHERE id=2; |
2341 | +--echo # This should print 3 indicating that the above query is logged |
2342 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2343 | +--echo |
2344 | + |
2345 | +--echo # Enabling the logging_query plugin to log only select queries |
2346 | +SET GLOBAL logging_query_pcre="SELECT.+"; |
2347 | +--echo |
2348 | + |
2349 | +--echo # The following UPDATE query should not be logged |
2350 | +UPDATE test_info SET name="INSERT" WHERE id=3; |
2351 | +SELECT * FROM test_info; |
2352 | +--echo # This should print 5 indicating that, only the UPDATE query is NOT logged |
2353 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2354 | +--echo |
2355 | + |
2356 | +--echo # Enabling the logging_query plugin to log UPDATE queries |
2357 | +SET GLOBAL logging_query_pcre="UPDATE.+"; |
2358 | +--echo |
2359 | + |
2360 | +--echo # The followihng UPDATE query should be logged |
2361 | +UPDATE test_info SET name="UPDATE" WHERE id=6; |
2362 | +--echo # The above query will not update the table since a tuple with id=6 does not exist |
2363 | +SELECT * FROM test_info; |
2364 | +--echo # This should print 7 indicating that, only the UPDATE query is logged and not the select query |
2365 | +--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log |
2366 | +--echo |
2367 | + |
2368 | +# ######################################################################################### |
2369 | +# Clean up |
2370 | +# ######################################################################################### |
2371 | +--echo cleaning up... |
2372 | +SET GLOBAL logging_query_enable=false; |
2373 | +SET GLOBAL logging_query_pcre=".+"; |
2374 | +DROP SCHEMA Test_Update; |
2375 | +--exec rm $DRIZZLETEST_VARDIR/logging_query.log |
2376 | +--echo ***done*** |
2377 | + |
2378 | +# ######################################################################################### |
2379 | +# Done |
2380 | +# ######################################################################################### |
2381 | + |
Looks good. Thanks for taking the time to fix that one test and to create this suite of tests.