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