~percona-toolkit-dev/percona-toolkit/manual-for-pt-query-digest--type-binlog-is-ambiguous-1377888

« back to all changes in this revision

Viewing changes to lib/SlowLogParser.pm

merged pt-table-checksum-deadlock-1287253

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
}
43
43
 
44
44
my $slow_log_ts_line = qr/^# Time: ([0-9: ]{15})/;
45
 
my $slow_log_uh_line = qr/# User\@Host: ([^\[]+|\[[^[]+\]).*?@ (\S*) \[(.*)\]/;
 
45
my $slow_log_uh_line = qr/# User\@Host: ([^\[]+|\[[^[]+\]).*?@ (\S*) \[(.*)\]\s*(?:Id:\s*(\d+))?/;
46
46
# These can appear in the log file when it's opened -- for example, when someone
47
47
# runs FLUSH LOGS or the server starts.
48
48
# /usr/sbin/mysqld, Version: 5.0.67-0ubuntu6-log ((Ubuntu)). started with:
159
159
               ++$got_ts;
160
160
               # The User@Host might be concatenated onto the end of the Time.
161
161
               if ( !$got_uh
162
 
                  && ( my ( $user, $host, $ip ) = $line =~ m/$slow_log_uh_line/o )
 
162
                  && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
163
163
               ) {
164
164
                  PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
165
165
                  push @properties, 'user', $user, 'host', $host, 'ip', $ip;
166
 
                  ++$got_uh;
 
166
                  # 5.6 has the thread id on the User@Host line
 
167
                  if ( $thread_id ) {  
 
168
                     push @properties, 'Thread_id', $thread_id;
 
169
                 }
 
170
                 ++$got_uh;
167
171
               }
168
172
            }
169
173
 
170
174
            # Maybe it's the user/host line of a slow query log
171
175
            # # User@Host: root[root] @ localhost []
172
176
            elsif ( !$got_uh
173
 
                  && ( my ( $user, $host, $ip ) = $line =~ m/$slow_log_uh_line/o )
 
177
                  && ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
174
178
            ) {
175
 
               PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
176
 
               push @properties, 'user', $user, 'host', $host, 'ip', $ip;
 
179
                  PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
 
180
                  push @properties, 'user', $user, 'host', $host, 'ip', $ip;
 
181
                  # 5.6 has the thread id on the User@Host line
 
182
                  if ( $thread_id ) {       
 
183
                     push @properties, 'Thread_id', $thread_id;
 
184
                 }
177
185
               ++$got_uh;
178
186
            }
179
187