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

View File

@@ -5038,27 +5038,23 @@ sub parse_event {
if ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
}
++$got_uh;
}
}
elsif ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
}
++$got_uh;
}

View File

@@ -1628,27 +1628,23 @@ sub parse_event {
if ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
}
++$got_uh;
}
}
elsif ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
}
++$got_uh;
}

View File

@@ -6609,27 +6609,23 @@ sub parse_event {
if ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh;
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
}
++$got_uh;
}
}
elsif ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
}
++$got_uh;
}

View File

@@ -161,14 +161,13 @@ sub parse_event {
if ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
++$got_uh;
PTDEBUG && _d("Got user, host, ip", $user, $host, $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;
}
}
@@ -177,13 +176,12 @@ sub parse_event {
elsif ( !$got_uh
&& ( 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);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
}
PTDEBUG && _d("Got user, host, ip", $user, $host, $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;
}

View File

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

View File

@@ -52,16 +52,16 @@ ok(
'--since 090727'
);
# This test will fail come July 2014.
# This test will fail come July 2015.
ok(
no_diff(
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",
stderr => 1,
),
'--since 1825d (5 years ago)'
'--since 2190d (6 years ago)'
);
# --until