4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
12
use Test::More tests => 72;
14
use MySQLProtocolParser;
18
my $sample = "t/lib/samples/tcpdump/";
19
my $tcpdump = new TcpdumpParser();
20
my $protocol; # Create a new MySQLProtocolParser for each test.
22
# Check that I can parse a really simple session.
23
$protocol = new MySQLProtocolParser();
26
protocol => $protocol,
27
file => "$sample/tcpdump001.txt",
29
{ ts => '090412 09:50:16.805123',
32
Thread_id => 4294967296,
36
arg => 'select "hello world" as greeting',
37
Query_time => sprintf('%.6f', .805123 - .804849),
39
bytes => length('select "hello world" as greeting'),
44
No_good_index_used => 'No',
45
No_index_used => 'No',
50
# A more complex session with a complete login/logout cycle.
51
$protocol = new MySQLProtocolParser();
54
protocol => $protocol,
55
file => "$sample/tcpdump002.txt",
57
{ ts => "090412 11:00:13.118191",
63
arg => 'administrator command: Connect',
64
Query_time => '0.011152',
67
bytes => length('administrator command: Connect'),
72
No_good_index_used => 'No',
73
No_index_used => 'No',
75
{ Query_time => '0.000265',
77
arg => 'select @@version_comment limit 1',
78
bytes => length('select @@version_comment limit 1'),
85
ts => '090412 11:00:13.118643',
90
No_good_index_used => 'No',
91
No_index_used => 'No',
93
{ Query_time => '0.000167',
95
arg => 'select "paris in the the spring" as trick',
96
bytes => length('select "paris in the the spring" as trick'),
103
ts => '090412 11:00:13.119079',
108
No_good_index_used => 'No',
109
No_index_used => 'No',
111
{ Query_time => '0.000000',
113
arg => 'administrator command: Quit',
120
pos_in_log => '4186',
121
ts => '090412 11:00:13.119487',
126
No_good_index_used => 'No',
127
No_index_used => 'No',
132
# A session that has an error during login.
133
$protocol = new MySQLProtocolParser();
134
test_protocol_parser(
136
protocol => $protocol,
137
file => "$sample/tcpdump003.txt",
139
{ ts => "090412 12:41:46.357853",
145
arg => 'administrator command: Connect',
146
Query_time => '0.010753',
149
bytes => length('administrator command: Connect'),
152
Error_msg => 'Access denied for user \'msandbox\'@\'localhost\' (using password: YES)',
155
No_good_index_used => 'No',
156
No_index_used => 'No',
161
# A session that has an error executing a query
162
$protocol = new MySQLProtocolParser();
163
test_protocol_parser(
165
protocol => $protocol,
166
file => "$sample/tcpdump004.txt",
168
{ ts => "090412 12:58:02.036002",
174
arg => 'select 5 from foo',
175
Query_time => '0.000251',
176
Thread_id => 4294967296,
178
bytes => length('select 5 from foo'),
181
Error_msg => 'No database selected',
184
No_good_index_used => 'No',
185
No_index_used => 'No',
190
# A session that has a single-row insert and a multi-row insert
191
$protocol = new MySQLProtocolParser();
192
test_protocol_parser(
194
protocol => $protocol,
195
file => "$sample/tcpdump005.txt",
197
{ Error_no => 'none',
199
Query_time => '0.000435',
200
Thread_id => 4294967296,
201
arg => 'insert into test.t values(1)',
209
ts => '090412 16:46:02.978340',
212
No_good_index_used => 'No',
213
No_index_used => 'No',
215
{ Error_no => 'none',
217
Query_time => '0.000565',
218
Thread_id => 4294967296,
219
arg => 'insert into test.t values(1),(2)',
226
pos_in_log => '1033',
227
ts => '090412 16:46:20.245088',
230
No_good_index_used => 'No',
231
No_index_used => 'No',
236
# A session that causes a slow query because it doesn't use an index.
237
$protocol = new MySQLProtocolParser();
238
test_protocol_parser(
240
protocol => $protocol,
241
file => "$sample/tcpdump006.txt",
243
{ ts => '100412 20:46:10.776899',
249
arg => 'select * from t',
250
Query_time => '0.000205',
251
Thread_id => 4294967296,
253
bytes => length('select * from t'),
258
No_good_index_used => 'No',
259
No_index_used => 'Yes',
264
# A session that truncates an insert.
265
$protocol = new MySQLProtocolParser();
266
test_protocol_parser(
268
protocol => $protocol,
269
file => "$sample/tcpdump007.txt",
271
{ ts => '090412 20:57:22.798296',
277
arg => 'insert into t values(current_date)',
278
Query_time => '0.000020',
279
Thread_id => 4294967296,
281
bytes => length('insert into t values(current_date)'),
286
No_good_index_used => 'No',
287
No_index_used => 'No',
292
# #############################################################################
293
# Check the individual packet parsing subs.
294
# #############################################################################
295
MySQLProtocolParser->import(qw(
298
parse_server_handshake_packet
299
parse_client_handshake_packet
304
parse_error_packet(load_data("t/lib/samples/mysql_proto_001.txt")),
307
sqlstate => '#3D000',
308
message => 'No database selected',
314
parse_ok_packet('010002000100'),
326
parse_server_handshake_packet(load_data("t/lib/samples/mysql_proto_002.txt")),
329
server_version => '5.0.67-0ubuntu6-log',
331
CLIENT_COMPRESS => 1,
332
CLIENT_CONNECT_WITH_DB => 1,
333
CLIENT_FOUND_ROWS => 0,
334
CLIENT_IGNORE_SIGPIPE => 0,
335
CLIENT_IGNORE_SPACE => 0,
336
CLIENT_INTERACTIVE => 0,
337
CLIENT_LOCAL_FILES => 0,
338
CLIENT_LONG_FLAG => 1,
339
CLIENT_LONG_PASSWORD => 0,
340
CLIENT_MULTI_RESULTS => 0,
341
CLIENT_MULTI_STATEMENTS => 0,
342
CLIENT_NO_SCHEMA => 0,
344
CLIENT_PROTOCOL_41 => 1,
345
CLIENT_RESERVED => 0,
346
CLIENT_SECURE_CONNECTION => 1,
348
CLIENT_TRANSACTIONS => 1,
351
'Parse server handshake packet'
355
parse_client_handshake_packet(load_data("t/lib/samples/mysql_proto_003.txt")),
360
CLIENT_COMPRESS => 0,
361
CLIENT_CONNECT_WITH_DB => 1,
362
CLIENT_FOUND_ROWS => 0,
363
CLIENT_IGNORE_SIGPIPE => 0,
364
CLIENT_IGNORE_SPACE => 0,
365
CLIENT_INTERACTIVE => 0,
366
CLIENT_LOCAL_FILES => 1,
367
CLIENT_LONG_FLAG => 1,
368
CLIENT_LONG_PASSWORD => 1,
369
CLIENT_MULTI_RESULTS => 1,
370
CLIENT_MULTI_STATEMENTS => 1,
371
CLIENT_NO_SCHEMA => 0,
373
CLIENT_PROTOCOL_41 => 1,
374
CLIENT_RESERVED => 0,
375
CLIENT_SECURE_CONNECTION => 1,
377
CLIENT_TRANSACTIONS => 1,
380
'Parse client handshake packet'
384
parse_com_packet('0373686f77207761726e696e67738d2dacbc', 14),
388
data => 'show warnings',
390
'Parse COM_QUERY packet'
393
# Test that we can parse with a non-standard port etc.
394
$protocol = new MySQLProtocolParser(
395
server => '192.168.1.1',
398
test_protocol_parser(
400
protocol => $protocol,
401
file => "$sample/tcpdump012.txt",
403
{ ts => '090412 09:50:16.805123',
406
Thread_id => 4294967296,
410
arg => 'select "hello world" as greeting',
411
Query_time => sprintf('%.6f', .805123 - .804849),
413
bytes => length('select "hello world" as greeting'),
418
No_good_index_used => 'No',
419
No_index_used => 'No',
424
# #############################################################################
425
# Issue 447: MySQLProtocolParser does not handle old password algo or
427
# #############################################################################
428
$protocol = new MySQLProtocolParser(
429
server => '10.55.200.15',
431
test_protocol_parser(
433
protocol => $protocol,
434
file => "$sample/tcpdump013.txt",
435
desc => 'old password and compression',
437
{ Error_no => 'none',
438
No_good_index_used => 'No',
439
No_index_used => 'No',
440
Query_time => '0.034355',
442
Thread_id => 36947020,
444
arg => 'administrator command: Connect',
448
host => '10.54.212.171',
449
ip => '10.54.212.171',
452
ts => '090603 10:52:24.578817',
458
# Check in-stream compression detection.
459
$protocol = new MySQLProtocolParser(
460
server => '10.55.200.15',
462
test_protocol_parser(
464
protocol => $protocol,
465
file => "$sample/tcpdump014.txt",
466
desc => 'in-stream compression detection',
470
No_good_index_used => 'No',
471
No_index_used => 'No',
472
Query_time => '0.001375',
474
Thread_id => 4294967296,
476
arg => 'show databases',
480
host => '10.54.212.171',
481
ip => '10.54.212.171',
484
ts => '090603 10:52:24.587685',
490
# Check data decompression.
491
$protocol = new MySQLProtocolParser(
492
server => '127.0.0.1',
495
test_protocol_parser(
497
protocol => $protocol,
498
file => "$sample/tcpdump015.txt",
499
desc => 'compressed data',
503
No_good_index_used => 'No',
504
No_index_used => 'No',
505
Query_time => '0.006415',
509
arg => 'administrator command: Connect',
517
ts => '090612 08:39:05.316805',
522
No_good_index_used => 'No',
523
No_index_used => 'Yes',
524
Query_time => '0.002884',
528
arg => 'select * from help_relation',
536
ts => '090612 08:39:08.428913',
541
No_good_index_used => 'No',
542
No_index_used => 'No',
543
Query_time => '0.000000',
547
arg => 'administrator command: Quit',
555
ts => '090612 08:39:09.145334',
561
# TCP retransmission.
562
# Check data decompression.
563
$protocol = new MySQLProtocolParser(
564
server => '10.55.200.15',
566
test_protocol_parser(
568
protocol => $protocol,
569
file => "$sample/tcpdump016.txt",
570
desc => 'TCP retransmission',
574
No_good_index_used => 'No',
575
No_index_used => 'No',
576
Query_time => '0.001000',
578
Thread_id => 38559282,
580
arg => 'administrator command: Connect',
584
host => '10.55.200.31',
585
ip => '10.55.200.31',
588
ts => '090609 16:53:17.112346',
594
# #############################################################################
595
# Issue 537: MySQLProtocolParser and MemcachedProtocolParser do not handle
597
# #############################################################################
598
$protocol = new MySQLProtocolParser();
599
test_protocol_parser(
601
protocol => $protocol,
602
file => "$sample/tcpdump018.txt",
603
desc => 'Multiple servers',
607
No_good_index_used => 'No',
608
No_index_used => 'No',
609
Query_time => '0.000206',
611
Thread_id => '4294967296',
613
arg => 'select * from foo',
621
ts => '090727 08:28:41.723651',
626
No_good_index_used => 'No',
627
No_index_used => 'No',
628
Query_time => '0.000203',
630
Thread_id => '4294967297',
632
arg => 'select * from bar',
640
ts => '090727 08:29:34.232748',
646
# Test that --watch-server causes just the given server to be watched.
647
$protocol = new MySQLProtocolParser(server=>'10.0.0.1',port=>'3306');
648
test_protocol_parser(
650
protocol => $protocol,
651
file => "$sample/tcpdump018.txt",
652
desc => 'Multiple servers but watch only one',
656
No_good_index_used => 'No',
657
No_index_used => 'No',
658
Query_time => '0.000206',
660
Thread_id => '4294967296',
662
arg => 'select * from foo',
670
ts => '090727 08:28:41.723651',
677
# #############################################################################
678
# Issue 558: Make mk-query-digest handle big/fragmented packets
679
# #############################################################################
680
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
681
my $e = test_protocol_parser(
683
protocol => $protocol,
684
file => "$sample/tcpdump019.txt",
690
'Handles big, fragmented MySQL packets (issue 558)'
693
my $arg = load_file("$sample/tcpdump019-arg.txt");
698
'Re-assembled data is correct (issue 558)'
701
# #############################################################################
702
# Issue 740: Handle prepared statements
703
# #############################################################################
704
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
705
test_protocol_parser(
707
protocol => $protocol,
708
file => "$sample/tcpdump021.txt",
709
desc => 'prepared statements, simple, no NULL',
713
No_good_index_used => 'No',
714
No_index_used => 'No',
715
Query_time => '0.000286',
717
Thread_id => '4294967296',
719
arg => 'PREPARE SELECT i FROM d.t WHERE i=?',
727
ts => '091208 09:23:49.637394',
733
No_good_index_used => 'No',
734
No_index_used => 'Yes',
735
Query_time => '0.000281',
737
Thread_id => '4294967296',
739
arg => 'EXECUTE SELECT i FROM d.t WHERE i="3"',
747
ts => '091208 09:23:49.637892',
753
No_good_index_used => 'No',
754
No_index_used => 'No',
755
Query_time => '0.000000',
757
Thread_id => '4294967296',
759
arg => 'administrator command: Quit',
767
ts => '091208 09:23:49.638381',
773
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
774
test_protocol_parser(
776
protocol => $protocol,
777
file => "$sample/tcpdump022.txt",
778
desc => 'prepared statements, NULL value',
782
No_good_index_used => 'No',
783
No_index_used => 'No',
784
Query_time => '0.000303',
786
Thread_id => '4294967296',
788
arg => 'PREPARE SELECT i,j FROM d.t2 WHERE i=? AND j=?',
796
ts => '091208 13:41:12.811188',
802
No_good_index_used => 'No',
803
No_index_used => 'No',
804
Query_time => '0.000186',
806
Thread_id => '4294967296',
808
arg => 'EXECUTE SELECT i,j FROM d.t2 WHERE i=NULL AND j="5"',
816
ts => '091208 13:41:12.811591',
823
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
824
test_protocol_parser(
826
protocol => $protocol,
827
file => "$sample/tcpdump023.txt",
828
desc => 'prepared statements, string, char and float',
832
No_good_index_used => 'No',
833
No_index_used => 'No',
834
Query_time => '0.000315',
836
Thread_id => '4294967296',
838
arg => 'PREPARE SELECT * FROM d.t3 WHERE v=? OR c=? OR f=?',
846
ts => '091208 14:14:55.951863',
852
No_good_index_used => 'No',
853
No_index_used => 'No',
854
Query_time => '0.000249',
856
Thread_id => '4294967296',
858
arg => 'EXECUTE SELECT * FROM d.t3 WHERE v="hello world" OR c="a" OR f="1.23"',
866
ts => '091208 14:14:55.952344',
873
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
874
test_protocol_parser(
876
protocol => $protocol,
877
file => "$sample/tcpdump024.txt",
878
desc => 'prepared statements, all NULL',
882
No_good_index_used => 'No',
883
No_index_used => 'No',
884
Query_time => '0.000278',
886
Thread_id => '4294967296',
888
arg => 'PREPARE SELECT * FROM d.t3 WHERE v=? OR c=? OR f=?',
896
ts => '091208 14:33:13.711351',
902
No_good_index_used => 'No',
903
No_index_used => 'No',
904
Query_time => '0.000159',
906
Thread_id => '4294967296',
908
arg => 'EXECUTE SELECT * FROM d.t3 WHERE v=NULL OR c=NULL OR f=NULL',
916
ts => '091208 14:33:13.711642',
923
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
924
test_protocol_parser(
926
protocol => $protocol,
927
file => "$sample/tcpdump025.txt",
928
desc => 'prepared statements, no params',
932
No_good_index_used => 'No',
933
No_index_used => 'No',
934
Query_time => '0.000268',
936
Thread_id => '4294967296',
938
arg => 'PREPARE SELECT * FROM d.t WHERE 1 LIMIT 1;',
946
ts => '091208 14:44:52.709181',
952
No_good_index_used => 'No',
953
No_index_used => 'Yes',
954
Query_time => '0.000234',
956
Thread_id => '4294967296',
958
arg => 'EXECUTE SELECT * FROM d.t WHERE 1 LIMIT 1;',
966
ts => '091208 14:44:52.709597',
973
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'3306');
974
test_protocol_parser(
976
protocol => $protocol,
977
file => "$sample/tcpdump026.txt",
978
desc => 'prepared statements, close statement',
982
No_good_index_used => 'No',
983
No_index_used => 'No',
984
Query_time => '0.000000',
986
Thread_id => '4294967296',
988
arg => 'DEALLOCATE PREPARE 50',
996
ts => '091208 17:42:12.696547',
1002
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'3306');
1003
test_protocol_parser(
1005
protocol => $protocol,
1006
file => "$sample/tcpdump027.txt",
1007
desc => 'prepared statements, reset statement',
1011
No_good_index_used => 'No',
1012
No_index_used => 'No',
1013
Query_time => '0.000023',
1016
Thread_id => '4294967296',
1026
ts => '091208 17:42:12.698093',
1032
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
1033
test_protocol_parser(
1035
protocol => $protocol,
1036
file => "$sample/tcpdump028.txt",
1037
desc => 'prepared statements, multiple exec, new param',
1041
No_good_index_used => 'No',
1042
No_index_used => 'No',
1043
Query_time => '0.000292',
1046
Thread_id => '4294967296',
1048
arg => 'PREPARE SELECT * FROM d.t WHERE i=?',
1052
host => '127.0.0.1',
1056
ts => '091208 17:35:37.433248',
1061
No_good_index_used => 'No',
1062
No_index_used => 'Yes',
1063
Query_time => '0.000254',
1066
Thread_id => '4294967296',
1068
arg => 'EXECUTE SELECT * FROM d.t WHERE i="1"',
1072
host => '127.0.0.1',
1076
ts => '091208 17:35:37.433700',
1081
No_good_index_used => 'No',
1082
No_index_used => 'Yes',
1083
Query_time => '0.000190',
1086
Thread_id => '4294967296',
1088
arg => 'EXECUTE SELECT * FROM d.t WHERE i="3"',
1092
host => '127.0.0.1',
1096
ts => '091208 17:35:37.434303',
1101
No_good_index_used => 'No',
1102
No_index_used => 'Yes',
1103
Query_time => '0.000166',
1106
Thread_id => '4294967296',
1108
arg => 'EXECUTE SELECT * FROM d.t WHERE i=NULL',
1112
host => '127.0.0.1',
1116
ts => '091208 17:35:37.434708',
1122
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'12345');
1123
test_protocol_parser(
1125
protocol => $protocol,
1126
file => "$sample/tcpdump029.txt",
1127
desc => 'prepared statements, real param types',
1131
No_good_index_used => 'No',
1132
No_index_used => 'No',
1133
Query_time => '0.000221',
1136
Thread_id => '4294967296',
1138
arg => 'PREPARE SELECT * FROM d.t WHERE i=? OR u=? OR v=? OR d=? OR f=? OR t > ? OR dt > ?',
1142
host => '127.0.0.1',
1146
ts => '091209 09:20:59.293775',
1151
No_good_index_used => 'No',
1152
No_index_used => 'No',
1153
Query_time => '0.000203',
1156
Thread_id => '4294967296',
1158
arg => 'EXECUTE SELECT * FROM d.t WHERE i=42 OR u=2009 OR v="hello world" OR d=1.23 OR f=4.56 OR t > "2009-12-01" OR dt > "2009-12-01"',
1162
host => '127.0.0.1',
1166
ts => '091209 09:20:59.294409',
1171
No_good_index_used => 'No',
1172
No_index_used => 'No',
1173
Query_time => '0.000000',
1175
Thread_id => '4294967296',
1177
arg => 'DEALLOCATE PREPARE 1',
1181
host => '127.0.0.1',
1185
ts => '091209 09:20:59.294926',
1190
No_good_index_used => 'No',
1191
No_index_used => 'No',
1192
Query_time => '0.000000',
1194
Thread_id => '4294967296',
1196
arg => 'administrator command: Quit',
1200
host => '127.0.0.1',
1204
ts => '091209 09:20:59.295064',
1210
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'3306');
1211
test_protocol_parser(
1213
protocol => $protocol,
1214
file => "$sample/tcpdump030.txt",
1215
desc => 'prepared statements, ok response to execute',
1219
No_good_index_used => 'No',
1220
No_index_used => 'No',
1221
Query_time => '0.000046',
1224
Thread_id => '4294967296',
1226
arg => 'PREPARE SET SESSION sql_mode="STRICT_ALL_TABLES"',
1234
ts => '091210 14:21:16.956302',
1239
No_good_index_used => 'No',
1240
No_index_used => 'No',
1241
Query_time => '0.000024',
1244
Thread_id => '4294967296',
1246
arg => 'EXECUTE SET SESSION sql_mode="STRICT_ALL_TABLES"',
1254
ts => '091210 14:21:16.956446',
1260
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'3306');
1261
test_protocol_parser(
1263
protocol => $protocol,
1264
file => "$sample/tcpdump034.txt",
1265
desc => 'prepared statements, NULL bitmap',
1269
No_good_index_used => 'No',
1270
No_index_used => 'No',
1271
Query_time => '0.000288',
1274
Thread_id => '4294967296',
1276
arg => 'PREPARE SELECT * FROM d.t WHERE i=? OR u=? OR v=? OR d=? OR f=? OR t > ? OR dt > ? OR i2=? OR i3=? OR i4=?',
1280
host => '127.0.0.1',
1284
ts => '091224 16:47:24.204501',
1289
No_good_index_used => 'No',
1290
No_index_used => 'No',
1291
Query_time => '0.000322',
1294
Thread_id => '4294967296',
1296
arg => 'EXECUTE SELECT * FROM d.t WHERE i=42 OR u=2009 OR v="hello world" OR d=1.23 OR f=4.56 OR t > "2009-12-01" OR dt > "2009-12-01" OR i2=NULL OR i3=NULL OR i4=NULL',
1300
host => '127.0.0.1',
1304
ts => '091224 16:47:24.204965',
1310
# #############################################################################
1311
# Issue 761: mk-query-digest --tcpdump does not handle incomplete packets
1312
# #############################################################################
1313
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'3306');
1314
test_protocol_parser(
1316
protocol => $protocol,
1317
file => "$sample/tcpdump032.txt",
1318
desc => 'issue 761',
1322
No_good_index_used => 'No',
1323
No_index_used => 'No',
1324
Query_time => '0.000431',
1326
Thread_id => '4294967296',
1327
Warning_count => 21032,
1328
arg => 'UPDATEDDDDNNNN',
1336
ts => '091208 20:54:54.795250',
1342
# #############################################################################
1343
# Issue 760: mk-query-digest --tcpdump might not get the whole query
1344
# #############################################################################
1345
$protocol = new MySQLProtocolParser(server=>'127.0.0.1',port=>'3306');
1346
test_protocol_parser(
1348
protocol => $protocol,
1349
file => "$sample/tcpdump031.txt",
1350
desc => 'issue 760',
1354
No_good_index_used => 'No',
1355
No_index_used => 'No',
1356
Query_time => '0.000430',
1358
Thread_id => '4294967296',
1359
Warning_count => 21032,
1360
arg => 'UPDATEDDDDNNNN',
1368
ts => '091207 20:54:54.795250',
1374
# #############################################################################
1375
# Issue 794: MySQLProtocolParser does not handle client port reuse
1376
# #############################################################################
1377
$protocol = new MySQLProtocolParser();
1378
test_protocol_parser(
1380
protocol => $protocol,
1381
file => "$sample/tcpdump035.txt",
1382
desc => 'client port reuse (issue 794)',
1384
{ ts => "090412 11:00:13.118191",
1387
host => '127.0.0.1',
1390
arg => 'administrator command: Connect',
1391
Query_time => '0.011152',
1394
bytes => length('administrator command: Connect'),
1399
No_good_index_used => 'No',
1400
No_index_used => 'No',
1402
{ Query_time => '0.000167',
1404
arg => 'select "paris in the the spring" as trick',
1405
bytes => length('select "paris in the the spring" as trick'),
1408
host => '127.0.0.1',
1412
ts => '090412 11:00:13.119079',
1417
No_good_index_used => 'No',
1418
No_index_used => 'No',
1420
{ Query_time => '0.000000',
1422
arg => 'administrator command: Quit',
1426
host => '127.0.0.1',
1430
ts => '090412 11:00:13.119487',
1435
No_good_index_used => 'No',
1436
No_index_used => 'No',
1439
{ ts => '090412 12:00:00.800000',
1441
No_good_index_used => 'No',
1442
No_index_used => 'No',
1443
Query_time => '0.700000',
1447
arg => 'administrator command: Connect',
1451
host => '127.0.0.1',
1457
{ ts => '090412 12:00:01.000000',
1459
No_good_index_used => 'No',
1460
No_index_used => 'No',
1461
Query_time => '0.100000',
1465
arg => 'select "paris in the the spring" as trick',
1469
host => '127.0.0.1',
1475
{ ts => '090412 12:00:01.100000',
1477
No_good_index_used => 'No',
1478
No_index_used => 'No',
1479
Query_time => '0.000000',
1483
arg => 'administrator command: Quit',
1487
host => '127.0.0.1',
1496
$protocol = new MySQLProtocolParser();
1497
test_protocol_parser(
1499
protocol => $protocol,
1500
file => "$sample/tcpdump036.txt",
1501
desc => 'Houdini data (issue 794)',
1503
{ ts => "090412 11:00:13.118191",
1506
host => '127.0.0.1',
1509
arg => 'administrator command: Connect',
1510
Query_time => '0.011152',
1513
bytes => length('administrator command: Connect'),
1518
No_good_index_used => 'No',
1519
No_index_used => 'No',
1522
{ ts => '090412 12:00:00.800000',
1524
No_good_index_used => 'No',
1525
No_index_used => 'No',
1526
Query_time => '0.700000',
1530
arg => 'administrator command: Connect',
1534
host => '127.0.0.1',
1540
{ ts => '090412 12:00:01.000000',
1542
No_good_index_used => 'No',
1543
No_index_used => 'No',
1544
Query_time => '0.100000',
1548
arg => 'select "paris in the the spring" as trick',
1552
host => '127.0.0.1',
1558
{ ts => '090412 12:00:01.100000',
1560
No_good_index_used => 'No',
1561
No_index_used => 'No',
1562
Query_time => '0.000000',
1566
arg => 'administrator command: Quit',
1570
host => '127.0.0.1',
1579
$protocol = new MySQLProtocolParser();
1580
test_protocol_parser(
1582
protocol => $protocol,
1583
file => "$sample/tcpdump037.txt",
1584
desc => 'no server ok (issue 794)',
1586
{ ts => '090412 12:00:01.000000',
1588
No_good_index_used => 'No',
1589
No_index_used => 'No',
1590
Query_time => '0.000000',
1592
Thread_id => '4294967296',
1594
arg => 'administrator command: Quit',
1598
host => '127.0.0.1',
1604
{ ts => '090412 12:00:03.000000',
1606
No_good_index_used => 'No',
1607
No_index_used => 'No',
1608
Query_time => '1.000000',
1610
Thread_id => 4294967297,
1612
arg => 'select "paris in the the spring" as trick',
1616
host => '127.0.0.1',
1625
# #############################################################################
1626
# Issue 832: mk-query-digest tcpdump crashes on successive, fragmented
1628
# #############################################################################
1629
$protocol = new MySQLProtocolParser(server => '127.0.0.1',port=>'12345');
1630
$e = test_protocol_parser(
1632
protocol => $protocol,
1633
file => "$sample/tcpdump038.txt",
1638
qr/--THE END--'\)$/,
1639
'2nd, fragmented client query (issue 832)',
1642
# #############################################################################
1643
# Issue 670: Make mk-query-digest capture the error message from tcpdump
1644
# #############################################################################
1645
$protocol = new MySQLProtocolParser(
1646
server => '127.0.0.1',
1649
test_protocol_parser(
1651
protocol => $protocol,
1652
file => "$sample/tcpdump040.txt",
1653
desc => 'Error (issue 670)',
1657
Error_msg => "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1",
1658
Error_no => '#1064',
1659
No_good_index_used => 'No',
1660
No_index_used => 'No',
1661
Query_time => '0.000316',
1663
Thread_id => '4294967296',
1669
host => '127.0.0.1',
1673
ts => '091101 14:54:44.293453',
1677
Error_msg => 'Unknown system variable \'nono\'',
1678
Error_no => '#1193',
1679
No_good_index_used => 'No',
1680
No_index_used => 'No',
1681
Query_time => '0.000329',
1683
Thread_id => '4294967296',
1685
arg => 'set global nono = 2',
1689
host => '127.0.0.1',
1693
ts => '091101 14:54:52.813941',
1699
# #############################################################################
1701
# #############################################################################