Simplified code. Verified SlowLogParser module is correctly in sync with tools. Renamed test slow log files.

This commit is contained in:
Frank Cizmich
2014-07-30 17:25:29 -03:00
parent af185fbc28
commit abe635b6b0
9 changed files with 62 additions and 80 deletions

View File

@@ -2844,27 +2844,23 @@ sub parse_event {
if ( !$got_uh if ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip; ++$got_uh;
}
++$got_uh;
} }
} }
elsif ( !$got_uh elsif ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh; ++$got_uh;
} }

View File

@@ -5038,27 +5038,23 @@ sub parse_event {
if ( !$got_uh if ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip; ++$got_uh;
}
++$got_uh;
} }
} }
elsif ( !$got_uh elsif ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh; ++$got_uh;
} }

View File

@@ -1628,27 +1628,23 @@ sub parse_event {
if ( !$got_uh if ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip; ++$got_uh;
}
++$got_uh;
} }
} }
elsif ( !$got_uh elsif ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh; ++$got_uh;
} }

View File

@@ -6609,27 +6609,23 @@ sub parse_event {
if ( !$got_uh if ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip; ++$got_uh;
}
++$got_uh;
} }
} }
elsif ( !$got_uh elsif ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; if ( $thread_id ) {
}else{ push @properties, 'Thread_id', $thread_id;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); }
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh; ++$got_uh;
} }

View File

@@ -161,14 +161,13 @@ sub parse_event {
if ( !$got_uh if ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; # 5.6 has the thread id on the User@Host line
}else{ if ( $thread_id ) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); push @properties, 'Thread_id', $thread_id;
push @properties, 'user', $user, 'host', $host, 'ip', $ip; }
} ++$got_uh;
++$got_uh;
} }
} }
@@ -177,13 +176,12 @@ sub parse_event {
elsif ( !$got_uh elsif ( !$got_uh
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o ) && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) { ) {
if ($thread_id) { # 5.6 has the thread id on the User@Host line PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
PTDEBUG && _d("Got user, host, ip, Thread_id", $user, $host, $thread_id); push @properties, 'user', $user, 'host', $host, 'ip', $ip;
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id; # 5.6 has the thread id on the User@Host line
}else{ if ( $thread_id ) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); push @properties, 'Thread_id', $thread_id;
push @properties, 'user', $user, 'host', $host, 'ip', $ip; }
}
++$got_uh; ++$got_uh;
} }

View File

@@ -1359,7 +1359,7 @@ test_log_parser(
# (MySQL 5.5 doesn't include thread id) # (MySQL 5.5 doesn't include thread id)
test_log_parser( test_log_parser(
parser => $p, parser => $p,
file => "$sample/p55-slow.log", file => "$sample/slow060.txt",
result => [ result => [
{ {
Thread_id => '1', # here's our item Thread_id => '1', # here's our item
@@ -1389,7 +1389,7 @@ test_log_parser(
# (this is in line with MySQL 5.6) # (this is in line with MySQL 5.6)
test_log_parser( test_log_parser(
parser => $p, parser => $p,
file => "$sample/p56-slow.log", file => "$sample/slow061.txt",
result => [ result => [
{ {
Thread_id => 1, # here's our item Thread_id => 1, # here's our item

View File

@@ -52,16 +52,16 @@ ok(
'--since 090727' '--since 090727'
); );
# This test will fail come July 2014. # This test will fail come July 2015.
ok( ok(
no_diff( no_diff(
sub { pt_query_digest::main(@args, sub { pt_query_digest::main(@args,
"$sample_in/slow033.txt", qw(--since 1825d), "$sample_in/slow033.txt", qw(--since 2190d),
)}, )},
"t/pt-query-digest/samples/slow033-since-Nd.txt", "t/pt-query-digest/samples/slow033-since-Nd.txt",
stderr => 1, stderr => 1,
), ),
'--since 1825d (5 years ago)' '--since 2190d (6 years ago)'
); );
# --until # --until