Merge fix-genlog-db-bug

This commit is contained in:
Daniel Nichter
2012-12-10 16:41:11 -07:00
4 changed files with 61 additions and 4 deletions

View File

@@ -9692,7 +9692,8 @@ sub parse_event {
$cmd = $arg;
}
else {
my ($user, undef, $db) = $arg =~ /(\S+)/g;
my ($user) = $arg =~ m/(\S+)/;
my ($db) = $arg =~ m/on (\S+)/;
my $host;
($user, $host) = split(/@/, $user);
PTDEBUG && _d('Connect', $user, '@', $host, 'on', $db);

View File

@@ -129,7 +129,8 @@ sub parse_event {
else {
# The Connect command may or may not be followed by 'on'.
# When it is, 'on' may or may not be followed by a database.
my ($user, undef, $db) = $arg =~ /(\S+)/g;
my ($user) = $arg =~ m/(\S+)/;
my ($db) = $arg =~ m/on (\S+)/;
my $host;
($user, $host) = split(/@/, $user);
PTDEBUG && _d('Connect', $user, '@', $host, 'on', $db);

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 7;
use Test::More;
use GeneralLogParser;
use PerconaTest;
@@ -219,7 +219,58 @@ test_log_parser(
]
);
# Customer issue from Ernie.
test_log_parser(
parser => $p,
file => $sample.'genlog004.txt',
oktorun => sub { $oktorun = $_[0]; },
result => [
{
Query_time => 0,
Thread_id => '12345',
arg => q/administrator command: Access denied for user 'nobody'@'localhost' (using password: NO)
/,
bytes => 88,
cmd => 'Admin',
pos_in_log => 0,
ts => undef
},
{
Query_time => 0,
Thread_id => '12345',
arg => 'administrator command: Connect',
bytes => 30,
cmd => 'Admin',
host => 'localhost',
pos_in_log => 81,
ts => undef,
user => 'nobody'
},
{
Query_time => 0,
Thread_id => '31519',
arg => 'BEGIN',
bytes => 5,
cmd => 'Query',
pos_in_log => 122,
ts => undef
},
{
Query_time => 0,
Thread_id => '98765',
arg => 'administrator command: Connect',
bytes => 30,
cmd => 'Admin',
db => 'sar',
host => '1.2.3.4',
pos_in_log => 184,
ts => undef,
user => 'payments_r'
},
],
);
# #############################################################################
# Done.
# #############################################################################
exit;
done_testing;

View File

@@ -0,0 +1,4 @@
12345 Connect Access denied for user 'nobody'@'localhost' (using password: NO)
12345 Connect nobody@localhost as on
31519 Query BEGIN
98765 Connect payments_r@1.2.3.4 on sar