5.6 slow query log Thead_id becomes Id - 1299387

This commit is contained in:
Frank Cizmich
2014-07-15 15:12:45 -03:00
parent ce0a9b0422
commit af185fbc28
8 changed files with 220 additions and 51 deletions

View File

@@ -42,7 +42,7 @@ sub new {
}
my $slow_log_ts_line = qr/^# Time: ([0-9: ]{15})/;
my $slow_log_uh_line = qr/# User\@Host: ([^\[]+|\[[^[]+\]).*?@ (\S*) \[(.*)\]/;
my $slow_log_uh_line = qr/# User\@Host: ([^\[]+|\[[^[]+\]).*?@ (\S*) \[(.*)\]\s*(?:Id:\s*(\d+))?/;
# These can appear in the log file when it's opened -- for example, when someone
# runs FLUSH LOGS or the server starts.
# /usr/sbin/mysqld, Version: 5.0.67-0ubuntu6-log ((Ubuntu)). started with:
@@ -159,10 +159,15 @@ sub parse_event {
++$got_ts;
# The User@Host might be concatenated onto the end of the Time.
if ( !$got_uh
&& ( my ( $user, $host, $ip ) = $line =~ m/$slow_log_uh_line/o )
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
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;
}
}
@@ -170,10 +175,15 @@ sub parse_event {
# Maybe it's the user/host line of a slow query log
# # User@Host: root[root] @ localhost []
elsif ( !$got_uh
&& ( my ( $user, $host, $ip ) = $line =~ m/$slow_log_uh_line/o )
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
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;
}