mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 23:45:44 +00:00
Fix prepared report for statements without corresponding prep or exec.
This commit is contained in:
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 43;
|
||||
use Test::More tests => 44;
|
||||
|
||||
use Data::Dumper;
|
||||
$Data::Dumper::Indent = 1;
|
||||
@@ -1010,8 +1010,11 @@ $events = [
|
||||
},
|
||||
];
|
||||
$ea = new EventAggregator(
|
||||
groupby => 'fingerprint',
|
||||
worst => 'Query_time',
|
||||
groupby => 'fingerprint',
|
||||
worst => 'Query_time',
|
||||
type_for => {
|
||||
Statement_id => 'string',
|
||||
},
|
||||
);
|
||||
foreach my $event ( @$events ) {
|
||||
$ea->aggregate($event);
|
||||
@@ -1499,6 +1502,60 @@ ok(
|
||||
'Sparkchart in event header'
|
||||
);
|
||||
|
||||
# ############################################################################
|
||||
# Bug 887688: Prepared statements crash pt-query-digest
|
||||
# ############################################################################
|
||||
|
||||
# PREP without EXEC
|
||||
$events = [
|
||||
{
|
||||
Query_time => '0.000286',
|
||||
Warning_count => 0,
|
||||
arg => 'PREPARE SELECT i FROM d.t WHERE i=?',
|
||||
fingerprint => 'prepare select i from d.t where i=?',
|
||||
bytes => 35,
|
||||
cmd => 'Query',
|
||||
db => undef,
|
||||
pos_in_log => 0,
|
||||
ts => '091208 09:23:49.637394',
|
||||
Statement_id => 1,
|
||||
},
|
||||
];
|
||||
$ea = new EventAggregator(
|
||||
groupby => 'fingerprint',
|
||||
worst => 'Query_time',
|
||||
type_for => {
|
||||
Statement_id => 'string',
|
||||
},
|
||||
);
|
||||
foreach my $event ( @$events ) {
|
||||
$ea->aggregate($event);
|
||||
}
|
||||
$ea->calculate_statistical_metrics();
|
||||
$report = new ReportFormatter(
|
||||
line_width => 82,
|
||||
extend_right => 1,
|
||||
);
|
||||
$qrf->set_report_formatter(report=>'prepared', formatter=>$report);
|
||||
ok(
|
||||
no_diff(
|
||||
sub {
|
||||
$qrf->print_reports(
|
||||
reports => ['prepared'],
|
||||
ea => $ea,
|
||||
worst => [
|
||||
['prepare select i from d.t where i=?', 'top', 1],
|
||||
],
|
||||
orderby => 'Query_time',
|
||||
groupby => 'fingerprint',
|
||||
variations => [qw(arg)],
|
||||
);
|
||||
},
|
||||
"t/lib/samples/QueryReportFormatter/report030.txt",
|
||||
),
|
||||
"PREP without EXEC (bug 887688)"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
@@ -8,10 +8,10 @@
|
||||
# Count 50 1
|
||||
# Exec time 99 30ms 30ms 30ms 30ms 30ms 0 30ms
|
||||
# Query size 51 37 37 37 37 37 0 37
|
||||
# Statement id 50 2 2 2 2 2 0 2
|
||||
# Warning coun 0 0 0 0 0 0 0 0
|
||||
# String:
|
||||
# cmd Query
|
||||
# Statement id 2
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
@@ -39,10 +39,10 @@ SELECT i FROM d.t WHERE i="3"\G
|
||||
# Count 50 1
|
||||
# Exec time 0 286us 286us 286us 286us 286us 0 286us
|
||||
# Query size 48 35 35 35 35 35 0 35
|
||||
# Statement id 50 2 2 2 2 2 0 2
|
||||
# Warning coun 0 0 0 0 0 0 0 0
|
||||
# String:
|
||||
# cmd Query
|
||||
# Statement id 2
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
@@ -64,4 +64,4 @@ SELECT i FROM d.t WHERE i=?\G
|
||||
# Prepared statements
|
||||
# Rank Query ID PREP PREP Response EXEC EXEC Response Item
|
||||
# ==== ================== ==== ============= ==== ============= ==========
|
||||
# 1 0x3F79759E7FA2F117 0 0.0003 0.9% 1 0.0303 99.1% SELECT d.t
|
||||
# 1 0x3F79759E7FA2F117 1 0.0003 0.9% 1 0.0303 99.1% SELECT d.t
|
||||
|
5
t/lib/samples/QueryReportFormatter/report030.txt
Normal file
5
t/lib/samples/QueryReportFormatter/report030.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
# Prepared statements
|
||||
# Rank Query ID PREP PREP Response EXEC EXEC Response Item
|
||||
# ==== ================== ==== ============= ==== ============= ==========
|
||||
# 1 0xAA8E9FA785927259 1 0.0003 100.0% 0 0.0000 0.0% SELECT d.t
|
22
t/lib/samples/tcpdump/tcpdump041.txt
Normal file
22
t/lib/samples/tcpdump/tcpdump041.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
2009-12-08 09:23:49.637108 IP 127.0.0.1.58619 > 127.0.0.1.12345: tcp 32
|
||||
0x0000: 4508 0054 b468 4000 4006 8831 7f00 0001
|
||||
0x0010: 7f00 0001 e4fb 3039 47e2 1612 4850 bc0a
|
||||
0x0020: 8018 0101 fe48 0000 0101 080a 000f a420
|
||||
0x0030: 000f a13c 1c00 0000 1653 454c 4543 5420
|
||||
0x0040: 6920 4652 4f4d 2064 2e74 2057 4845 5245
|
||||
0x0050: 2069 3d3f
|
||||
2009-12-08 09:23:49.637194 IP 127.0.0.1.12345 > 127.0.0.1.58619: tcp 0
|
||||
0x0000: 4508 0034 1ab3 4000 4006 2207 7f00 0001
|
||||
0x0010: 7f00 0001 3039 e4fb 4850 bc0a 47e2 1632
|
||||
0x0020: 8010 0100 b7b7 0000 0101 080a 000f a420
|
||||
0x0030: 000f a420
|
||||
2009-12-08 09:23:49.637394 IP 127.0.0.1.12345 > 127.0.0.1.58619: tcp 92
|
||||
0x0000: 4508 0090 1ab4 4000 4006 21aa 7f00 0001
|
||||
0x0010: 7f00 0001 3039 e4fb 4850 bc0a 47e2 1632
|
||||
0x0020: 8018 0100 fe84 0000 0101 080a 000f a420
|
||||
0x0030: 000f a420 0c00 0001 0002 0000 0001 0001
|
||||
0x0040: 0000 0000 1700 0002 0364 6566 0000 0001
|
||||
0x0050: 3f00 0c3f 0000 0000 00fd 8000 0000 0005
|
||||
0x0060: 0000 03fe 0000 0200 1b00 0004 0364 6566
|
||||
0x0070: 0164 0174 0174 0169 0169 0c3f 000b 0000
|
||||
0x0080: 0003 0000 0000 0005 0000 05fe 0000 0200
|
Reference in New Issue
Block a user