Don't crash if group by attrib is empty string.

This commit is contained in:
Daniel Nichter
2012-07-11 15:46:58 -06:00
parent 6269b196a3
commit d8b0192495
7 changed files with 84 additions and 12 deletions

View File

@@ -5453,7 +5453,7 @@ sub _calc_metrics {
sub metrics {
my ( $self, %args ) = @_;
foreach my $arg ( qw(attrib where) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $attrib = $args{attrib};
my $where = $args{where};
@@ -6365,7 +6365,7 @@ sub files {
sub header {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea orderby) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $orderby = $args{orderby};
@@ -6594,7 +6594,7 @@ sub query_report {
sub event_report {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea item orderby) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $item = $args{item};
@@ -6765,7 +6765,7 @@ sub event_report {
sub chart_distro {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea item attrib) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $item = $args{item};
@@ -6814,7 +6814,7 @@ sub chart_distro {
sub distro_sparkline {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea item attrib) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $item = $args{item};

View File

@@ -764,7 +764,7 @@ sub _calc_metrics {
sub metrics {
my ( $self, %args ) = @_;
foreach my $arg ( qw(attrib where) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $attrib = $args{attrib};
my $where = $args{where};

View File

@@ -209,7 +209,7 @@ sub files {
sub header {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea orderby) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $orderby = $args{orderby};
@@ -489,7 +489,7 @@ sub query_report {
sub event_report {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea item orderby) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $item = $args{item};
@@ -686,7 +686,7 @@ sub event_report {
sub chart_distro {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea item attrib) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $item = $args{item};
@@ -765,7 +765,7 @@ sub chart_distro {
sub distro_sparkline {
my ( $self, %args ) = @_;
foreach my $arg ( qw(ea item attrib) ) {
die "I need a $arg argument" unless $args{$arg};
die "I need a $arg argument" unless defined $args{$arg};
}
my $ea = $args{ea};
my $item = $args{item};

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 81;
use Test::More tests => 82;
use QueryRewriter;
use EventAggregator;
@@ -1924,6 +1924,21 @@ is(
"Parse InnoDB_trx_id as string"
);
# #############################################################################
# Bug 924950: pt-query-digest --group-by db may crash profile report
# #############################################################################
$ea = new EventAggregator(
groupby => 'Schema',
worst => 'Query_time',
);
parse_file('t/lib/samples/slowlogs/slow055.txt', $p, $ea);
my $m = $ea->metrics(where => '', attrib => 'Query_time');
is(
$m->{cnt},
3,
"Metrics for '' attrib (bug 924950)"
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -0,0 +1,15 @@
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 5 Schema:
# Query_time: 0.000002 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
# No InnoDB statistics available for this query
# administrator command: Quit;
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 6 Schema:
# Query_time: 0.000899 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
# No InnoDB statistics available for this query
SET NAMES utf8;
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 6 Schema:
# Query_time: 0.018799 Lock_time: 0.009453 Rows_sent: 0 Rows_examined: 0
# No InnoDB statistics available for this query
SELECT MIN(id),MAX(id) FROM tbl;

View File

@@ -0,0 +1,30 @@
# ########################################################################
# Report grouped by db
# ########################################################################
# Item 1: 0 QPS, 0x concurrency, ID 0xE9800998ECF8427E at byte 420 _______
# This item is included in the report because it matches --limit.
# Scores: Apdex = 1.00 [1.0]*, V/M = 0.01
# Query_time sparkline: |^ ^ ^ |
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 100 3
# Exec time 100 20ms 2us 19ms 7ms 18ms 8ms 881us
# Lock time 100 9ms 0 9ms 3ms 9ms 4ms 0
# Rows sent 0 0 0 0 0 0 0 0
# Rows examine 0 0 0 0 0 0 0 0
# Query size 100 72 14 31 24 30.19 6.95 26.08
# String:
# Hosts
# Users meow
# Query_time distribution
# 1us ################################################################
# 10us
# 100us ################################################################
# 1ms
# 10ms ################################################################
# 100ms
# 1s
# 10s+

View File

@@ -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 PerconaTest;
@@ -433,6 +433,18 @@ ok(
'Analysis for slow054 (InnoDB_trx_id bug 821694)'
);
# #############################################################################
# Bug 924950: pt-query-digest --group-by db may crash profile report
# #############################################################################
ok(
no_diff(
sub { pt_query_digest::main(@args, $sample.'slow055.txt',
qw(--group-by db)) },
"t/pt-query-digest/samples/slow055.txt",
),
'Analysis for slow055 (group by blank db bug 924950)'
);
# #############################################################################
# Done.
# #############################################################################