Merge lp:~ansharyan015/drizzle/logging_query_dynamic into lp:drizzle

Proposed by Daniel Nichter
Status: Merged
Approved by: Brian Aker
Approved revision: 2569
Merged at revision: 2580
Proposed branch: lp:~ansharyan015/drizzle/logging_query_dynamic
Merge into: lp:drizzle
Diff against target: 557 lines (+417/-18)
7 files modified
plugin/logging_query/logging_query.cc (+146/-18)
plugin/logging_query/tests/parse-query-log.sh (+2/-0)
plugin/logging_query/tests/r/file.result (+46/-0)
plugin/logging_query/tests/r/thresholds.result (+54/-0)
plugin/logging_query/tests/t/file.test (+81/-0)
plugin/logging_query/tests/t/master.opt (+1/-0)
plugin/logging_query/tests/t/thresholds.test (+87/-0)
To merge this branch: bzr merge lp:~ansharyan015/drizzle/logging_query_dynamic
Reviewer Review Type Date Requested Status
Daniel Nichter (community) code review Approve
Drizzle Merge Team Pending
Review via email: mp+114035@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :
Download full text (3.3 KiB)

The new tests have hard-coded paths which fail:

logging_query.file [ fail ]
--- /home/vagrant/drizzle/stage/tests/../plugin/logging_query/tests/r/file.result 2012-07-10 02:00:27.845566000 +0300
+++ /home/vagrant/drizzle/stage/tests/../plugin/logging_query/tests/r/file.reject 2012-07-10 02:14:20.671982823 +0300
@@ -1,49 +1,49 @@
 Log file exists
-1 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+1 /home/vagrant/drizzle/stage/tests/var/logging_query.log
 SHOW VARIABLES LIKE "%logging_query%";
 Variable_name Value
 logging_query_enable OFF
-logging_query_filename /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+logging_query_filename /home/vagrant/drizzle/stage/tests/var/logging_query.log
 logging_query_pcre
 logging_query_threshold_big_examined 0
 logging_query_threshold_big_resultset 0
 logging_query_threshold_slow 0
-1 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+1 /home/vagrant/drizzle/stage/tests/var/logging_query.log
 SET GLOBAL logging_query_enable=true;
 SELECT 1;
 1
 1
-3 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+3 /home/vagrant/drizzle/stage/tests/var/logging_query.log
 SET GLOBAL logging_query_pcre="SHOW.+";
 SELECT @@logging_query_enable;
 @@logging_query_enable
 1
-4 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+4 /home/vagrant/drizzle/stage/tests/var/logging_query.log
 SHOW VARIABLES LIKE "%logging_query%";
 Variable_name Value
 logging_query_enable ON
-logging_query_filename /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+logging_query_filename /home/vagrant/drizzle/stage/tests/var/logging_query.log
 logging_query_pcre SHOW.+
 logging_query_threshold_big_examined 0
 logging_query_threshold_big_resultset 0
 logging_query_threshold_slow 0
-5 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
+5 /home/vagrant/drizzle/stage/tests/var/logging_query.log
 SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query1.log";
-1 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query1.log
+1 /home/vagrant/drizzle/stage/tests/var/logging_query1.log
 SELECT @@logging_query_enable;
 @@logging_query_enable
 1
-5 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
-1 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query1.log
+5 /home/vagrant/drizzle/stage/tests/var/logging_query.log
+1 /home/vagrant/drizzle/stage/tests/var/logging_query1.log
 SHOW VARIABLES LIKE "%logging_query%";
 Variable_name Value
 logging_query_enable ON
-logging_query_filename /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query1.log
+logging_query_filename /home/vagrant/drizzle/stage/tests/var/logging_query1.log
 logging_query_pcre SHOW.+
 logging_query_threshold_big_examined 0
 logging_query_threshold_big_resultset 0
 logging_query_threshold_slow 0
-5 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query.log
-2 /home/ansh/repos/drizzle/logging_query_dynamic/tests/var/logging_query1.log
+5 /home/vagrant/drizzle/stage/tests/var/logging_...

Read more...

review: Needs Fixing (code review)
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugin/logging_query/logging_query.cc'
--- plugin/logging_query/logging_query.cc 2012-01-16 02:37:54 +0000
+++ plugin/logging_query/logging_query.cc 2012-07-10 18:31:49 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20#include <config.h>20#include <config.h>
21#include <drizzled/item.h>
21#include <drizzled/plugin.h>22#include <drizzled/plugin.h>
22#include <drizzled/plugin/logging.h>23#include <drizzled/plugin/logging.h>
23#include <drizzled/gettext.h>24#include <drizzled/gettext.h>
@@ -44,8 +45,9 @@
44#define ESCAPE_CHAR '\\'45#define ESCAPE_CHAR '\\'
45#define SEPARATOR_CHAR ','46#define SEPARATOR_CHAR ','
4647
47namespace drizzle_plugin48namespace drizzle_plugin {
48{49namespace logging_query {
50
4951
50static bool sysvar_logging_query_enable= false;52static bool sysvar_logging_query_enable= false;
51/* TODO fix these to not be unsigned long once we have sensible sys_var system */53/* TODO fix these to not be unsigned long once we have sensible sys_var system */
@@ -53,6 +55,10 @@
53static uint32_constraint sysvar_logging_query_threshold_big_resultset;55static uint32_constraint sysvar_logging_query_threshold_big_resultset;
54static uint32_constraint sysvar_logging_query_threshold_big_examined;56static uint32_constraint sysvar_logging_query_threshold_big_examined;
5557
58bool updateFileName(Session *, set_var*);
59bool updatePCRE(Session *, set_var*);
60
61
56/* quote a string to be safe to include in a CSV line62/* quote a string to be safe to include in a CSV line
57 that means backslash quoting all commas, doublequotes, backslashes,63 that means backslash quoting all commas, doublequotes, backslashes,
58 and all the ASCII unprintable characters64 and all the ASCII unprintable characters
@@ -146,8 +152,8 @@
146152
147class Logging_query: public drizzled::plugin::Logging153class Logging_query: public drizzled::plugin::Logging
148{154{
149 const std::string _filename;155 std::string sysvar_filename;
150 const std::string _query_pcre;156 std::string sysvar_pcre;
151 int fd;157 int fd;
152 pcre *re;158 pcre *re;
153 pcre_extra *pe;159 pcre_extra *pe;
@@ -160,37 +166,116 @@
160 Logging_query(const std::string &filename,166 Logging_query(const std::string &filename,
161 const std::string &query_pcre) :167 const std::string &query_pcre) :
162 drizzled::plugin::Logging("csv_query_log"),168 drizzled::plugin::Logging("csv_query_log"),
163 _filename(filename),169 sysvar_filename(filename),
164 _query_pcre(query_pcre),170 sysvar_pcre(query_pcre),
165 fd(-1), re(NULL), pe(NULL),171 fd(-1), re(NULL), pe(NULL),
166 formatter("%1%,%2%,%3%,\"%4%\",\"%5%\",\"%6%\",%7%,%8%,"172 formatter("%1%,%2%,%3%,\"%4%\",\"%5%\",\"%6%\",%7%,%8%,"
167 "%9%,%10%,%11%,%12%,%13%,%14%,\"%15%\"\n")173 "%9%,%10%,%11%,%12%,%13%,%14%,\"%15%\"\n")
168 {174 {
169175
170 /* if there is no destination filename, dont bother doing anything */176 /* if there is no destination filename, dont bother doing anything */
171 if (_filename.empty())177 if (sysvar_filename.empty())
172 return;178 return;
173179
174 fd= open(_filename.c_str(),180 fd= open(sysvar_filename.c_str(),
175 O_WRONLY | O_APPEND | O_CREAT,181 O_WRONLY | O_APPEND | O_CREAT,
176 S_IRUSR|S_IWUSR);182 S_IRUSR|S_IWUSR);
177183
178 if (fd < 0)184 if (fd < 0)
179 {185 {
180 sql_perror( _("fail open()"), _filename);186 sql_perror( _("fail open()"), sysvar_filename);
181 return;187 return;
182 }188 }
183189
184 if (not _query_pcre.empty())190 if (not sysvar_pcre.empty())
185 {191 {
186 const char *this_pcre_error;192 const char *this_pcre_error;
187 int this_pcre_erroffset;193 int this_pcre_erroffset;
188 re= pcre_compile(_query_pcre.c_str(), 0, &this_pcre_error,194 re= pcre_compile(sysvar_pcre.c_str(), 0, &this_pcre_error,
189 &this_pcre_erroffset, NULL);195 &this_pcre_erroffset, NULL);
190 pe= pcre_study(re, 0, &this_pcre_error);196 pe= pcre_study(re, 0, &this_pcre_error);
191 /* TODO emit error messages if there is a problem */197 /* TODO emit error messages if there is a problem */
192 }198 }
193 }199 }
200
201
202 /**
203 * This function changes the current query log file to the parameter passed to the function.
204 *
205 * @return True on success, False on error.
206 */
207 bool setFileName(std::string new_filename)
208 {
209 if (new_filename.empty())
210 return false;
211
212 int tmp_fd= open(new_filename.c_str(),
213 O_WRONLY | O_APPEND | O_CREAT,
214 S_IRUSR|S_IWUSR);
215
216 if (tmp_fd < 0)
217 {
218 sql_perror( _("fail open()"), new_filename);
219 return false;
220 }
221 if(fd >= 0)
222 {
223 close(fd);
224 }
225 fd= tmp_fd;
226 sysvar_filename= new_filename;
227 return true;
228 }
229
230 /**
231 * This function updates the current regex expression with the new regex expression passed as parameter.
232 *
233 * @return True on success, False on error.
234 */
235 bool setPCRE(std::string new_pcre)
236 {
237 if (not new_pcre.empty())
238 {
239 if (pe != NULL)
240 {
241 pcre_free(pe);
242 }
243
244 if (re != NULL)
245 {
246 pcre_free(re);
247 }
248
249 const char *tmp_this_pcre_error;
250 int tmp_this_pcre_erroffset;
251 re= pcre_compile(new_pcre.c_str(), 0, &tmp_this_pcre_error,
252 &tmp_this_pcre_erroffset, NULL);
253 pe= pcre_study(re, 0, &tmp_this_pcre_error);
254 /* TODO emit error messages if there is a problem */
255 }
256 sysvar_pcre= new_pcre;
257 return true;
258 }
259
260 /**
261 * Getter for query log filename
262 *
263 * @return sysvar_filename
264 */
265 std::string& getFileName()
266 {
267 return sysvar_filename;
268 }
269
270 /**
271 * Getter for pcre
272 *
273 * @return sysvar_pcre
274 */
275 std::string& getPCRE()
276 {
277 return sysvar_pcre;
278 }
194279
195 ~Logging_query()280 ~Logging_query()
196 {281 {
@@ -295,17 +380,58 @@
295 }380 }
296};381};
297382
298static int logging_query_plugin_init(drizzled::module::Context &context)383static Logging_query *handler= NULL;
384
385/**
386 * This function is called when the value of logging_query_filename is updated dynamically.
387 *
388 * @return False on success, True on error.
389 */
390bool updateFileName(Session *, set_var* var)
391{
392 if (not var->value->str_value.empty())
393 {
394 std::string new_filename(var->value->str_value.data());
395 if (handler->setFileName(new_filename))
396 return false; //success
397 else
398 return true; // error
399 }
400 errmsg_printf(error::ERROR, _("logging_query_filename cannot be NULL"));
401 return true; // error
402}
403
404/**
405 * This function is called when the value of logging_query_pcre is updated dynamically.
406 *
407 * @return False on success, True on error.
408 */
409bool updatePCRE(Session *, set_var* var)
410{
411 if (not var->value->str_value.empty())
412 {
413 std::string new_pcre(var->value->str_value.data());
414 if (handler->setPCRE(new_pcre))
415 return false; //success
416 else
417 return true; // error
418 }
419 return false; // success
420}
421
422static int init(drizzled::module::Context &context)
299{423{
300 const module::option_map &vm= context.getOptions();424 const module::option_map &vm= context.getOptions();
301425
302 if (vm.count("filename"))426 if (vm.count("filename"))
303 {427 {
304 context.add(new Logging_query(vm["filename"].as<string>(),428 handler= new Logging_query(vm["filename"].as<string>(),
305 vm["pcre"].as<string>()));429 vm["pcre"].as<string>());
430
431 context.add(handler);
306 context.registerVariable(new sys_var_bool_ptr("enable", &sysvar_logging_query_enable));432 context.registerVariable(new sys_var_bool_ptr("enable", &sysvar_logging_query_enable));
307 context.registerVariable(new sys_var_const_string_val("filename", vm["filename"].as<string>()));433 context.registerVariable(new sys_var_std_string("filename", handler->getFileName(), NULL, &updateFileName));
308 context.registerVariable(new sys_var_const_string_val("pcre", vm["pcre"].as<string>()));434 context.registerVariable(new sys_var_std_string("pcre", handler->getPCRE(), NULL, &updatePCRE));
309 context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_slow", sysvar_logging_query_threshold_slow));435 context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_slow", sysvar_logging_query_threshold_slow));
310 context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_big_resultset", sysvar_logging_query_threshold_big_resultset));436 context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_big_resultset", sysvar_logging_query_threshold_big_resultset));
311 context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_big_examined", sysvar_logging_query_threshold_big_examined));437 context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_big_examined", sysvar_logging_query_threshold_big_examined));
@@ -336,6 +462,8 @@
336 _("Threshold for logging big queries, for rows examined"));462 _("Threshold for logging big queries, for rows examined"));
337}463}
338464
465} /* namespace logging_query */
466
339} /* namespace drizzle_plugin */467} /* namespace drizzle_plugin */
340468
341DRIZZLE_DECLARE_PLUGIN469DRIZZLE_DECLARE_PLUGIN
@@ -346,8 +474,8 @@
346 "Mark Atwood",474 "Mark Atwood",
347 N_("Logs queries to a CSV file"),475 N_("Logs queries to a CSV file"),
348 PLUGIN_LICENSE_GPL,476 PLUGIN_LICENSE_GPL,
349 drizzle_plugin::logging_query_plugin_init,477 drizzle_plugin::logging_query::init,
350 NULL,478 NULL,
351 drizzle_plugin::init_options479 drizzle_plugin::logging_query::init_options
352}480}
353DRIZZLE_DECLARE_PLUGIN_END;481DRIZZLE_DECLARE_PLUGIN_END;
354482
=== added directory 'plugin/logging_query/tests'
=== added file 'plugin/logging_query/tests/parse-query-log.sh'
--- plugin/logging_query/tests/parse-query-log.sh 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/parse-query-log.sh 2012-07-10 18:31:49 +0000
@@ -0,0 +1,2 @@
1#!/bin/sh
2wc -l "$1"|awk '{print($1)}'
03
=== added directory 'plugin/logging_query/tests/r'
=== added file 'plugin/logging_query/tests/r/file.result'
--- plugin/logging_query/tests/r/file.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/file.result 2012-07-10 18:31:49 +0000
@@ -0,0 +1,46 @@
1Log file exists
21
3SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
4Variable_name Value
5logging_query_enable OFF
6logging_query_pcre
7logging_query_threshold_big_examined 0
8logging_query_threshold_big_resultset 0
9logging_query_threshold_slow 0
101
11SET GLOBAL logging_query_enable=true;
12SELECT 1;
131
141
153
16SET GLOBAL logging_query_pcre="SHOW.+";
17SELECT @@logging_query_enable;
18@@logging_query_enable
191
204
21SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
22Variable_name Value
23logging_query_enable ON
24logging_query_pcre SHOW.+
25logging_query_threshold_big_examined 0
26logging_query_threshold_big_resultset 0
27logging_query_threshold_slow 0
285
29SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query1.log";
301
31SELECT @@logging_query_enable;
32@@logging_query_enable
331
345
351
36SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
37Variable_name Value
38logging_query_enable ON
39logging_query_pcre SHOW.+
40logging_query_threshold_big_examined 0
41logging_query_threshold_big_resultset 0
42logging_query_threshold_slow 0
435
442
45SET GLOBAL logging_query_filename="";
46ERROR HY000: Incorrect arguments to SET
047
=== added file 'plugin/logging_query/tests/r/thresholds.result'
--- plugin/logging_query/tests/r/thresholds.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/thresholds.result 2012-07-10 18:31:49 +0000
@@ -0,0 +1,54 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2SET GLOBAL logging_query_pcre=".+";
3SET GLOBAL logging_query_enable=true;
4SHOW VARIABLES LIKE 'logging_query_threshold%';
5Variable_name Value
6logging_query_threshold_big_examined 0
7logging_query_threshold_big_resultset 0
8logging_query_threshold_slow 0
9SET GLOBAL logging_query_threshold_slow=500000;
10SELECT @@logging_query_threshold_slow;
11@@logging_query_threshold_slow
12500000
13
14SELECT SLEEP(0.4);
15SLEEP(0.4)
160
171
18SELECT SLEEP(0.5);
19SLEEP(0.5)
200
212
22SET GLOBAL logging_query_threshold_slow=0;
23SELECT SLEEP(1);
24SLEEP(1)
250
264
27
28SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
29Variable_name Value
30logging_query_enable ON
31logging_query_pcre .+
32logging_query_threshold_big_examined 0
33logging_query_threshold_big_resultset 0
34logging_query_threshold_slow 0
352
36SET GLOBAL logging_query_threshold_big_resultset=2;
37SELECT "This should not be logged";
38This should not be logged
39This should not be logged
402
41
42SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
43Variable_name Value
44logging_query_enable ON
45logging_query_pcre .+
46logging_query_threshold_big_examined 0
47logging_query_threshold_big_resultset 2
48logging_query_threshold_slow 0
492
50SET GLOBAL logging_query_threshold_big_examined=2;
51SELECT "This should not be logged";
52This should not be logged
53This should not be logged
542
055
=== added directory 'plugin/logging_query/tests/t'
=== added file 'plugin/logging_query/tests/t/file.test'
--- plugin/logging_query/tests/t/file.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/file.test 2012-07-10 18:31:49 +0000
@@ -0,0 +1,81 @@
1
2# ###########################################################################
3# This tests the dynamic behaviour of logging_query plugin
4# ###########################################################################
5
6# Logging_query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not.
7--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
8--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
9# Clear log file.
10--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
11# Double-check that log file is clear.
12--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
13
14# Since logging_query_enable is OFF by default, this should not be logged into the log file.
15SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
16
17#This should not print anything
18--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
19
20#Enabling logging_query plugin
21SET GLOBAL logging_query_enable=true;
22
23#Now as logging_query_enable is set to true, this should be logged.
24SELECT 1;
25
26#This should print the content of log file as SET GLOBAL query and SELECT query
27--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
28
29#Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now.
30SET GLOBAL logging_query_pcre="SHOW.+";
31
32#This should not be logged
33SELECT @@logging_query_enable;
34
35#This should print the content of log file updated with
36--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
37
38#This should be logged
39SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
40
41#This should print the content of log file updated with SHOW query as it matched the regex.
42--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
43
44#Now changing the query log filename
45--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
46eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query1.log";
47--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
48#--exec if [ -f $DRIZZLETEST_VARDIR/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi
49
50# Clear log file.
51--exec echo "" > $DRIZZLETEST_VARDIR/logging_query1.log
52
53# Double-check that log file is clear.
54--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log
55
56#This should not be logged. Neither into new log file. Nor into new log file.
57SELECT @@logging_query_enable;
58
59#Checking the content of both the files.
60--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
61
62--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log
63
64#This should be logged into new log file
65SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
66
67#Checking the contents of boh the log files.
68--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
69
70--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log
71
72#Changing log file to null string. This should throw error.
73--error ER_WRONG_ARGUMENTS
74eval SET GLOBAL logging_query_filename="";
75
76--exec rm $DRIZZLETEST_VARDIR/logging_query*.log
77
78# ###########################################################################
79# Done.
80# ###########################################################################
81
082
=== added file 'plugin/logging_query/tests/t/master.opt'
--- plugin/logging_query/tests/t/master.opt 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/master.opt 2012-07-10 18:31:49 +0000
@@ -0,0 +1,1 @@
1--plugin-add=logging_query --logging-query.filename=$DRIZZLETEST_VARDIR/logging_query.log
02
=== added file 'plugin/logging_query/tests/t/thresholds.test'
--- plugin/logging_query/tests/t/thresholds.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/thresholds.test 2012-07-10 18:31:49 +0000
@@ -0,0 +1,87 @@
1
2# ###########################################################################
3# This tests the various logging_query_threshold_ variables.
4# ###########################################################################
5
6# First make sure the logging_query plugin is enabled.
7--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9eval SET GLOBAL logging_query_pcre=".+";
10--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
11SET GLOBAL logging_query_enable=true;
12
13# Make sure we have all our threshold variables and that they're all
14# off (zero) by default.
15SHOW VARIABLES LIKE 'logging_query_threshold%';
16
17# ###########################################################################
18# logging_query_threshold_slow
19# ###########################################################################
20
21# Set a 0.5s execution time threshold.
22SET GLOBAL logging_query_threshold_slow=500000;
23SELECT @@logging_query_threshold_slow;
24
25# Clear log file.
26--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
27# Double-check that log file is clear.
28--cat_file $DRIZZLETEST_VARDIR/logging_query.log
29
30# This query should *not* log since it's below the threshold.
31SELECT SLEEP(0.4);
32# This should not print anything.
33--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
34
35# This query should log since it's just a few microseconds past the threshold.
36SELECT SLEEP(0.5);
37--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
38
39# Set query_log_threshold_execution_time back to zero.
40SET GLOBAL logging_query_threshold_slow=0;
41#This should be logged
42SELECT SLEEP(1);
43--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
44
45# Clear log file.
46--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
47# Double-check that log file is clear.
48--cat_file $DRIZZLETEST_VARDIR/logging_query.log
49
50# ###########################################################################
51# logging_query_threshold_big_resultset
52# ###########################################################################
53# This should be logged
54SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
55--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
56SET GLOBAL logging_query_threshold_big_resultset=2;
57
58#This should not be logged
59SELECT "This should not be logged";
60--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
61
62# Clear log file.
63--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
64# Double-check that log file is clear.
65--cat_file $DRIZZLETEST_VARDIR/logging_query.log
66
67# ###########################################################################
68# logging_query_threshold_big_examined
69# ###########################################################################
70# This should be logged
71SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
72--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
73
74#Changing threshold_big_examined to 2, so that queries which examine less that 2 rows will not be logged
75SET GLOBAL logging_query_threshold_big_examined=2;
76#This should not be logged
77SELECT "This should not be logged";
78--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
79
80# ############################################################################
81# Clean up.
82# ############################################################################
83--exec rm $DRIZZLETEST_VARDIR/logging_query*.log
84
85# ###########################################################################
86# Done.
87# ###########################################################################

Subscribers

People subscribed via source and target branches

to all changes: