| 1 |
# Setting general_log content empty. |
| 2 |
TRUNCATE TABLE mysql.general_log; |
| 3 |
# Creating tables |
| 4 |
CREATE TABLE t_int (c1 TINYINT, |
| 5 |
c2 SMALLINT, |
| 6 |
c3 MEDIUMINT, |
| 7 |
c4 INT, |
| 8 |
c5 INTEGER, |
| 9 |
c6 SMALLINT UNSIGNED, |
| 10 |
c7 MEDIUMINT UNSIGNED, |
| 11 |
c8 INT UNSIGNED, |
| 12 |
c9 INTEGER); |
| 13 |
CREATE TABLE t_bigint (c1 BIGINT, |
| 14 |
c2 BIGINT UNSIGNED); |
| 15 |
CREATE TABLE t_real (c1 REAL UNSIGNED, |
| 16 |
c2 DOUBLE UNSIGNED, |
| 17 |
c3 FLOAT UNSIGNED, |
| 18 |
c4 DECIMAL UNSIGNED, |
| 19 |
c5 NUMERIC UNSIGNED, |
| 20 |
c6 DOUBLE, |
| 21 |
c7 FLOAT, |
| 22 |
c8 DECIMAL, |
| 23 |
c9 NUMERIC); |
| 24 |
Warnings: |
| 25 |
Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. |
| 26 |
Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. |
| 27 |
Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. |
| 28 |
Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. |
| 29 |
Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. |
| 30 |
CREATE TABLE t_date (c1 DATE, |
| 31 |
c2 TIME, |
| 32 |
c3 TIMESTAMP, |
| 33 |
c4 DATETIME, |
| 34 |
c5 YEAR); |
| 35 |
# Inserting values into the tables |
| 36 |
INSERT INTO t_int VALUES (91,92,93,94,95,96,97,98,99),(81,82,83,84,85,86,87,88,89); |
| 37 |
INSERT INTO t_bigint VALUES (91,92),(81,82); |
| 38 |
INSERT INTO t_real VALUES (8.51,8.52,8.53,8.54,8.55,8.56,8.57,8.58,8.59); |
| 39 |
Warnings: |
| 40 |
Note 1265 Data truncated for column 'c4' at row 1 |
| 41 |
Note 1265 Data truncated for column 'c5' at row 1 |
| 42 |
Note 1265 Data truncated for column 'c8' at row 1 |
| 43 |
Note 1265 Data truncated for column 'c9' at row 1 |
| 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 |
Warnings: |
| 46 |
Note 1265 Data truncated for column 'c4' at row 1 |
| 47 |
Note 1265 Data truncated for column 'c5' at row 1 |
| 48 |
Note 1265 Data truncated for column 'c8' at row 1 |
| 49 |
Note 1265 Data truncated for column 'c9' at row 1 |
| 50 |
INSERT INTO t_date VALUES ('2015-07-06','20:15','2015-12-31 14:59:48','2014-11-30 13:58:47','2015'); |
| 51 |
INSERT INTO t_date VALUES ('2015-07-07','20:17','2013-12-31 17:59:47','2012-10-31 15:57:47','2010'); |
| 52 |
SET @old_log_output = @@global.log_output; |
| 53 |
SET @old_general_log = @@global.general_log; |
| 54 |
SET @old_general_log_file = @@global.general_log_file; |
| 55 |
########################################## |
| 56 |
# Start plugin with general log |
| 57 |
########################################## |
| 58 |
SET GLOBAL general_log_file = '.../log/test_sql_general.log'; |
| 59 |
SET GLOBAL log_output = 'FILE,TABLE'; |
| 60 |
SET GLOBAL general_log = 'ON'; |
| 61 |
########################################## |
| 62 |
# Run plugin |
| 63 |
########################################## |
| 64 |
INSTALL PLUGIN test_sql_2_sessions SONAME 'TEST_SQL_2_SESSIONS'; |
| 65 |
########################################## |
| 66 |
# Stop plugin |
| 67 |
########################################## |
| 68 |
UNINSTALL PLUGIN test_sql_2_sessions; |
| 69 |
########################################## |
| 70 |
# Plugin log |
| 71 |
########################################## |
| 72 |
======================================================================== |
| 73 |
Test in a server thread |
| 74 |
Opening Session 1 |
| 75 |
======================================================================== |
| 76 |
Session 1 : |
| 77 |
======================================================================== |
| 78 |
SELECT * FROM test.t_int |
| 79 |
num_cols: 9 |
| 80 |
nb rows: 2 |
| 81 |
c1 c2 c3 c4 c5 c6 c7 c8 c9 |
| 82 |
TINY(1) SHORT(2) INT24(9) LONG(3) LONG(3) SHORT(2) INT24(9) LONG(3) LONG(3) |
| 83 |
() () () () () (UNSIGNED ) (UNSIGNED ) (UNSIGNED ) () |
| 84 |
Write a string |
| 85 |
91 92 93 94 95 96 97 98 99 |
| 86 |
81 82 83 84 85 86 87 88 89 |
| 87 |
|
| 88 |
affected rows : 0 |
| 89 |
server status : 34 |
| 90 |
warn count : 0 |
| 91 |
|
| 92 |
Opening Session 2 |
| 93 |
======================================================================== |
| 94 |
Session 1 : |
| 95 |
======================================================================== |
| 96 |
SELECT * FROM test.t_bigint |
| 97 |
num_cols: 2 |
| 98 |
nb rows: 2 |
| 99 |
c1 c2 |
| 100 |
LONGLONG(8) LONGLONG(8) |
| 101 |
() (UNSIGNED ) |
| 102 |
Write a string |
| 103 |
91 92 |
| 104 |
81 82 |
| 105 |
|
| 106 |
affected rows : 0 |
| 107 |
server status : 34 |
| 108 |
warn count : 0 |
| 109 |
======================================================================== |
| 110 |
Session 2 : |
| 111 |
======================================================================== |
| 112 |
SELECT * FROM test.t_real |
| 113 |
num_cols: 9 |
| 114 |
nb rows: 2 |
| 115 |
c1 c2 c3 c4 c5 c6 c7 c8 c9 |
| 116 |
DOUBLE(5) DOUBLE(5) FLOAT(4) NEWDECIMAL(246) NEWDECIMAL(246) DOUBLE(5) FLOAT(4) NEWDECIMAL(246) NEWDECIMAL(246) |
| 117 |
(UNSIGNED ) (UNSIGNED ) (UNSIGNED ) (UNSIGNED ) (UNSIGNED ) () () () () |
| 118 |
Write a string |
| 119 |
8.51 8.52 8.53 9 9 8.56 8.57 9 9 |
| 120 |
9.51 9.52 9.53 10 10 9.56 9.57 10 10 |
| 121 |
|
| 122 |
affected rows : 0 |
| 123 |
server status : 34 |
| 124 |
warn count : 0 |
| 125 |
|
| 126 |
Close Session 1 |
| 127 |
======================================================================== |
| 128 |
Session 2 : |
| 129 |
======================================================================== |
| 130 |
SELECT * FROM test.t_date |
| 131 |
num_cols: 5 |
| 132 |
nb rows: 2 |
| 133 |
c1 c2 c3 c4 c5 |
| 134 |
DATE(10) TIME(11) TIMESTAMP(7) DATETIME(12) YEAR(13) |
| 135 |
(BINARY ) (BINARY ) (BINARY ) (BINARY ) (UNSIGNED ZEROFILL ) |
| 136 |
Write a string |
| 137 |
2015-07-06 20:15:00 2015-12-31 14:59:48 2014-11-30 13:58:47 2015 |
| 138 |
2015-07-07 20:17:00 2013-12-31 17:59:47 2012-10-31 15:57:47 2010 |
| 139 |
|
| 140 |
affected rows : 0 |
| 141 |
server status : 34 |
| 142 |
warn count : 0 |
| 143 |
======================================================================== |
| 144 |
Session 1 : |
| 145 |
======================================================================== |
| 146 |
SELECT * FROM test.t_date |
| 147 |
|
| 148 |
Close Session 2 |
| 149 |
Follows threaded run |
| 150 |
======================================================================== |
| 151 |
init thread |
| 152 |
Opening Session 1 |
| 153 |
======================================================================== |
| 154 |
Session 1 : |
| 155 |
======================================================================== |
| 156 |
SELECT * FROM test.t_int |
| 157 |
num_cols: 9 |
| 158 |
nb rows: 2 |
| 159 |
c1 c2 c3 c4 c5 c6 c7 c8 c9 |
| 160 |
TINY(1) SHORT(2) INT24(9) LONG(3) LONG(3) SHORT(2) INT24(9) LONG(3) LONG(3) |
| 161 |
() () () () () (UNSIGNED ) (UNSIGNED ) (UNSIGNED ) () |
| 162 |
Write a string |
| 163 |
91 92 93 94 95 96 97 98 99 |
| 164 |
81 82 83 84 85 86 87 88 89 |
| 165 |
|
| 166 |
affected rows : 0 |
| 167 |
server status : 34 |
| 168 |
warn count : 0 |
| 169 |
|
| 170 |
Opening Session 2 |
| 171 |
======================================================================== |
| 172 |
Session 1 : |
| 173 |
======================================================================== |
| 174 |
SELECT * FROM test.t_bigint |
| 175 |
num_cols: 2 |
| 176 |
nb rows: 2 |
| 177 |
c1 c2 |
| 178 |
LONGLONG(8) LONGLONG(8) |
| 179 |
() (UNSIGNED ) |
| 180 |
Write a string |
| 181 |
91 92 |
| 182 |
81 82 |
| 183 |
|
| 184 |
affected rows : 0 |
| 185 |
server status : 34 |
| 186 |
warn count : 0 |
| 187 |
======================================================================== |
| 188 |
Session 2 : |
| 189 |
======================================================================== |
| 190 |
SELECT * FROM test.t_real |
| 191 |
num_cols: 9 |
| 192 |
nb rows: 2 |
| 193 |
c1 c2 c3 c4 c5 c6 c7 c8 c9 |
| 194 |
DOUBLE(5) DOUBLE(5) FLOAT(4) NEWDECIMAL(246) NEWDECIMAL(246) DOUBLE(5) FLOAT(4) NEWDECIMAL(246) NEWDECIMAL(246) |
| 195 |
(UNSIGNED ) (UNSIGNED ) (UNSIGNED ) (UNSIGNED ) (UNSIGNED ) () () () () |
| 196 |
Write a string |
| 197 |
8.51 8.52 8.53 9 9 8.56 8.57 9 9 |
| 198 |
9.51 9.52 9.53 10 10 9.56 9.57 10 10 |
| 199 |
|
| 200 |
affected rows : 0 |
| 201 |
server status : 34 |
| 202 |
warn count : 0 |
| 203 |
|
| 204 |
Close Session 1 |
| 205 |
======================================================================== |
| 206 |
Session 2 : |
| 207 |
======================================================================== |
| 208 |
SELECT * FROM test.t_date |
| 209 |
num_cols: 5 |
| 210 |
nb rows: 2 |
| 211 |
c1 c2 c3 c4 c5 |
| 212 |
DATE(10) TIME(11) TIMESTAMP(7) DATETIME(12) YEAR(13) |
| 213 |
(BINARY ) (BINARY ) (BINARY ) (BINARY ) (UNSIGNED ZEROFILL ) |
| 214 |
Write a string |
| 215 |
2015-07-06 20:15:00 2015-12-31 14:59:48 2014-11-30 13:58:47 2015 |
| 216 |
2015-07-07 20:17:00 2013-12-31 17:59:47 2012-10-31 15:57:47 2010 |
| 217 |
|
| 218 |
affected rows : 0 |
| 219 |
server status : 34 |
| 220 |
warn count : 0 |
| 221 |
======================================================================== |
| 222 |
Session 1 : |
| 223 |
======================================================================== |
| 224 |
SELECT * FROM test.t_date |
| 225 |
|
| 226 |
Close Session 2 |
| 227 |
deinit thread |
| 228 |
########################################## |
| 229 |
# Check general log file |
| 230 |
########################################## |
| 231 |
CREATE TABLE t1 (c1 TEXT, c2 TEXT, c3 TEXT); |
| 232 |
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/log/test_sql_general.log' INTO TABLE t1; |
| 233 |
SELECT c3 FROM t1 WHERE c3 LIKE '%FROM test.t_int%'; |
| 234 |
c3 |
| 235 |
SELECT * FROM test.t_int |
| 236 |
SELECT * FROM test.t_int |
| 237 |
SELECT c3 FROM t1 WHERE c3 LIKE '%FROM test.t_bigint%'; |
| 238 |
c3 |
| 239 |
SELECT * FROM test.t_bigint |
| 240 |
SELECT * FROM test.t_bigint |
| 241 |
SELECT count(*) FROM t1 WHERE c2 LIKE '%Connect%'; |
| 242 |
count(*) |
| 243 |
4 |
| 244 |
SELECT count(*) FROM t1 WHERE c2 LIKE '%Quit%'; |
| 245 |
count(*) |
| 246 |
4 |
| 247 |
SELECT argument FROM mysql.general_log WHERE command_type = 'Query' AND |
| 248 |
(argument LIKE '%FROM test.t_int%' OR |
| 249 |
argument LIKE '%FROM test.t_bigint%'); |
| 250 |
argument |
| 251 |
SELECT * FROM test.t_int |
| 252 |
SELECT * FROM test.t_bigint |
| 253 |
SELECT * FROM test.t_int |
| 254 |
SELECT * FROM test.t_bigint |
| 255 |
SELECT c3 FROM t1 WHERE c3 LIKE '%FROM test.t_int%' |
| 256 |
SELECT c3 FROM t1 WHERE c3 LIKE '%FROM test.t_bigint%' |
| 257 |
SELECT argument FROM mysql.general_log WHERE command_type = 'Query' AND |
| 258 |
(argument LIKE '%FROM test.t_int%' OR |
| 259 |
argument LIKE '%FROM test.t_bigint%') |
| 260 |
SELECT count(*) FROM mysql.general_log WHERE command_type = 'Connect'; |
| 261 |
count(*) |
| 262 |
4 |
| 263 |
SELECT count(*) FROM mysql.general_log WHERE command_type = 'Quit'; |
| 264 |
count(*) |
| 265 |
4 |
| 266 |
########################################## |
| 267 |
# Cleanup |
| 268 |
########################################## |
| 269 |
# Dropping the created tables |
| 270 |
DROP TABLE t1; |
| 271 |
DROP TABLE t_int; |
| 272 |
DROP TABLE t_bigint; |
| 273 |
DROP TABLE t_real; |
| 274 |
DROP TABLE t_date; |
| 275 |
# Removing general_log content |
| 276 |
TRUNCATE TABLE mysql.general_log; |
| 277 |
# Deleting log file created |
| 278 |
SET GLOBAL log_output = @old_log_output; |
| 279 |
SET GLOBAL general_log = @old_general_log; |
| 280 |
SET GLOBAL general_log_file = @old_general_log_file; |
| 281 |
TRUNCATE TABLE mysql.general_log; |