| 1 |
--source include/xplugin_wait_for_interfaces.inc |
| 2 |
--disable_ps_protocol |
| 3 |
|
| 4 |
--echo # Setting general_log content empty. |
| 5 |
TRUNCATE TABLE mysql.general_log; |
| 6 |
|
| 7 |
--echo # Creating tables |
| 8 |
CREATE TABLE t_int (c1 TINYINT, |
| 9 |
c2 SMALLINT, |
| 10 |
c3 MEDIUMINT, |
| 11 |
c4 INT, |
| 12 |
c5 INTEGER, |
| 13 |
c6 SMALLINT UNSIGNED, |
| 14 |
c7 MEDIUMINT UNSIGNED, |
| 15 |
c8 INT UNSIGNED, |
| 16 |
c9 INTEGER); |
| 17 |
|
| 18 |
CREATE TABLE t_bigint (c1 BIGINT, |
| 19 |
c2 BIGINT UNSIGNED); |
| 20 |
|
| 21 |
CREATE TABLE t_real (c1 REAL UNSIGNED, |
| 22 |
c2 DOUBLE UNSIGNED, |
| 23 |
c3 FLOAT UNSIGNED, |
| 24 |
c4 DECIMAL UNSIGNED, |
| 25 |
c5 NUMERIC UNSIGNED, |
| 26 |
c6 DOUBLE, |
| 27 |
c7 FLOAT, |
| 28 |
c8 DECIMAL, |
| 29 |
c9 NUMERIC); |
| 30 |
|
| 31 |
CREATE TABLE t_date (c1 DATE, |
| 32 |
c2 TIME, |
| 33 |
c3 TIMESTAMP, |
| 34 |
c4 DATETIME, |
| 35 |
c5 YEAR); |
| 36 |
|
| 37 |
--echo # Inserting values into the tables |
| 38 |
INSERT INTO t_int VALUES (91,92,93,94,95,96,97,98,99),(81,82,83,84,85,86,87,88,89); |
| 39 |
|
| 40 |
INSERT INTO t_bigint VALUES (91,92),(81,82); |
| 41 |
|
| 42 |
INSERT INTO t_real VALUES (8.51,8.52,8.53,8.54,8.55,8.56,8.57,8.58,8.59); |
| 43 |
|
| 44 |
INSERT INTO t_real VALUES (9.51,9.52,9.53,9.54,9.55,9.56,9.57,9.58,9.59); |
| 45 |
|
| 46 |
INSERT INTO t_date VALUES ('2015-07-06','20:15','2015-12-31 14:59:48','2014-11-30 13:58:47','2015'); |
| 47 |
|
| 48 |
INSERT INTO t_date VALUES ('2015-07-07','20:17','2013-12-31 17:59:47','2012-10-31 15:57:47','2010'); |
| 49 |
|
| 50 |
SET @old_log_output = @@global.log_output; |
| 51 |
SET @old_general_log = @@global.general_log; |
| 52 |
SET @old_general_log_file = @@global.general_log_file; |
| 53 |
|
| 54 |
--echo ########################################## |
| 55 |
--echo # Start plugin with general log |
| 56 |
--echo ########################################## |
| 57 |
--replace_result $MYSQLTEST_VARDIR ... |
| 58 |
eval SET GLOBAL general_log_file = '$MYSQLTEST_VARDIR/log/test_sql_general.log'; |
| 59 |
SET GLOBAL log_output = 'FILE,TABLE'; |
| 60 |
SET GLOBAL general_log = 'ON'; |
| 61 |
|
| 62 |
--echo ########################################## |
| 63 |
--echo # Run plugin |
| 64 |
--echo ########################################## |
| 65 |
--replace_result $TEST_SQL_2_SESSIONS TEST_SQL_2_SESSIONS |
| 66 |
eval INSTALL PLUGIN test_sql_2_sessions SONAME '$TEST_SQL_2_SESSIONS'; |
| 67 |
|
| 68 |
--echo ########################################## |
| 69 |
--echo # Stop plugin |
| 70 |
--echo ########################################## |
| 71 |
UNINSTALL PLUGIN test_sql_2_sessions; |
| 72 |
|
| 73 |
--echo ########################################## |
| 74 |
--echo # Plugin log |
| 75 |
--echo ########################################## |
| 76 |
let $MYSQLD_DATADIR= `select @@datadir`; |
| 77 |
cat_file $MYSQLD_DATADIR/test_sql_2_sessions.log; |
| 78 |
remove_file $MYSQLD_DATADIR/test_sql_2_sessions.log; |
| 79 |
|
| 80 |
--echo ########################################## |
| 81 |
--echo # Check general log file |
| 82 |
--echo ########################################## |
| 83 |
CREATE TABLE t1 (c1 TEXT, c2 TEXT, c3 TEXT); |
| 84 |
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 85 |
--disable_warnings |
| 86 |
eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/log/test_sql_general.log' INTO TABLE t1; |
| 87 |
--enable_warnings |
| 88 |
|
| 89 |
SELECT c3 FROM t1 WHERE c3 LIKE '%FROM test.t_int%'; |
| 90 |
SELECT c3 FROM t1 WHERE c3 LIKE '%FROM test.t_bigint%'; |
| 91 |
|
| 92 |
SELECT count(*) FROM t1 WHERE c2 LIKE '%Connect%'; |
| 93 |
SELECT count(*) FROM t1 WHERE c2 LIKE '%Quit%'; |
| 94 |
|
| 95 |
SELECT argument FROM mysql.general_log WHERE command_type = 'Query' AND |
| 96 |
(argument LIKE '%FROM test.t_int%' OR |
| 97 |
argument LIKE '%FROM test.t_bigint%'); |
| 98 |
|
| 99 |
SELECT count(*) FROM mysql.general_log WHERE command_type = 'Connect'; |
| 100 |
SELECT count(*) FROM mysql.general_log WHERE command_type = 'Quit'; |
| 101 |
|
| 102 |
--echo ########################################## |
| 103 |
--echo # Cleanup |
| 104 |
--echo ########################################## |
| 105 |
|
| 106 |
--echo # Dropping the created tables |
| 107 |
DROP TABLE t1; |
| 108 |
DROP TABLE t_int; |
| 109 |
DROP TABLE t_bigint; |
| 110 |
DROP TABLE t_real; |
| 111 |
DROP TABLE t_date; |
| 112 |
|
| 113 |
--echo # Removing general_log content |
| 114 |
TRUNCATE TABLE mysql.general_log; |
| 115 |
|
| 116 |
--echo # Deleting log file created |
| 117 |
--remove_file $MYSQLTEST_VARDIR/log/test_sql_general.log |
| 118 |
|
| 119 |
SET GLOBAL log_output = @old_log_output; |
| 120 |
SET GLOBAL general_log = @old_general_log; |
| 121 |
SET GLOBAL general_log_file = @old_general_log_file; |
| 122 |
TRUNCATE TABLE mysql.general_log; |
| 123 |
|
| 124 |
--enable_ps_protocol |