Merge lp:~sharan-monikantan/drizzle/trunk-bug-723915-fixed into lp:drizzle

Proposed by Sharan Kumar
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
Reviewer Review Type Date Requested Status
Patrick Crews Approve
Review via email: mp+128576@code.launchpad.net

Description of the change

The test suite for logging_query plugin has been updated with a lot of intense tests.

To post a comment you must log in.
Revision history for this message
Patrick Crews (patrick-crews) wrote :

Looks good. Thanks for taking the time to fix that one test and to create this suite of tests.

review: Approve
Revision history for this message
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.

Revision history for this message
Brian Aker (brianaker) wrote :

Running again.

Revision history for this message
Sharan Kumar (sharan-monikantan) wrote :

> Running again.
Is the test running without errors? Will this patch make it to the trunk?

Revision history for this message
Brian Aker (brianaker) wrote :

Still running:

https://jenkins.drizzle.org/job/Drizzle-Builder/78/console

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://code.launchpad.net/~sharan-monikantan/drizzle/trunk-bug-723915-fixed/+merge/128576
> Your team Drizzle Trunk is subscribed to branch lp:drizzle.

Revision history for this message
Brian Aker (brianaker) wrote :

Still failing:

https://jenkins.drizzle.org/job/drizzle-build-matrix/254/label=ubuntu-12.04/consoleFull

If you are on an Ubuntu box you can simulate this entire test run by running:

./bootstrap jenkins

Revision history for this message
Sharan Kumar (sharan-monikantan) wrote :

> Still failing:
>
> https://jenkins.drizzle.org/job/drizzle-build-
> matrix/254/label=ubuntu-12.04/consoleFull
>
> 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_query_enable=true' are getting logged ( this is the point where the plugin is enabled for the first time in the test, which means, queries following this statements should only be logged, right? ). I am not sure if that is to be logged or not, however, is that something unusual?

Revision history for this message
Brian Aker (brianaker) wrote :

From Jenkins:

https://jenkins.drizzle.org/job/drizzle-build-matrix/293/label=ubuntu-12.04/console

logging_query.select [ fail ]
--- ./plugin/logging_query/tests/r/select.result 2012-12-16 15:39:12.973392000 +0300
+++ ./plugin/logging_query/tests/r/select.reject 2012-12-16 16:33:36.880657220 +0300
@@ -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_query.thresholds [ pass ] 2488
logging_query.update [ fail ]
--- ./plugin/logging_query/tests/r/update.result 2012-12-16 15:39:12.973392000 +0300
+++ ./plugin/logging_query/tests/r/update.reject 2012-12-16 16:34:02.325636943 +0300
@@ -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_query_pcre="UPDATE.+";

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugin/logging_query/tests/parse-query-log.sh'
--- plugin/logging_query/tests/parse-query-log.sh 2012-07-10 18:29:14 +0000
+++ plugin/logging_query/tests/parse-query-log.sh 2012-10-08 20:02:27 +0000
@@ -1,2 +1,2 @@
1#!/bin/sh1#!/bin/sh
2wc -l "$1"|awk '{print($1)}'2wc -l "$1"|awk '{print("Number of queries logged : "$1)}'
33
=== added file 'plugin/logging_query/tests/r/blob.result'
--- plugin/logging_query/tests/r/blob.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/blob.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,46 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4# The logging_query plugin is not enabled and hence none of the following queries should be logged
5DROP SCHEMA IF EXISTS Blob_Test;
6Warnings:
7Note 1008 Can't drop schema 'Blob_Test'; schema doesn't exist
8CREATE SCHEMA Blob_Test;
9USE Blob_Test;
10CREATE TABLE test_blob (data BLOB);
11# Enabling the logging_query plugin
12SET GLOBAL logging_query_enable=true;
13Inserting blob data
14INSERT INTO test_blob VALUES (null);
15INSERT INTO test_blob VALUES ("");
16INSERT INTO test_blob VALUES ("A");
17INSERT INTO test_blob VALUES ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
18INSERT INTO test_blob VALUES ("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
19Number of queries logged : 7
20Selecting blob data
21SELECT data FROM test_blob WHERE data LIKE null;
22data
23SELECT data FROM test_blob WHERE data LIKE "";
24data
25
26SELECT data FROM test_blob WHERE data LIKE "A";
27data
28A
29SELECT data FROM test_blob WHERE LENGTH(data) < 100;
30data
31
32A
33aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
34SELECT data FROM test_blob WHERE LENGTH(data) > 1024;
35data
36ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
37Number of queries logged : 12
38Deleting blob data
39DELETE FROM test_blob WHERE data LIKE null;
40DELETE FROM test_blob WHERE LENGTH(data) > 1000;
41DELETE FROM test_blob WHERE data = 'A';
42Number of queries logged : 15
43cleaning up...
44SET GLOBAL logging_query_enable=false;
45DROP SCHEMA Blob_Test;
46***done***
047
=== added file 'plugin/logging_query/tests/r/create.result'
--- plugin/logging_query/tests/r/create.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/create.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,61 @@
1# Logging query plugin is loaded into the system. This checks if the file which we passed through the command line is opened or not
2SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
3Log file exists
4# Clearing the log file
5# Checking if the log file is cleared
6Number of queries logged : 1
7# The above command should print 1 indicating that the file is empty
8# Preparation phase completed
9
10# Starting the test
11# The logging_query is not enabled and hence the following query should not be logged
12DROP SCHEMA IF EXISTS test;
13CREATE SCHEMA test;
14# This should print 1 to indicate the log file is still empty
15Number of queries logged : 1
16# Enabling the logging_query plugin
17SET GLOBAL logging_query_enable=true;
18# The following queries should be logged
19DROP SCHEMA IF EXISTS test_db;
20Warnings:
21Note 1008 Can't drop schema 'test_db'; schema doesn't exist
22CREATE SCHEMA test_db;
23USE test_db;
24# This should print 6 indicating that the above queries are logged
25Number of queries logged : 6
26# Issuing another CREATE query. This should be logged
27CREATE TABLE Test_Entries (test_id INT, test_name VARCHAR(10));
28# This should print 7 to indicate that the above query is logged
29Number of queries logged : 7
30# Enabling logging_query pluging for only SELECT queries
31SET GLOBAL logging_query_pcre="SELECT.+";
32# The following CREATE query should not be logged
33CREATE TABLE Test_Entries_2 (test_id INT, test_name VARCHAR(10));
34# This should print 8 to indicate that the above query is not logged
35Number of queries logged : 8
36# The following SELECT query should be logged
37SELECT * FROM Test_Entries_2;
38test_id test_name
39# This should print 9 to indicate that the above query is logged
40Number of queries logged : 9
41# Enabling logging_query plugin for only CREATE queries
42SET GLOBAL logging_query_pcre="CREATE.+";
43# The following CREATE query should be logged
44DROP SCHEMA IF EXISTS test_db_2;
45Warnings:
46Note 1008 Can't drop schema 'test_db_2'; schema doesn't exist
47CREATE SCHEMA test_db_2;
48# This should print 11
49Number of queries logged : 11
50# The following SELECT query should not be logged
51SELECT * FROM Test_Entries_2;
52test_id test_name
53# This should print 11 indicating that the above query is not logged
54Number of queries logged : 11
55cleaning up...
56DROP SCHEMA test;
57DROP SCHEMA test_db;
58DROP SCHEMA test_db_2;
59SET GLOBAL logging_query_enable=false;
60SET GLOBAL logging_query_pcre=".+";
61***done***
062
=== added file 'plugin/logging_query/tests/r/datatypes_datetime.result'
--- plugin/logging_query/tests/r/datatypes_datetime.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/datatypes_datetime.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,117 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4# logging_query plugin is not enabled and hence none of the following queries should be logged
5DROP SCHEMA IF EXISTS Test;
6CREATE SCHEMA Test;
7USE Test;
8# Enabling the logging_query plugin
9SET GLOBAL logging_query_enable=true;
10#DATE
11CREATE TABLE test_date (type DATE);
12# Inserting a record with DATE value within the range
13INSERT INTO test_date VALUES ('1990-01-01');
14INSERT INTO test_date VALUES ('2012-01-01');
15# Inserting a record with DATE value on range border
16INSERT INTO test_date VALUES ('0001-01-01');
17INSERT INTO test_date VALUES ('9999-12-31');
18# Selecting the record
19SELECT type FROM test_date WHERE (EXTRACT(year FROM type) == 1990);
20type
211990-01-01
22SELECT type FROM test_date WHERE (EXTRACT(month FROM type) == 01);
23type
241990-01-01
252012-01-01
260001-01-01
27SELECT type FROM test_date WHERE (EXTRACT(day FROM type) == 31);
28type
299999-12-31
30# Deleting the record
31DELETE FROM test_date WHERE (EXTRACT(year FROM type) == 0001);
32DELETE FROM test_date WHERE (EXTRACT(month FROM type) == 01);
33DELETE FROM test_date WHERE (EXTRACT(day FROM type) == 31);
34# Selecting the record ; this should return a NULL set
35SELECT * FROM test_date;
36type
37Number of queries logged : 14
38#TIME
39CREATE TABLE test_time (type TIME);
40# Inserting a record with TIME value within the range
41INSERT INTO test_time VALUES ('09:00:00');
42INSERT INTO test_time VALUES ('15:00:00');
43# Inserting a record with TIME value on range border
44INSERT INTO test_time VALUES ('00:00:00');
45INSERT INTO test_time VALUES ('23:59:59');
46# Selecting the record
47SELECT type FROM test_time WHERE (HOUR(type) == 09);
48type
4909:00:00
50SELECT type FROM test_time WHERE (MINUTE(type) == 00);
51type
5209:00:00
5315:00:00
5400:00:00
55SELECT type FROM test_time WHERE (SECOND(type) == 59);
56type
5723:59:59
58# Deleting the record
59DELETE FROM test_time WHERE (HOUR(type) == 09);
60DELETE FROM test_time WHERE (MINUTE(type) == 00);
61DELETE FROM test_time WHERE (SECOND(type) == 59);
62# Selecting the record ; this should return a NULL set
63SELECT * FROM test_time;
64type
65Number of queries logged : 26
66#DATETIME
67CREATE TABLE test_datetime (type DATETIME);
68# Inserting a record with DATETIME value within the range
69INSERT INTO test_datetime VALUES ('1992-07-22 07:50:30');
70INSERT INTO test_datetime VALUES ('2012-09-29 20:49:50');
71# Insertingt a record with DATETIME value on range border
72INSERT INTO test_datetime VALUES ('0001-01-01 00:00:00');
73INSERT INTO test_datetime VALUES ('9999-12-31 23:59:59');
74# Selecting the record
75SELECT type FROM test_datetime WHERE (EXTRACT(year FROM type) == 1992);
76type
771992-07-22 07:50:30
78SELECT type FROM test_datetime WHERE (HOUR(type) == 07);
79type
801992-07-22 07:50:30
81# Deleting the record
82DELETE FROM test_datetime WHERE (EXTRACT(year FROM type) == 2012);
83DELETE FROM test_datetime WHERE (MINUTE(type) == 50);
84# Selecting the records ; this should return 2 records
85SELECT * FROM test_datetime;
86type
870001-01-01 00:00:00
889999-12-31 23:59:59
89Number of queries logged : 36
90#TIMESTAMP(6)
91CREATE TABLE test_timestamp (type TIMESTAMP(6));
92# Inserting a record with TIMESTAMP value within the range
93INSERT INTO test_timestamp VALUES ('1992-07-22 07:50:23.324543');
94INSERT INTO test_timestamp VALUES ('2012-09-29 23:12:20.232109');
95# Inserting a record with TIMESTAMP value on range border
96INSERT INTO test_timestamp VALUES ('1970-01-01 00:00:01.000000');
97INSERT INTO test_timestamp VALUES ('2038-01-19 03:14:07.999999');
98# Selecting the record
99SELECT type FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1970);
100type
1011970-01-01 00:00:01.000000
102SELECT type FROM test_timestamp WHERE (HOUR(type) == 03);
103type
1042038-01-19 03:14:07.999999
105# Deleting the record
106DELETE FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1992);
107DELETE FROM test_timestamp WHERE (MINUTE(type) == 12);
108# Selecting the records ; this should return 2 records
109SELECT * FROM test_timestamp;
110type
1111970-01-01 00:00:01.000000
1122038-01-19 03:14:07.999999
113Number of queries logged : 46
114cleaning up...
115SET GLOBAL logging_query_enable=false;
116DROP SCHEMA Test;
117***done***
0118
=== added file 'plugin/logging_query/tests/r/datatypes_numeric.result'
--- plugin/logging_query/tests/r/datatypes_numeric.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/datatypes_numeric.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,97 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4# logging_query plugin is not enabled and hence none of the following queries should be logged
5DROP SCHEMA IF EXISTS Test;
6CREATE SCHEMA Test;
7USE Test;
8# Enabling the logging_query plugin
9SET GLOBAL logging_query_enable=true;
10#INTEGER
11CREATE TABLE test_integer (type INTEGER);
12# Inserting a record with INTEGER value within range
13INSERT INTO test_integer VALUES (2147483645);
14INSERT INTO test_integer VALUES (-2147483645);
15# Inserting a record with INTEGER value on range borders
16INSERT INTO test_integer VALUES (2147483647);
17INSERT INTO test_integer VALUES (-2147483648);
18# Selecting the record from table
19SELECT type FROM test_integer WHERE type > 0;
20type
212147483645
222147483647
23SELECT type FROM test_integer WHERE type < 0;
24type
25-2147483645
26-2147483648
27# Deleting a record from table
28DELETE FROM test_integer WHERE type > 0;
29# This SELECT should return only two records
30SELECT * FROM test_integer;
31type
32-2147483645
33-2147483648
34# Deleting a record from table
35DELETE FROM test_integer WHERE type < 0;
36# This SELECT should return a NULL set
37SELECT * FROM test_integer;
38type
39Number of queries logged : 13
40#BIGINT
41CREATE TABLE test_bigint (type BIGINT);
42# Inserting a record with BIGINT value within range
43INSERT INTO test_bigint VALUES (9223372036854775805);
44INSERT INTO test_bigint VALUES (-9223372036854775805);
45# Inserting a record with BIGINT value on range borders
46INSERT INTO test_bigint VALUES (9223372036854775807);
47INSERT INTO test_bigint VALUES (-9223372036854775808);
48# Selecting the record from table
49SELECT type FROM test_bigint WHERE type > 0;
50type
519223372036854775805
529223372036854775807
53SELECT type FROM test_bigint WHERE type < 0;
54type
55-9223372036854775805
56-9223372036854775808
57# Deleting a record from table
58DELETE FROM test_bigint WHERE type > 0;
59# This SELECT should return only two records
60SELECT * FROM test_bigint;
61type
62-9223372036854775805
63-9223372036854775808
64# Deleting a record from table
65DELETE FROM test_bigint WHERE type < 0;
66# This SELECT should return a NULL set
67SELECT * FROM test_bigint;
68type
69Number of queries logged : 24
70#DOUBLE
71CREATE TABLE test_double (type DOUBLE);
72#Inserting a record with DOUBLE value within range
73INSERT INTO test_double VALUES (-1.7976931348623155E+308);
74INSERT INTO test_double VALUES (1.7976931348623157E+308);
75# Selecting the record from table
76SELECT type FROM test_double WHERE type > 0;
77type
781.79769313486232e308
79SELECT type FROM test_double WHERE type < 0;
80type
81-1.79769313486232e308
82# Deleting a record from table
83DELETE FROM test_double WHERE type > 0;
84# This SELECT should return only one record
85SELECT * FROM test_double;
86type
87-1.79769313486232e308
88# Deleting a record from table
89DELETE FROM test_double WHERE type < 0;
90# This SELECT should return a NULL set
91SELECT * FROM test_double;
92type
93Number of queries logged : 33
94cleaning up...
95SET GLOBAL logging_query_enable=false;
96DROP SCHEMA Test;
97***done***
098
=== added file 'plugin/logging_query/tests/r/datatypes_string.result'
--- plugin/logging_query/tests/r/datatypes_string.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/datatypes_string.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,62 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4# logging_query plugin is not enabled and hence none of the following queries should be logged
5DROP SCHEMA IF EXISTS Test;
6CREATE SCHEMA Test;
7USE Test;
8# Enabling the logging_query plugin
9SET GLOBAL logging_query_enable=true;
10#VARCHAR
11CREATE TABLE test_varchar (type VARCHAR(10));
12# Inserting a record with VARCHAR length within range
13INSERT INTO test_varchar VALUES ('varchar');
14INSERT INTO test_varchar VALUES ('sql');
15# Inserting a record with VARCHAR length on range borders
16INSERT INTO test_varchar VALUES ('drizzle-DB');
17INSERT INTO test_varchar VALUES ('');
18# Selecting records from table
19SELECT type FROM test_varchar WHERE LENGTH(type) = 3;
20type
21sql
22SELECT type FROM test_varchar WHERE LENGTH(type) = 0;
23type
24
25# Deleting records
26DELETE FROM test_varchar WHERE type LIKE REVERSE('rahcrav');
27DELETE FROM test_varchar WHERE type LIKE SUBSTRING('mysql',3);
28# Selecting records from table ; this should return 2 rows
29SELECT * FROM test_varchar;
30type
31drizzle-DB
32
33Number of queries logged : 12
34#ENUM
35CREATE TABLE test_enum (type ENUM('one','two','three','four','five','six','seven','eight','nine','ten'));
36# Inserting a record with ENUM value within range
37INSERT INTO test_enum VALUES (3);
38INSERT INTO test_enum VALUES (7);
39# Inserting a record with ENUM value on range border
40INSERT INTO test_enum VALUES (1);
41INSERT INTO test_enum VALUES (9);
42# Selecting records from table
43SELECT type FROM test_enum WHERE type > 5;
44type
45seven
46nine
47SELECT type FROM test_enum WHERE type < 5;
48type
49three
50one
51# Deleting records
52DELETE FROM test_enum WHERE type = 9;
53DELETE FROM test_enum WHERE type > 1;
54# Selecting records from table ; this should return 1 row
55SELECT * FROM test_enum;
56type
57one
58Number of queries logged : 22
59cleaning up...
60SET GLOBAL logging_query_enable=false;
61DROP SCHEMA Test;
62***done***
063
=== added file 'plugin/logging_query/tests/r/delete.result'
--- plugin/logging_query/tests/r/delete.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/delete.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,104 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4Preparing the test bed...
5# The logging_query plugin is not yet enabled and hence none of the queries in the prepare phase should be logged
6DROP SCHEMA IF EXISTS Test_Delete;
7Warnings:
8Note 1008 Can't drop schema 'Test_Delete'; schema doesn't exist
9CREATE SCHEMA Test_Delete;
10DROP SCHEMA IF EXISTS Test_Truncate;
11Warnings:
12Note 1008 Can't drop schema 'Test_Truncate'; schema doesn't exist
13CREATE SCHEMA Test_Truncate;
14DROP SCHEMA IF EXISTS Test_Drop;
15Warnings:
16Note 1008 Can't drop schema 'Test_Drop'; schema doesn't exist
17CREATE SCHEMA Test_Drop;
18# Preparing test bed for DELETE test
19USE Test_Delete;
20CREATE TABLE test_delete_1 ( test_id INT, test_name CHAR(10) );
21INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
22CREATE TABLE test_delete_2 ( test_id INT, test_name VARCHAR(10) );
23INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
24# Preparing test bed for TRUNCATE test
25USE Test_Truncate;
26CREATE TABLE test_truncate_1 ( test_id INT, test_name CHAR(10) );
27INSERT INTO test_truncate_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
28CREATE TABLE test_truncate_2 ( test_id INT, test_name CHAR(10) );
29INSERT INTO test_truncate_2 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
30# Preparing test bed for DROP test
31USE Test_Drop;
32CREATE TABLE test_drop ( test_id INT, test_name CHAR(10) );
33CREATE INDEX index_id ON test_drop ( test_id );
34INSERT INTO test_drop VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
35# This should print 1 indicating that, the log file is still empty
36Number of queries logged : 1
37# enabling the logging_query plugin
38SET GLOBAL logging_query_enable=true;
39# Now the tests begin!!!
40DELETE test in progress...
41USE Test_Delete;
42# The following 2 queries should be logged
43DELETE FROM test_delete_1;
44# The following query should return a null set
45SELECT * FROM test_delete_1;
46test_id test_name
47# enabling the logging_query plugin to log only DELETE queries
48SET GLOBAL logging_query_pcre="DELETE.+";
49# The following DELETE queries should be logged
50DELETE FROM test_delete_2 WHERE test_id = 1;
51DELETE FROM test_delete_2 WHERE test_name = "select";
52# The following query should select only tuples with id = (3,4,5) and this query should not be logged
53SELECT * FROM test_delete_2;
54test_id test_name
55# enabling the logging_query plugin to log SELECT queries
56SET GLOBAL logging_query_pcre="SELECT.+";
57# The following DELETE query should not be logged
58DELETE FROM test_delete_2;
59# The following SELECT query should return a null set and should be logged
60SELECT * FROM test_delete_2;
61test_id test_name
62# Delete test is completed. Now checking the logging_query.log file. This should print 10
63Number of queries logged : 10
64TRUNCATE test in progress...
65USE Test_Truncate;
66# enabling the logging_query plugin to log TRUNCATE queries
67SET GLOBAL logging_query_pcre="TRUNCATE.+";
68# The following TRUNCATE query should be logged
69TRUNCATE TABLE test_truncate_1;
70# This SELECT query should not be logged ; this should return a null set
71SELECT * FROM test_truncate_1;
72test_id test_name
73# enabling the logging_query plugin to log RENAME query
74SET GLOBAL logging_query_pcre="RENAME.+";
75# The following RENAME query should be logged
76RENAME TABLE test_truncate_2 TO test_truncate;
77# This TRUNCATE query should not be logged
78TRUNCATE TABLE test_truncate;
79# This SELECT query should not be logged ; this should return a null set
80SELECT * FROM test_truncate;
81test_id test_name
82# Truncate test is completed. Now checking the logging_query.log file. This should print 14
83Number of queries logged : 14
84DROP test in progress...
85USE Test_Drop;
86# enabling the logging_query plugin to log DROP queries
87SET GLOBAL logging_query_pcre="DROP.+";
88# dropping an index ; this query should be logged since it is a DROP query ( though implemented through ALTER query )
89ALTER TABLE test_drop DROP INDEX index_id;
90# dropping a table ; this query should be logged
91DROP TABLE test_drop;
92# dropping a schema ; this query should be logged
93DROP SCHEMA Test_Drop;
94# Drop test is completed. Now checking the logging_query.log file. This should print 18
95Number of queries logged : 18
96cleaning up...
97SET GLOBAL logging_query_enable=false;
98SET GLOBAL logging_query_pcre=".+";
99DROP SCHEMA IF EXISTS Test_Delete;
100DROP SCHEMA IF EXISTS Test_Truncate;
101DROP SCHEMA IF EXISTS Test_Drop;
102Warnings:
103Note 1008 Can't drop schema 'Test_Drop'; schema doesn't exist
104***done***
0105
=== modified file 'plugin/logging_query/tests/r/file.result'
--- plugin/logging_query/tests/r/file.result 2012-07-10 18:29:14 +0000
+++ plugin/logging_query/tests/r/file.result 2012-10-08 20:02:27 +0000
@@ -1,23 +1,33 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
1Log file exists2Log file exists
213Number of queries logged : 1
4# Since logging_query_enable is OFF by default, this should not be logged into the log file.
3SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";5SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
4Variable_name Value6Variable_name Value
5logging_query_enable OFF7logging_query_enable OFF
6logging_query_pcre 8logging_query_pcre .+
7logging_query_threshold_big_examined 09logging_query_threshold_big_examined 0
8logging_query_threshold_big_resultset 010logging_query_threshold_big_resultset 0
9logging_query_threshold_slow 011logging_query_threshold_slow 0
10112#This should not print anything
13Number of queries logged : 1
14#Enabling logging_query plugin
11SET GLOBAL logging_query_enable=true;15SET GLOBAL logging_query_enable=true;
16#Now as logging_query_enable is set to true, this should be logged.
12SELECT 1;17SELECT 1;
131181
141191
15320#This should print the content of log file as SET GLOBAL query and SELECT query
21Number of queries logged : 3
22#Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now.
16SET GLOBAL logging_query_pcre="SHOW.+";23SET GLOBAL logging_query_pcre="SHOW.+";
24#This should not be logged
17SELECT @@logging_query_enable;25SELECT @@logging_query_enable;
18@@logging_query_enable26@@logging_query_enable
191271
20428#This should print the content of log file updated with
29Number of queries logged : 4
30#This should be logged
21SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";31SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
22Variable_name Value32Variable_name Value
23logging_query_enable ON33logging_query_enable ON
@@ -25,14 +35,22 @@
25logging_query_threshold_big_examined 035logging_query_threshold_big_examined 0
26logging_query_threshold_big_resultset 036logging_query_threshold_big_resultset 0
27logging_query_threshold_slow 037logging_query_threshold_slow 0
28538#This should print the content of log file updated with SHOW query as it matched the regex.
39Number of queries logged : 5
40#Now changing the query log filename
29SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query1.log";41SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query1.log";
30142New log file exists
43# Clear log file.
44# Double-check that log file is clear.
45Number of queries logged : 1
46#This should not be logged. Neither into new log file. Nor into new log file.
31SELECT @@logging_query_enable;47SELECT @@logging_query_enable;
32@@logging_query_enable48@@logging_query_enable
331491
34550#Checking the content of both the files.
35151Number of queries logged : 5
52Number of queries logged : 1
53#This should be logged into new log file
36SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";54SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
37Variable_name Value55Variable_name Value
38logging_query_enable ON56logging_query_enable ON
@@ -40,7 +58,14 @@
40logging_query_threshold_big_examined 058logging_query_threshold_big_examined 0
41logging_query_threshold_big_resultset 059logging_query_threshold_big_resultset 0
42logging_query_threshold_slow 060logging_query_threshold_slow 0
43561#Checking the contents of boh the log files.
44262Number of queries logged : 5
63Number of queries logged : 2
64#Changing log file to null string. This should throw error.
45SET GLOBAL logging_query_filename="";65SET GLOBAL logging_query_filename="";
46ERROR HY000: Incorrect arguments to SET66ERROR HY000: Incorrect arguments to SET
67cleaning up...
68SET GLOBAL logging_query_enable=false;
69SET GLOBAL logging_query_pcre="*";
70SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
71***done***
4772
=== added file 'plugin/logging_query/tests/r/insert.result'
--- plugin/logging_query/tests/r/insert.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/insert.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,85 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4preparing the test bed...
5# The logging_query plugin is not enabled and hence the following queries should not be logged
6DROP SCHEMA IF EXISTS Test;
7CREATE SCHEMA Test;
8USE Test;
9CREATE TABLE test_info (test_id INT, test_name VARCHAR(10));
10INSERT INTO test_info (test_id,test_name) VALUES (0,null);
11# This should print 1 indicating the log file is still empty
12Number of queries logged : 1
13
14# Now the test begins!!!
15# Enabling the logging_query plugin
16SET GLOBAL logging_query_enable=true;
17# The following queries should be logged
18INSERT INTO test_info (test_id) VALUES (1);
19INSERT INTO test_info (test_id,test_name) VALUES (1,"create");
20INSERT INTO test_info VALUES (2,"select");
21SELECT * FROM test_info;
22test_id test_name
230 NULL
241 NULL
251 create
262 select
27# This should print 6 indicating that, all of the above queries are logged
28Number of queries logged : 6
29# Enabling the logging_query plugin to log only INSERT queries
30SET GLOBAL logging_query_pcre="INSERT.+";
31# The following INSERT query should be logged
32INSERT INTO test_info (test_id,test_name) VALUES (3,"insert");
33INSERT INTO test_info VALUES (4,"drop"),(5,"delete");
34SELECT test_name FROM test_info;
35test_name
36NULL
37NULL
38create
39select
40insert
41drop
42delete
43DELETE FROM test_info WHERE test_id = 0;
44SELECT * FROM test_info;
45test_id test_name
461 NULL
471 create
482 select
493 insert
504 drop
515 delete
52# This should print 9 indicating that, only the INSERT queries were logged
53Number of queries logged : 9
54# Enabling the logging_query plugin to log SELECT queries
55SET GLOBAL logging_query_pcre="SELECT.+";
56# The following INSERT queries should NOT be logged
57INSERT INTO test_info VALUES (5,"delete");
58SELECT test_name AS tests FROM test_info;
59tests
60NULL
61create
62select
63insert
64drop
65delete
66delete
67SELECT * FROM test_info WHERE test_id > 3;
68test_id test_name
694 drop
705 delete
715 delete
72# This should print 12 indicating that, the INSERT query is NOT logged
73Number of queries logged : 12
74# Enabling the logging_query plugin to log DELETE queries
75SET GLOBAL logging_query_pcre="DELETE.+";
76# The following INSERT queries should NOT be logged
77INSERT INTO test_info VALUES (6,""),(7,"enums");
78DELETE FROM test_info WHERE test_id=6 OR 7;
79# This should print 14 indicating that, the INSERT query is NOT Logged
80Number of queries logged : 14
81cleaning up...
82SET GLOBAL logging_query_enable=false;
83SET GLOBAL logging_query_pcre=".+";
84DROP SCHEMA Test;
85***done***
086
=== added file 'plugin/logging_query/tests/r/select.result'
--- plugin/logging_query/tests/r/select.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/select.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,130 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4Preparing the test bed...
5CREATE SCHEMA Select_Test;
6USE Select_Test;
7CREATE TABLE select_test_1 (id INT, type CHAR(20));
8INSERT INTO select_test_1 VALUES (1,"basic select"),(2,"select distinct"),(3,"select with where"),(4,"select with orderby");
9CREATE TABLE select_test_2 (id INT, time FLOAT);
10INSERT INTO select_test_2 VALUES (1,10.01),(2,9.38),(3,5.6),(4,6.7);
11prepare phase completed...
12
13Testing basic select queries.
14# The logging_query is not enabled and hence the following select queries should not be logged
15SELECT 1;
161
171
18SELECT "logging_query";
19logging_query
20logging_query
21# This should print 1 to indicate the log file is still empty
22Number of queries logged : 1
23
24# Enabling the logging_query plugin
25SET GLOBAL logging_query_enable=true;
26
27# The logging_query is enabled and the following select query should be logged
28SELECT 1;
291
301
31# This should print 3 indicating that the above query is logged
32Number of queries logged : 3
33# Issuing another select query
34SELECT "hello world";
35hello world
36hello world
37# This should print 4 indicating that the above query is logged
38Number of queries logged : 4
39
40# Enabling the logging_query to log only SHOW queries
41SET GLOBAL logging_query_pcre="SHOW.+";
42
43# The following query should be logged
44SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
45Variable_name Value
46logging_query_enable ON
47logging_query_pcre SHOW.+
48logging_query_threshold_big_examined 0
49logging_query_threshold_big_resultset 0
50logging_query_threshold_slow 0
51# This should print 6 indicating that the above query is logged
52Number of queries logged : 6
53
54# The following select query should not be logged
55SELECT 1;
561
571
58# This should print 4 indicating that the above query is not logged
59Number of queries logged : 6
60# Basic test completed...
61
62drilling the SELECT queries test.
63# Enabling the logging_query plugin to log SELECT queries
64# ( since here after, the test deals with variants of SELECT queries and all such should be checked against logging)
65SET GLOBAL logging_query_pcre="SELECT.+";
66
67# Testing for select with distinct
68# The following queries should be logged
69SELECT DISTINCT * FROM select_test_1;
70id type
711 basic select
722 select distinct
733 select with where
744 select with orderby
75SELECT DISTINCT * FROM select_test_2;
76id time
771 10.01
782 9.38
793 5.6
804 6.7
81# This should print 9 indicating that the above queries are logged
82Number of queries logged : 9
83
84# Testing for select with where
85# The following queries should be logged
86SELECT * FROM select_test_1 WHERE id = 2;
87id type
882 select distinct
89SELECT * FROM select_test_1 WHERE type = "select with where";
90id type
913 select with where
92SELECT time FROM select_test_2 WHERE id >= 2;
93time
949.38
955.6
966.7
97SELECT id FROM select_test_2 WHERE time < 6;
98id
993
100# This should print 13 indicating that the above queries are logged
101Number of queries logged : 13
102
103# Testing for select with order by
104# The following queries should be logged
105SELECT * FROM select_test_2 ORDER BY id DESC;
106id time
1074 6.7
1083 5.6
1092 9.38
1101 10.01
111SELECT time FROM select_test_2 ORDER BY time;
112time
1135.6
1146.7
1159.38
11610.01
117SELECT id FROM select_test_2 ORDER BY time DESC;
118id
1191
1202
1214
1223
123# This should print 16 indicating all the above queries are logged
124Number of queries logged : 16
125
126cleaning up...
127DROP SCHEMA Select_Test;
128SET GLOBAL logging_query_enable=false;
129SET GLOBAL logging_query_pcre=".+";
130***done***
0131
=== modified file 'plugin/logging_query/tests/r/thresholds.result'
--- plugin/logging_query/tests/r/thresholds.result 2012-07-10 18:29:14 +0000
+++ plugin/logging_query/tests/r/thresholds.result 2012-10-08 20:02:27 +0000
@@ -14,16 +14,16 @@
14SELECT SLEEP(0.4);14SELECT SLEEP(0.4);
15SLEEP(0.4)15SLEEP(0.4)
160160
17117Number of queries logged : 1
18SELECT SLEEP(0.5);18SELECT SLEEP(0.5);
19SLEEP(0.5)19SLEEP(0.5)
200200
21221Number of queries logged : 2
22SET GLOBAL logging_query_threshold_slow=0;22SET GLOBAL logging_query_threshold_slow=0;
23SELECT SLEEP(1);23SELECT SLEEP(1);
24SLEEP(1)24SLEEP(1)
250250
26426Number of queries logged : 4
2727
28SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";28SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
29Variable_name Value29Variable_name Value
@@ -32,12 +32,12 @@
32logging_query_threshold_big_examined 032logging_query_threshold_big_examined 0
33logging_query_threshold_big_resultset 033logging_query_threshold_big_resultset 0
34logging_query_threshold_slow 034logging_query_threshold_slow 0
35235Number of queries logged : 2
36SET GLOBAL logging_query_threshold_big_resultset=2;36SET GLOBAL logging_query_threshold_big_resultset=2;
37SELECT "This should not be logged";37SELECT "This should not be logged";
38This should not be logged38This should not be logged
39This should not be logged39This should not be logged
40240Number of queries logged : 2
4141
42SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";42SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
43Variable_name Value43Variable_name Value
@@ -46,9 +46,13 @@
46logging_query_threshold_big_examined 046logging_query_threshold_big_examined 0
47logging_query_threshold_big_resultset 247logging_query_threshold_big_resultset 2
48logging_query_threshold_slow 048logging_query_threshold_slow 0
49249Number of queries logged : 2
50SET GLOBAL logging_query_threshold_big_examined=2;50SET GLOBAL logging_query_threshold_big_examined=2;
51SELECT "This should not be logged";51SELECT "This should not be logged";
52This should not be logged52This should not be logged
53This should not be logged53This should not be logged
54254Number of queries logged : 2
55cleaning up...
56SET GLOBAL logging_query_enable=false;
57SET GLOBAL logging_query_pcre=".+";
58***done***
5559
=== added file 'plugin/logging_query/tests/r/update.result'
--- plugin/logging_query/tests/r/update.result 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/r/update.result 2012-10-08 20:02:27 +0000
@@ -0,0 +1,62 @@
1SET GLOBAL logging_query_filename="DRIZZLETEST_VARDIR/logging_query.log";
2Log file exists
3Number of queries logged : 1
4preparing the test bed...
5# The logging_query plugin is not enabled and hence none of the queries in prepare phase should be logged
6CREATE SCHEMA Test_Update;
7USE Test_Update;
8CREATE TABLE test_info (id INT, name CHAR(10));
9INSERT INTO test_info VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
10# This should print 1 indicating that the log file is still empty
11Number of queries logged : 1
12
13UPDATE test in progress...
14# The logging_query plugin is not enabled and the following update query should not be logged
15UPDATE test_info SET name="CREATE" WHERE id=1;
16# This should print 1 indicating that the log file is still empty
17Number of queries logged : 1
18
19# Enabling the logging_query plugin
20SET GLOBAL logging_query_enable=true;
21
22# The logging_query plugin is enabled and the following update query should be logged
23UPDATE test_info SET name="SELECT" WHERE id=2;
24# This should print 3 indicating that the above query is logged
25Number of queries logged : 1
26
27# Enabling the logging_query plugin to log only select queries
28SET GLOBAL logging_query_pcre="SELECT.+";
29
30# The following UPDATE query should not be logged
31UPDATE test_info SET name="INSERT" WHERE id=3;
32SELECT * FROM test_info;
33id name
341 CREATE
352 SELECT
363 INSERT
374 update
385 delete
39# This should print 5 indicating that, only the UPDATE query is NOT logged
40Number of queries logged : 2
41
42# Enabling the logging_query plugin to log UPDATE queries
43SET GLOBAL logging_query_pcre="UPDATE.+";
44
45# The followihng UPDATE query should be logged
46UPDATE test_info SET name="UPDATE" WHERE id=6;
47# The above query will not update the table since a tuple with id=6 does not exist
48SELECT * FROM test_info;
49id name
501 CREATE
512 SELECT
523 INSERT
534 update
545 delete
55# This should print 7 indicating that, only the UPDATE query is logged and not the select query
56Number of queries logged : 2
57
58cleaning up...
59SET GLOBAL logging_query_enable=false;
60SET GLOBAL logging_query_pcre=".+";
61DROP SCHEMA Test_Update;
62***done***
063
=== added file 'plugin/logging_query/tests/t/blob.test'
--- plugin/logging_query/tests/t/blob.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/blob.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,84 @@
1
2# ###########################################################################################
3# This test runs several tests against the BLOB type
4# ###########################################################################################
5
6# logging_query plugin is loaded into the system. This is to check that the file passed through the command line is opened or not
7--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "log file does not exist"; fi
10
11# Clearing the log file
12--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
13# Checking if the file is cleared or not
14--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
15# The above command should print 1 indicating that the log file is empty
16
17--echo # The logging_query plugin is not enabled and hence none of the following queries should be logged
18DROP SCHEMA IF EXISTS Blob_Test;
19CREATE SCHEMA Blob_Test;
20USE Blob_Test;
21CREATE TABLE test_blob (data BLOB);
22
23--echo # Enabling the logging_query plugin
24SET GLOBAL logging_query_enable=true;
25
26# ###########################################################################################
27# Insert BLOB data
28# ###########################################################################################
29
30--echo Inserting blob data
31INSERT INTO test_blob VALUES (null);
32INSERT INTO test_blob VALUES ("");
33INSERT INTO test_blob VALUES ("A");
34INSERT INTO test_blob VALUES ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
35INSERT INTO test_blob VALUES ("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
36
37# Testing if the above queries are logged
38--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
39
40
41# ###########################################################################################
42# Select BLOB data
43# ###########################################################################################
44
45--echo Selecting blob data
46SELECT data FROM test_blob WHERE data LIKE null;
47SELECT data FROM test_blob WHERE data LIKE "";
48SELECT data FROM test_blob WHERE data LIKE "A";
49SELECT data FROM test_blob WHERE LENGTH(data) < 100;
50SELECT data FROM test_blob WHERE LENGTH(data) > 1024;
51
52
53# Testing if the above queries are logged
54--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
55
56
57# ###########################################################################################
58# Deleting BLOB data
59# ###########################################################################################
60
61--echo Deleting blob data
62DELETE FROM test_blob WHERE data LIKE null;
63DELETE FROM test_blob WHERE LENGTH(data) > 1000;
64DELETE FROM test_blob WHERE data = 'A';
65
66
67# Testing if the above queries are logged
68--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
69
70
71
72# ####################################################################################################
73# Cleaning up
74# ####################################################################################################
75--echo cleaning up...
76SET GLOBAL logging_query_enable=false;
77DROP SCHEMA Blob_Test;
78--exec rm $DRIZZLETEST_VARDIR/logging_query.log
79--echo ***done***
80
81# ####################################################################################################
82# Done
83# ####################################################################################################
84
085
=== added file 'plugin/logging_query/tests/t/create.test'
--- plugin/logging_query/tests/t/create.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/create.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,80 @@
1
2# ##################################################################################
3# This tests the logging_query plugin for various create queries
4# ##################################################################################
5
6--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
7--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
10
11--echo # Clearing the log file
12--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
13--echo # Checking if the log file is cleared
14--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
15--echo # The above command should print 1 indicating that the file is empty
16--echo # Preparation phase completed
17--echo
18
19--echo # Starting the test
20--echo # The logging_query is not enabled and hence the following query should not be logged
21DROP SCHEMA IF EXISTS test;
22CREATE SCHEMA test;
23--echo # This should print 1 to indicate the log file is still empty
24--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
25
26--echo # Enabling the logging_query plugin
27SET GLOBAL logging_query_enable=true;
28
29--echo # The following queries should be logged
30DROP SCHEMA IF EXISTS test_db;
31CREATE SCHEMA test_db;
32USE test_db;
33--echo # This should print 6 indicating that the above queries are logged
34--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
35
36--echo # Issuing another CREATE query. This should be logged
37CREATE TABLE Test_Entries (test_id INT, test_name VARCHAR(10));
38--echo # This should print 7 to indicate that the above query is logged
39--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
40
41--echo # Enabling logging_query pluging for only SELECT queries
42SET GLOBAL logging_query_pcre="SELECT.+";
43
44--echo # The following CREATE query should not be logged
45CREATE TABLE Test_Entries_2 (test_id INT, test_name VARCHAR(10));
46--echo # This should print 8 to indicate that the above query is not logged
47--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
48--echo # The following SELECT query should be logged
49SELECT * FROM Test_Entries_2;
50--echo # This should print 9 to indicate that the above query is logged
51--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
52
53--echo # Enabling logging_query plugin for only CREATE queries
54SET GLOBAL logging_query_pcre="CREATE.+";
55
56--echo # The following CREATE query should be logged
57DROP SCHEMA IF EXISTS test_db_2;
58CREATE SCHEMA test_db_2;
59--echo # This should print 11
60--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
61--echo # The following SELECT query should not be logged
62SELECT * FROM Test_Entries_2;
63--echo # This should print 11 indicating that the above query is not logged
64--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
65
66# ###################################################################################
67# Clean up
68# ###################################################################################
69--echo cleaning up...
70DROP SCHEMA test;
71DROP SCHEMA test_db;
72DROP SCHEMA test_db_2;
73SET GLOBAL logging_query_enable=false;
74SET GLOBAL logging_query_pcre=".+";
75--exec rm $DRIZZLETEST_VARDIR/logging_query.log
76--echo ***done***
77
78# ###################################################################################
79# Done
80# ###################################################################################
081
=== added file 'plugin/logging_query/tests/t/datatypes_datetime.test'
--- plugin/logging_query/tests/t/datatypes_datetime.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/datatypes_datetime.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,151 @@
1
2# ##############################################################################################################################################
3# Test for Drizzle's datatypes
4# 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)
5# cases:
6# 1.Type
7# 2.Range
8# 3.Select, Insert, Delete queries
9# ##############################################################################################################################################
10
11# logging_query plugin is loaded into the system and this checks if the file we passed through the command line is opened or not
12--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
13eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
14--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
15
16# Clearing the log file
17--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
18# Checking if the file is cleared or not
19--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
20# The above command should print 1 indicating that the log file is empty
21
22# ###################################################################################################
23# Preparing the test bed
24# ###################################################################################################
25
26--echo # logging_query plugin is not enabled and hence none of the following queries should be logged
27DROP SCHEMA IF EXISTS Test;
28CREATE SCHEMA Test;
29USE Test;
30
31--echo # Enabling the logging_query plugin
32SET GLOBAL logging_query_enable=true;
33
34# ###################################################################################################
35# DATE
36# ###################################################################################################
37
38--echo #DATE
39CREATE TABLE test_date (type DATE);
40--echo # Inserting a record with DATE value within the range
41INSERT INTO test_date VALUES ('1990-01-01');
42INSERT INTO test_date VALUES ('2012-01-01');
43--echo # Inserting a record with DATE value on range border
44INSERT INTO test_date VALUES ('0001-01-01');
45INSERT INTO test_date VALUES ('9999-12-31');
46--echo # Selecting the record
47SELECT type FROM test_date WHERE (EXTRACT(year FROM type) == 1990);
48SELECT type FROM test_date WHERE (EXTRACT(month FROM type) == 01);
49SELECT type FROM test_date WHERE (EXTRACT(day FROM type) == 31);
50--echo # Deleting the record
51DELETE FROM test_date WHERE (EXTRACT(year FROM type) == 0001);
52DELETE FROM test_date WHERE (EXTRACT(month FROM type) == 01);
53DELETE FROM test_date WHERE (EXTRACT(day FROM type) == 31);
54--echo # Selecting the record ; this should return a NULL set
55SELECT * FROM test_date;
56
57# Testing if the above queries are logged
58--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
59
60
61# ####################################################################################################
62# TIME
63# ####################################################################################################
64
65--echo #TIME
66CREATE TABLE test_time (type TIME);
67--echo # Inserting a record with TIME value within the range
68INSERT INTO test_time VALUES ('09:00:00');
69INSERT INTO test_time VALUES ('15:00:00');
70--echo # Inserting a record with TIME value on range border
71INSERT INTO test_time VALUES ('00:00:00');
72INSERT INTO test_time VALUES ('23:59:59');
73--echo # Selecting the record
74SELECT type FROM test_time WHERE (HOUR(type) == 09);
75SELECT type FROM test_time WHERE (MINUTE(type) == 00);
76SELECT type FROM test_time WHERE (SECOND(type) == 59);
77--echo # Deleting the record
78DELETE FROM test_time WHERE (HOUR(type) == 09);
79DELETE FROM test_time WHERE (MINUTE(type) == 00);
80DELETE FROM test_time WHERE (SECOND(type) == 59);
81--echo # Selecting the record ; this should return a NULL set
82SELECT * FROM test_time;
83
84# Testing if the above queries are logged
85--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
86
87
88# ####################################################################################################
89# DATETIME
90# ####################################################################################################
91
92--echo #DATETIME
93CREATE TABLE test_datetime (type DATETIME);
94--echo # Inserting a record with DATETIME value within the range
95INSERT INTO test_datetime VALUES ('1992-07-22 07:50:30');
96INSERT INTO test_datetime VALUES ('2012-09-29 20:49:50');
97--echo # Insertingt a record with DATETIME value on range border
98INSERT INTO test_datetime VALUES ('0001-01-01 00:00:00');
99INSERT INTO test_datetime VALUES ('9999-12-31 23:59:59');
100--echo # Selecting the record
101SELECT type FROM test_datetime WHERE (EXTRACT(year FROM type) == 1992);
102SELECT type FROM test_datetime WHERE (HOUR(type) == 07);
103--echo # Deleting the record
104DELETE FROM test_datetime WHERE (EXTRACT(year FROM type) == 2012);
105DELETE FROM test_datetime WHERE (MINUTE(type) == 50);
106--echo # Selecting the records ; this should return 2 records
107SELECT * FROM test_datetime;
108
109
110# Testing if the above queries are logged
111--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
112
113
114# ####################################################################################################
115# TIMESTAMP(6)
116# ####################################################################################################
117
118--echo #TIMESTAMP(6)
119CREATE TABLE test_timestamp (type TIMESTAMP(6));
120--echo # Inserting a record with TIMESTAMP value within the range
121INSERT INTO test_timestamp VALUES ('1992-07-22 07:50:23.324543');
122INSERT INTO test_timestamp VALUES ('2012-09-29 23:12:20.232109');
123--echo # Inserting a record with TIMESTAMP value on range border
124INSERT INTO test_timestamp VALUES ('1970-01-01 00:00:01.000000');
125INSERT INTO test_timestamp VALUES ('2038-01-19 03:14:07.999999');
126--echo # Selecting the record
127SELECT type FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1970);
128SELECT type FROM test_timestamp WHERE (HOUR(type) == 03);
129--echo # Deleting the record
130DELETE FROM test_timestamp WHERE (EXTRACT(year FROM type) == 1992);
131DELETE FROM test_timestamp WHERE (MINUTE(type) == 12);
132--echo # Selecting the records ; this should return 2 records
133SELECT * FROM test_timestamp;
134
135
136# Testing if the above queries are logged
137--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
138
139
140# ####################################################################################################
141# Cleaning up
142# ####################################################################################################
143--echo cleaning up...
144SET GLOBAL logging_query_enable=false;
145DROP SCHEMA Test;
146--exec rm $DRIZZLETEST_VARDIR/logging_query.log
147--echo ***done***
148
149# ####################################################################################################
150# Done
151# ####################################################################################################
0152
=== added file 'plugin/logging_query/tests/t/datatypes_numeric.test'
--- plugin/logging_query/tests/t/datatypes_numeric.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/datatypes_numeric.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,126 @@
1
2# ##############################################################################################################################################
3# Test for Drizzle's datatypes
4# 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)
5# cases:
6# 1.Type
7# 2.Range
8# 3.Select, Insert, Delete queries
9# ##############################################################################################################################################
10
11# logging_query plugin is loaded into the system and this checks if the file we passed through the command line is opened or not
12--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
13eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
14--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
15
16# Clearing the log file
17--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
18# Checking if the file is cleared or not
19--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
20# The above command should print 1 indicating that the log file is empty
21
22# ###################################################################################################
23# Preparing the test bed
24# ###################################################################################################
25
26--echo # logging_query plugin is not enabled and hence none of the following queries should be logged
27DROP SCHEMA IF EXISTS Test;
28CREATE SCHEMA Test;
29USE Test;
30
31--echo # Enabling the logging_query plugin
32SET GLOBAL logging_query_enable=true;
33
34# ####################################################################################################
35# INTEGER
36# ####################################################################################################
37
38--echo #INTEGER
39CREATE TABLE test_integer (type INTEGER);
40--echo # Inserting a record with INTEGER value within range
41INSERT INTO test_integer VALUES (2147483645);
42INSERT INTO test_integer VALUES (-2147483645);
43--echo # Inserting a record with INTEGER value on range borders
44INSERT INTO test_integer VALUES (2147483647);
45INSERT INTO test_integer VALUES (-2147483648);
46--echo # Selecting the record from table
47SELECT type FROM test_integer WHERE type > 0;
48SELECT type FROM test_integer WHERE type < 0;
49--echo # Deleting a record from table
50DELETE FROM test_integer WHERE type > 0;
51--echo # This SELECT should return only two records
52SELECT * FROM test_integer;
53--echo # Deleting a record from table
54DELETE FROM test_integer WHERE type < 0;
55--echo # This SELECT should return a NULL set
56SELECT * FROM test_integer;
57
58# Testing if the above queries are logged
59--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
60
61
62# ####################################################################################################
63# BIGINT
64# ####################################################################################################
65
66--echo #BIGINT
67CREATE TABLE test_bigint (type BIGINT);
68--echo # Inserting a record with BIGINT value within range
69INSERT INTO test_bigint VALUES (9223372036854775805);
70INSERT INTO test_bigint VALUES (-9223372036854775805);
71--echo # Inserting a record with BIGINT value on range borders
72INSERT INTO test_bigint VALUES (9223372036854775807);
73INSERT INTO test_bigint VALUES (-9223372036854775808);
74--echo # Selecting the record from table
75SELECT type FROM test_bigint WHERE type > 0;
76SELECT type FROM test_bigint WHERE type < 0;
77--echo # Deleting a record from table
78DELETE FROM test_bigint WHERE type > 0;
79--echo # This SELECT should return only two records
80SELECT * FROM test_bigint;
81--echo # Deleting a record from table
82DELETE FROM test_bigint WHERE type < 0;
83--echo # This SELECT should return a NULL set
84SELECT * FROM test_bigint;
85
86# Testing if the above queries are logged
87--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
88
89
90# ####################################################################################################
91# DOUBLE
92# ####################################################################################################
93
94--echo #DOUBLE
95CREATE TABLE test_double (type DOUBLE);
96--echo #Inserting a record with DOUBLE value within range
97INSERT INTO test_double VALUES (-1.7976931348623155E+308);
98INSERT INTO test_double VALUES (1.7976931348623157E+308);
99--echo # Selecting the record from table
100SELECT type FROM test_double WHERE type > 0;
101SELECT type FROM test_double WHERE type < 0;
102--echo # Deleting a record from table
103DELETE FROM test_double WHERE type > 0;
104--echo # This SELECT should return only one record
105SELECT * FROM test_double;
106--echo # Deleting a record from table
107DELETE FROM test_double WHERE type < 0;
108--echo # This SELECT should return a NULL set
109SELECT * FROM test_double;
110
111# Testing if the above queries are logged
112--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
113
114
115# ####################################################################################################
116# Cleaning up
117# ####################################################################################################
118--echo cleaning up...
119SET GLOBAL logging_query_enable=false;
120DROP SCHEMA Test;
121--exec rm $DRIZZLETEST_VARDIR/logging_query.log
122--echo ***done***
123
124# ####################################################################################################
125# Done
126# ####################################################################################################
0127
=== added file 'plugin/logging_query/tests/t/datatypes_string.test'
--- plugin/logging_query/tests/t/datatypes_string.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/datatypes_string.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,111 @@
1
2# ##############################################################################################################################################
3# Test for Drizzle's datatypes
4# 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)
5# cases:
6# 1.Type
7# 2.Range
8# 3.Select, Insert, Delete queries
9# ##############################################################################################################################################
10
11# logging_query plugin is loaded into the system and this checks if the file we passed through the command line is opened or not
12--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
13eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
14--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
15
16# Clearing the log file
17--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
18# Checking if the file is cleared or not
19--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
20# The above command should print 1 indicating that the log file is empty
21
22# ###################################################################################################
23# Preparing the test bed
24# ###################################################################################################
25
26--echo # logging_query plugin is not enabled and hence none of the following queries should be logged
27DROP SCHEMA IF EXISTS Test;
28CREATE SCHEMA Test;
29USE Test;
30
31--echo # Enabling the logging_query plugin
32SET GLOBAL logging_query_enable=true;
33
34# ###################################################################################################
35# VARCHAR
36# ###################################################################################################
37
38--echo #VARCHAR
39CREATE TABLE test_varchar (type VARCHAR(10));
40--echo # Inserting a record with VARCHAR length within range
41INSERT INTO test_varchar VALUES ('varchar');
42INSERT INTO test_varchar VALUES ('sql');
43--echo # Inserting a record with VARCHAR length on range borders
44INSERT INTO test_varchar VALUES ('drizzle-DB');
45INSERT INTO test_varchar VALUES ('');
46--echo # Selecting records from table
47SELECT type FROM test_varchar WHERE LENGTH(type) = 3;
48SELECT type FROM test_varchar WHERE LENGTH(type) = 0;
49--echo # Deleting records
50DELETE FROM test_varchar WHERE type LIKE REVERSE('rahcrav');
51DELETE FROM test_varchar WHERE type LIKE SUBSTRING('mysql',3);
52--echo # Selecting records from table ; this should return 2 rows
53SELECT * FROM test_varchar;
54
55
56# Testing if the above queries are logged
57--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
58
59
60
61# ####################################################################################################
62# ENUM
63# ####################################################################################################
64
65--echo #ENUM
66CREATE TABLE test_enum (type ENUM('one','two','three','four','five','six','seven','eight','nine','ten'));
67--echo # Inserting a record with ENUM value within range
68INSERT INTO test_enum VALUES (3);
69INSERT INTO test_enum VALUES (7);
70--echo # Inserting a record with ENUM value on range border
71INSERT INTO test_enum VALUES (1);
72INSERT INTO test_enum VALUES (9);
73--echo # Selecting records from table
74SELECT type FROM test_enum WHERE type > 5;
75SELECT type FROM test_enum WHERE type < 5;
76--echo # Deleting records
77DELETE FROM test_enum WHERE type = 9;
78DELETE FROM test_enum WHERE type > 1;
79--echo # Selecting records from table ; this should return 1 row
80SELECT * FROM test_enum;
81
82
83# Testing if the above queries are logged
84--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
85
86
87
88# ####################################################################################################
89# Cleaning up
90# ####################################################################################################
91--echo cleaning up...
92SET GLOBAL logging_query_enable=false;
93DROP SCHEMA Test;
94--exec rm $DRIZZLETEST_VARDIR/logging_query.log
95--echo ***done***
96
97# ####################################################################################################
98# Done
99# ####################################################################################################
100
101
102
103
104
105
106
107
108
109
110
111
0112
=== added file 'plugin/logging_query/tests/t/delete.test'
--- plugin/logging_query/tests/t/delete.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/delete.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,152 @@
1
2# #############################################################################################
3# This tests the logging_query plugin for delete, truncate and drop statements
4# #############################################################################################
5
6# logging_query plugin is loaded into the system. This checks if the file passed through the command line argument is opened or not
7--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
10
11# Clearing the log file
12--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
13# Checking if the log file is cleared
14--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
15# The above command should print 1 indicating the log file is empty
16
17# #############################################################################################
18# Preparing the test bed
19# #############################################################################################
20--echo Preparing the test bed...
21
22--echo # The logging_query plugin is not yet enabled and hence none of the queries in the prepare phase should be logged
23DROP SCHEMA IF EXISTS Test_Delete;
24CREATE SCHEMA Test_Delete;
25DROP SCHEMA IF EXISTS Test_Truncate;
26CREATE SCHEMA Test_Truncate;
27DROP SCHEMA IF EXISTS Test_Drop;
28CREATE SCHEMA Test_Drop;
29--echo # Preparing test bed for DELETE test
30USE Test_Delete;
31CREATE TABLE test_delete_1 ( test_id INT, test_name CHAR(10) );
32INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
33CREATE TABLE test_delete_2 ( test_id INT, test_name VARCHAR(10) );
34INSERT INTO test_delete_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
35--echo # Preparing test bed for TRUNCATE test
36USE Test_Truncate;
37CREATE TABLE test_truncate_1 ( test_id INT, test_name CHAR(10) );
38INSERT INTO test_truncate_1 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
39CREATE TABLE test_truncate_2 ( test_id INT, test_name CHAR(10) );
40INSERT INTO test_truncate_2 VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
41--echo # Preparing test bed for DROP test
42USE Test_Drop;
43CREATE TABLE test_drop ( test_id INT, test_name CHAR(10) );
44CREATE INDEX index_id ON test_drop ( test_id );
45INSERT INTO test_drop VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
46
47--echo # This should print 1 indicating that, the log file is still empty
48--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
49
50
51
52--echo # enabling the logging_query plugin
53SET GLOBAL logging_query_enable=true;
54--echo # Now the tests begin!!!
55
56# #############################################################################################
57# Test: DELETE
58# #############################################################################################
59--echo DELETE test in progress...
60USE Test_Delete;
61
62--echo # The following 2 queries should be logged
63DELETE FROM test_delete_1;
64--echo # The following query should return a null set
65SELECT * FROM test_delete_1;
66
67--echo # enabling the logging_query plugin to log only DELETE queries
68SET GLOBAL logging_query_pcre="DELETE.+";
69
70--echo # The following DELETE queries should be logged
71DELETE FROM test_delete_2 WHERE test_id = 1;
72DELETE FROM test_delete_2 WHERE test_name = "select";
73--echo # The following query should select only tuples with id = (3,4,5) and this query should not be logged
74SELECT * FROM test_delete_2;
75
76--echo # enabling the logging_query plugin to log SELECT queries
77SET GLOBAL logging_query_pcre="SELECT.+";
78
79--echo # The following DELETE query should not be logged
80DELETE FROM test_delete_2;
81--echo # The following SELECT query should return a null set and should be logged
82SELECT * FROM test_delete_2;
83
84--echo # Delete test is completed. Now checking the logging_query.log file. This should print 10
85--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
86
87
88# #############################################################################################
89# Test: TRUNCATE
90# #############################################################################################
91--echo TRUNCATE test in progress...
92USE Test_Truncate;
93
94--echo # enabling the logging_query plugin to log TRUNCATE queries
95SET GLOBAL logging_query_pcre="TRUNCATE.+";
96
97--echo # The following TRUNCATE query should be logged
98TRUNCATE TABLE test_truncate_1;
99--echo # This SELECT query should not be logged ; this should return a null set
100SELECT * FROM test_truncate_1;
101
102--echo # enabling the logging_query plugin to log RENAME query
103SET GLOBAL logging_query_pcre="RENAME.+";
104
105--echo # The following RENAME query should be logged
106RENAME TABLE test_truncate_2 TO test_truncate;
107--echo # This TRUNCATE query should not be logged
108TRUNCATE TABLE test_truncate;
109--echo # This SELECT query should not be logged ; this should return a null set
110SELECT * FROM test_truncate;
111
112--echo # Truncate test is completed. Now checking the logging_query.log file. This should print 14
113--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
114
115
116# #############################################################################################
117# Test: Drop
118# #############################################################################################
119--echo DROP test in progress...
120USE Test_Drop;
121
122--echo # enabling the logging_query plugin to log DROP queries
123SET GLOBAL logging_query_pcre="DROP.+";
124
125--echo # dropping an index ; this query should be logged since it is a DROP query ( though implemented through ALTER query )
126ALTER TABLE test_drop DROP INDEX index_id;
127
128--echo # dropping a table ; this query should be logged
129DROP TABLE test_drop;
130
131--echo # dropping a schema ; this query should be logged
132DROP SCHEMA Test_Drop;
133
134--echo # Drop test is completed. Now checking the logging_query.log file. This should print 18
135--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
136
137
138# #############################################################################################
139# Cleaning up
140# #############################################################################################
141--echo cleaning up...
142SET GLOBAL logging_query_enable=false;
143SET GLOBAL logging_query_pcre=".+";
144DROP SCHEMA IF EXISTS Test_Delete;
145DROP SCHEMA IF EXISTS Test_Truncate;
146DROP SCHEMA IF EXISTS Test_Drop;
147--exec rm $DRIZZLETEST_VARDIR/logging_query.log
148--echo ***done***
149
150# #############################################################################################
151# Done
152# #############################################################################################
0153
=== removed file 'plugin/logging_query/tests/t/file.bak'
--- plugin/logging_query/tests/t/file.bak 2012-09-30 18:45:40 +0000
+++ plugin/logging_query/tests/t/file.bak 1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
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
820
=== 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-10-08 20:02:27 +0000
@@ -0,0 +1,92 @@
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
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
10# Clear log file.
11--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
12# Double-check that log file is clear.
13--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
14
15--echo # Since logging_query_enable is OFF by default, this should not be logged into the log file.
16SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
17
18--echo #This should not print anything
19--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
20
21--echo #Enabling logging_query plugin
22SET GLOBAL logging_query_enable=true;
23
24--echo #Now as logging_query_enable is set to true, this should be logged.
25SELECT 1;
26
27--echo #This should print the content of log file as SET GLOBAL query and SELECT query
28--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
29
30--echo #Setting logging_query_pcre as "SHOW.+". Only queries starting with 'SHOW' will be logged from now.
31SET GLOBAL logging_query_pcre="SHOW.+";
32
33--echo #This should not be logged
34SELECT @@logging_query_enable;
35
36--echo #This should print the content of log file updated with
37--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
38
39--echo #This should be logged
40SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
41
42--echo #This should print the content of log file updated with SHOW query as it matched the regex.
43--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
44
45--echo #Now changing the query log filename
46--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
47eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query1.log";
48
49--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
50--exec if [ -f $DRIZZLETEST_VARDIR/logging_query1.log ]; then echo "New log file exists"; else echo "New log file does not exist"; fi
51
52--echo # Clear log file.
53--exec echo "" > $DRIZZLETEST_VARDIR/logging_query1.log
54
55--echo # Double-check that log file is clear.
56--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log
57
58--echo #This should not be logged. Neither into new log file. Nor into new log file.
59SELECT @@logging_query_enable;
60
61--echo #Checking the content of both the files.
62--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
63
64--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log
65
66--echo #This should be logged into new log file
67SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
68
69--echo #Checking the contents of boh the log files.
70--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
71
72--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query1.log
73
74--echo #Changing log file to null string. This should throw error.
75--error ER_WRONG_ARGUMENTS
76eval SET GLOBAL logging_query_filename="";
77
78# ###################################################################################
79# Clean up
80# ###################################################################################
81--echo cleaning up...
82SET GLOBAL logging_query_enable=false;
83SET GLOBAL logging_query_pcre="*";
84--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
85eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
86--exec rm $DRIZZLETEST_VARDIR/logging_query.log
87--echo ***done***
88
89# ###################################################################################
90# Done.
91# ###################################################################################
92
093
=== added file 'plugin/logging_query/tests/t/insert.test'
--- plugin/logging_query/tests/t/insert.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/insert.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,87 @@
1
2# ####################################################################################################
3# This tests the logging_query plugin for various insert statements
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
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
10
11# Clearing the log file
12--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
13# Checking if the log file is cleared
14--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
15# The above command should print 1 to indicate the log file is empty
16
17# ####################################################################################################
18# Preparing the test bed
19# ####################################################################################################
20--echo preparing the test bed...
21
22--echo # The logging_query plugin is not enabled and hence the following queries should not be logged
23DROP SCHEMA IF EXISTS Test;
24CREATE SCHEMA Test;
25USE Test;
26CREATE TABLE test_info (test_id INT, test_name VARCHAR(10));
27INSERT INTO test_info (test_id,test_name) VALUES (0,null);
28--echo # This should print 1 indicating the log file is still empty
29--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
30--echo
31
32--echo # Now the test begins!!!
33--echo # Enabling the logging_query plugin
34SET GLOBAL logging_query_enable=true;
35
36--echo # The following queries should be logged
37INSERT INTO test_info (test_id) VALUES (1);
38INSERT INTO test_info (test_id,test_name) VALUES (1,"create");
39INSERT INTO test_info VALUES (2,"select");
40SELECT * FROM test_info;
41--echo # This should print 6 indicating that, all of the above queries are logged
42--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
43
44--echo # Enabling the logging_query plugin to log only INSERT queries
45SET GLOBAL logging_query_pcre="INSERT.+";
46
47--echo # The following INSERT query should be logged
48INSERT INTO test_info (test_id,test_name) VALUES (3,"insert");
49INSERT INTO test_info VALUES (4,"drop"),(5,"delete");
50SELECT test_name FROM test_info;
51DELETE FROM test_info WHERE test_id = 0;
52SELECT * FROM test_info;
53--echo # This should print 9 indicating that, only the INSERT queries were logged
54--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
55
56--echo # Enabling the logging_query plugin to log SELECT queries
57SET GLOBAL logging_query_pcre="SELECT.+";
58
59--echo # The following INSERT queries should NOT be logged
60INSERT INTO test_info VALUES (5,"delete");
61SELECT test_name AS tests FROM test_info;
62SELECT * FROM test_info WHERE test_id > 3;
63--echo # This should print 12 indicating that, the INSERT query is NOT logged
64--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
65
66--echo # Enabling the logging_query plugin to log DELETE queries
67SET GLOBAL logging_query_pcre="DELETE.+";
68
69--echo # The following INSERT queries should NOT be logged
70INSERT INTO test_info VALUES (6,""),(7,"enums");
71DELETE FROM test_info WHERE test_id=6 OR 7;
72--echo # This should print 14 indicating that, the INSERT query is NOT Logged
73--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
74
75# ####################################################################################################
76# Cleaning up
77# ####################################################################################################
78--echo cleaning up...
79SET GLOBAL logging_query_enable=false;
80SET GLOBAL logging_query_pcre=".+";
81DROP SCHEMA Test;
82--exec rm $DRIZZLETEST_VARDIR/logging_query.log
83--echo ***done***
84
85# ####################################################################################################
86# Done
87# ####################################################################################################
088
=== added file 'plugin/logging_query/tests/t/select.test'
--- plugin/logging_query/tests/t/select.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/select.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,128 @@
1
2# ##################################################################################
3# This tests the logging_query plugin for various select instances
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
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
10
11# Clearing the log file
12--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
13# Checking if the log file is cleared
14--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
15# The above command should print 1 to indicate that the log file is empty
16
17# ##################################################################################
18# Preparing the test bed
19# ##################################################################################
20--echo Preparing the test bed...
21CREATE SCHEMA Select_Test;
22USE Select_Test;
23CREATE TABLE select_test_1 (id INT, type CHAR(20));
24INSERT INTO select_test_1 VALUES (1,"basic select"),(2,"select distinct"),(3,"select with where"),(4,"select with orderby");
25CREATE TABLE select_test_2 (id INT, time FLOAT);
26INSERT INTO select_test_2 VALUES (1,10.01),(2,9.38),(3,5.6),(4,6.7);
27--echo prepare phase completed...
28--echo
29
30# ###################################################################################
31# Basic SELECT queries
32# ###################################################################################
33--echo Testing basic select queries.
34--echo # The logging_query is not enabled and hence the following select queries should not be logged
35SELECT 1;
36SELECT "logging_query";
37--echo # This should print 1 to indicate the log file is still empty
38--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
39--echo
40
41--echo # Enabling the logging_query plugin
42SET GLOBAL logging_query_enable=true;
43--echo
44
45--echo # The logging_query is enabled and the following select query should be logged
46SELECT 1;
47--echo # This should print 3 indicating that the above query is logged
48--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
49--echo # Issuing another select query
50SELECT "hello world";
51--echo # This should print 4 indicating that the above query is logged
52--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
53--echo
54
55--echo # Enabling the logging_query to log only SHOW queries
56SET GLOBAL logging_query_pcre="SHOW.+";
57--echo
58
59--echo # The following query should be logged
60SHOW VARIABLES WHERE Variable_Name NOT LIKE "%logging_query_filename%" AND Variable_Name LIKE "%logging_query%";
61--echo # This should print 6 indicating that the above query is logged
62--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
63--echo
64
65--echo # The following select query should not be logged
66SELECT 1;
67--echo # This should print 4 indicating that the above query is not logged
68--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
69--echo # Basic test completed...
70--echo
71
72
73--echo drilling the SELECT queries test.
74--echo # Enabling the logging_query plugin to log SELECT queries
75--echo # ( since here after, the test deals with variants of SELECT queries and all such should be checked against logging)
76SET GLOBAL logging_query_pcre="SELECT.+";
77--echo
78
79# ##################################################################################
80# SELECT with DISTINCT
81# ##################################################################################
82--echo # Testing for select with distinct
83--echo # The following queries should be logged
84SELECT DISTINCT * FROM select_test_1;
85SELECT DISTINCT * FROM select_test_2;
86--echo # This should print 9 indicating that the above queries are logged
87--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
88--echo
89
90# ##################################################################################
91# SELECT with WHERE
92# ##################################################################################
93--echo # Testing for select with where
94--echo # The following queries should be logged
95SELECT * FROM select_test_1 WHERE id = 2;
96SELECT * FROM select_test_1 WHERE type = "select with where";
97SELECT time FROM select_test_2 WHERE id >= 2;
98SELECT id FROM select_test_2 WHERE time < 6;
99--echo # This should print 13 indicating that the above queries are logged
100--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
101--echo
102
103# ##################################################################################
104# SELECT with ORDER BY
105# ##################################################################################
106--echo # Testing for select with order by
107--echo # The following queries should be logged
108SELECT * FROM select_test_2 ORDER BY id DESC;
109SELECT time FROM select_test_2 ORDER BY time;
110SELECT id FROM select_test_2 ORDER BY time DESC;
111--echo # This should print 16 indicating all the above queries are logged
112--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
113--echo
114
115
116# ##################################################################################
117# Cleaning up
118# ##################################################################################
119--echo cleaning up...
120DROP SCHEMA Select_Test;
121SET GLOBAL logging_query_enable=false;
122SET GLOBAL logging_query_pcre=".+";
123--exec rm $DRIZZLETEST_VARDIR/logging_query.log
124--echo ***done***
125
126# ##################################################################################
127# Done
128# ##################################################################################
0129
=== removed file 'plugin/logging_query/tests/t/thresholds.bak'
--- plugin/logging_query/tests/t/thresholds.bak 2012-09-30 21:58:50 +0000
+++ plugin/logging_query/tests/t/thresholds.bak 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
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# ###########################################################################
880
=== 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-10-08 20:02:27 +0000
@@ -0,0 +1,91 @@
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--echo cleaning up...
84SET GLOBAL logging_query_enable=false;
85SET GLOBAL logging_query_pcre=".+";
86--exec rm $DRIZZLETEST_VARDIR/logging_query*.log
87--echo ***done***
88
89# ###########################################################################
90# Done.
91# ###########################################################################
092
=== added file 'plugin/logging_query/tests/t/update.test'
--- plugin/logging_query/tests/t/update.test 1970-01-01 00:00:00 +0000
+++ plugin/logging_query/tests/t/update.test 2012-10-08 20:02:27 +0000
@@ -0,0 +1,88 @@
1
2# #########################################################################################
3# This tests the logging_query plugin for various update statements
4# #########################################################################################
5
6# 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
7--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
8eval SET GLOBAL logging_query_filename="$DRIZZLETEST_VARDIR/logging_query.log";
9--exec if [ -f $DRIZZLETEST_VARDIR/logging_query.log ]; then echo "Log file exists"; else echo "Log file does not exist"; fi
10
11# Clearing the log file
12--exec echo "" > $DRIZZLETEST_VARDIR/logging_query.log
13# Checking if the log file is empty or not
14--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
15# The above command should print 1 indicating that the log file is still empty
16
17# #########################################################################################
18# Preparing the test bed
19# #########################################################################################
20--echo preparing the test bed...
21
22--echo # The logging_query plugin is not enabled and hence none of the queries in prepare phase should be logged
23CREATE SCHEMA Test_Update;
24USE Test_Update;
25CREATE TABLE test_info (id INT, name CHAR(10));
26INSERT INTO test_info VALUES (1,"create"),(2,"select"),(3,"insert"),(4,"update"),(5,"delete");
27--echo # This should print 1 indicating that the log file is still empty
28--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
29--echo
30
31# #########################################################################################
32# UPDATE test
33# #########################################################################################
34--echo UPDATE test in progress...
35
36--echo # The logging_query plugin is not enabled and the following update query should not be logged
37UPDATE test_info SET name="CREATE" WHERE id=1;
38--echo # This should print 1 indicating that the log file is still empty
39--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
40--echo
41
42--echo # Enabling the logging_query plugin
43SET GLOBAL logging_query_enable=true;
44--echo
45
46--echo # The logging_query plugin is enabled and the following update query should be logged
47UPDATE test_info SET name="SELECT" WHERE id=2;
48--echo # This should print 3 indicating that the above query is logged
49--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
50--echo
51
52--echo # Enabling the logging_query plugin to log only select queries
53SET GLOBAL logging_query_pcre="SELECT.+";
54--echo
55
56--echo # The following UPDATE query should not be logged
57UPDATE test_info SET name="INSERT" WHERE id=3;
58SELECT * FROM test_info;
59--echo # This should print 5 indicating that, only the UPDATE query is NOT logged
60--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
61--echo
62
63--echo # Enabling the logging_query plugin to log UPDATE queries
64SET GLOBAL logging_query_pcre="UPDATE.+";
65--echo
66
67--echo # The followihng UPDATE query should be logged
68UPDATE test_info SET name="UPDATE" WHERE id=6;
69--echo # The above query will not update the table since a tuple with id=6 does not exist
70SELECT * FROM test_info;
71--echo # This should print 7 indicating that, only the UPDATE query is logged and not the select query
72--exec $TOP_SRCDIR/plugin/logging_query/tests/parse-query-log.sh $DRIZZLETEST_VARDIR/logging_query.log
73--echo
74
75# #########################################################################################
76# Clean up
77# #########################################################################################
78--echo cleaning up...
79SET GLOBAL logging_query_enable=false;
80SET GLOBAL logging_query_pcre=".+";
81DROP SCHEMA Test_Update;
82--exec rm $DRIZZLETEST_VARDIR/logging_query.log
83--echo ***done***
84
85# #########################################################################################
86# Done
87# #########################################################################################
88

Subscribers

People subscribed via source and target branches

to all changes: