mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 21:51:21 +00:00
Add func to col ident struct to fix QueryAdvisorRules.t.
This commit is contained in:
@@ -251,7 +251,7 @@ sub get_rules {
|
||||
my $cols = $event->{query_struct}->{columns};
|
||||
return unless $cols;
|
||||
foreach my $col ( @$cols ) {
|
||||
return 0 if $col->{col} eq '*';
|
||||
return 0 if $col->{col} eq '*' && !$col->{func};
|
||||
}
|
||||
return;
|
||||
},
|
||||
|
@@ -1299,8 +1299,9 @@ sub parse_identifier {
|
||||
return unless $type && $ident;
|
||||
PTDEBUG && _d("Parsing", $type, "identifier:", $ident);
|
||||
|
||||
my ($func, $expr);
|
||||
if ( $ident =~ m/^\w+\(/ ) { # Function like MIN(col)
|
||||
my ($func, $expr) = $ident =~ m/^(\w+)\(([^\)]*)\)/;
|
||||
($func, $expr) = $ident =~ m/^(\w+)\(([^\)]*)\)/;
|
||||
PTDEBUG && _d('Function', $func, 'arg', $expr);
|
||||
return { col => $ident } unless $expr; # NOW()
|
||||
$ident = $expr; # col from MAX(col)
|
||||
@@ -1340,6 +1341,10 @@ sub parse_identifier {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $func ) {
|
||||
$ident_struct{func} = uc $func;
|
||||
}
|
||||
|
||||
PTDEBUG && _d($type, "identifier struct:", Dumper(\%ident_struct));
|
||||
return \%ident_struct;
|
||||
}
|
||||
|
@@ -2065,7 +2065,7 @@ my @cases = (
|
||||
from => 'l ',
|
||||
where => 'col<100'
|
||||
},
|
||||
columns => [ { col => 'max(col)' } ],
|
||||
columns => [ { col => 'col', func => 'MAX' } ],
|
||||
context => 'scalar',
|
||||
from => [ { tbl => 'l' } ],
|
||||
nested => 1,
|
||||
|
Reference in New Issue
Block a user