Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/pt-index-usage
Original file line number Diff line number Diff line change
Expand Up @@ -3029,6 +3029,10 @@ sub parse_event {
}

PTDEBUG && _d('Properties of event:', Dumper(\@properties));
if ( @properties % 2 ) {
PTDEBUG && _d('Skipping malformed event (odd properties):', Dumper(\@properties));
next EVENT;
}
my $event = { @properties };
if ( !$event->{arg} ) {
PTDEBUG && _d('Partial event, no arg');
Expand Down
10 changes: 9 additions & 1 deletion bin/pt-query-digest
Original file line number Diff line number Diff line change
Expand Up @@ -5234,6 +5234,10 @@ sub parse_event {
}

PTDEBUG && _d('Properties of event:', Dumper(\@properties));
if ( @properties % 2 ) {
PTDEBUG && _d('Skipping malformed event (odd properties):', Dumper(\@properties));
next EVENT;
}
my $event = { @properties };
if ( !$event->{arg} ) {
PTDEBUG && _d('Partial event, no arg');
Expand Down Expand Up @@ -5625,6 +5629,10 @@ sub make_handler {
);
}

if ( $type =~ m/^(?:num|bool)$/ ) {
push @lines, q{$val = 0 if defined $val && $val eq '';};
}

if ( $type eq 'num' && $self->{attrib_limit} ) {
push @lines, (
"if ( \$val > $self->{attrib_limit} ) {",
Expand Down Expand Up @@ -5654,7 +5662,7 @@ sub make_handler {
. $gt . ' PLACE->{max};',
);
if ( $track{sum} ) {
push @tmp, 'PLACE->{sum} += $val;';
push @tmp, 'PLACE->{sum} += (defined $val && $val ne q{} ? $val : 0);';
}

if ( $track{all} ) {
Expand Down
4 changes: 4 additions & 0 deletions bin/pt-table-usage
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,10 @@ sub parse_event {
}

PTDEBUG && _d('Properties of event:', Dumper(\@properties));
if ( @properties % 2 ) {
PTDEBUG && _d('Skipping malformed event (odd properties):', Dumper(\@properties));
next EVENT;
}
my $event = { @properties };
if ( !$event->{arg} ) {
PTDEBUG && _d('Partial event, no arg');
Expand Down
4 changes: 4 additions & 0 deletions bin/pt-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -6995,6 +6995,10 @@ sub parse_event {
}

PTDEBUG && _d('Properties of event:', Dumper(\@properties));
if ( @properties % 2 ) {
PTDEBUG && _d('Skipping malformed event (odd properties):', Dumper(\@properties));
next EVENT;
}
my $event = { @properties };
if ( !$event->{arg} ) {
PTDEBUG && _d('Partial event, no arg');
Expand Down
9 changes: 8 additions & 1 deletion lib/EventAggregator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ sub make_handler {
);
}

# Slow log and similar sources can leave numeric attributes as ''; treat as 0
# so type detection and later arithmetic stay consistent.
if ( $type =~ m/^(?:num|bool)$/ ) {
push @lines, q{$val = 0 if defined $val && $val eq '';};
}

# Make sure the value is constrained to legal limits. If it's out of
# bounds, just use the last-seen value for it.
if ( $type eq 'num' && $self->{attrib_limit} ) {
Expand Down Expand Up @@ -422,8 +428,9 @@ sub make_handler {
'PLACE->{max} = $val if !defined PLACE->{max} || $val '
. $gt . ' PLACE->{max};',
);
# Num/bool sums must not use += on undef or '' (would warn or incorrectly sum).
if ( $track{sum} ) {
push @tmp, 'PLACE->{sum} += $val;';
push @tmp, 'PLACE->{sum} += (defined $val && $val ne q{} ? $val : 0);';
}

# Save all values in a bucketed list. See bucket_idx() below.
Expand Down
6 changes: 6 additions & 0 deletions lib/SlowLogParser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ sub parse_event {
# Don't dump $event; want to see full dump of all properties, and after
# it's been cast into a hash, duplicated keys will be gone.
PTDEBUG && _d('Properties of event:', Dumper(\@properties));
# An odd-length @properties list would pair keys/values wrong in the
# hash below; skip the event rather than corrupt aggregation.
if ( @properties % 2 ) {
PTDEBUG && _d('Skipping malformed event (odd properties):', Dumper(\@properties));
next EVENT;
}
my $event = { @properties };
if ( !$event->{arg} ) {
PTDEBUG && _d('Partial event, no arg');
Expand Down
Loading