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,12 +2844,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }
@@ -2858,12 +2856,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }

View File

@@ -5038,12 +5038,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }
@@ -5052,12 +5050,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }

View File

@@ -1628,12 +1628,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }
@@ -1642,12 +1640,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }

View File

@@ -6609,12 +6609,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }
@@ -6623,12 +6621,10 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }

View File

@@ -161,12 +161,11 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
# 5.6 has the thread id on the User@Host line
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$got_uh; ++$got_uh;
} }
@@ -177,12 +176,11 @@ 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, Thread_id", $user, $host, $thread_id);
push @properties, 'user', $user, 'host', $host, 'ip', $ip, 'Thread_id', $thread_id;
}else{
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip); PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip; push @properties, 'user', $user, 'host', $host, 'ip', $ip;
# 5.6 has the thread id on the User@Host line
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
} }
++$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