mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 06:00:14 +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};
|
my $cols = $event->{query_struct}->{columns};
|
||||||
return unless $cols;
|
return unless $cols;
|
||||||
foreach my $col ( @$cols ) {
|
foreach my $col ( @$cols ) {
|
||||||
return 0 if $col->{col} eq '*';
|
return 0 if $col->{col} eq '*' && !$col->{func};
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
@@ -1299,8 +1299,9 @@ sub parse_identifier {
|
|||||||
return unless $type && $ident;
|
return unless $type && $ident;
|
||||||
PTDEBUG && _d("Parsing", $type, "identifier:", $ident);
|
PTDEBUG && _d("Parsing", $type, "identifier:", $ident);
|
||||||
|
|
||||||
|
my ($func, $expr);
|
||||||
if ( $ident =~ m/^\w+\(/ ) { # Function like MIN(col)
|
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);
|
PTDEBUG && _d('Function', $func, 'arg', $expr);
|
||||||
return { col => $ident } unless $expr; # NOW()
|
return { col => $ident } unless $expr; # NOW()
|
||||||
$ident = $expr; # col from MAX(col)
|
$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));
|
PTDEBUG && _d($type, "identifier struct:", Dumper(\%ident_struct));
|
||||||
return \%ident_struct;
|
return \%ident_struct;
|
||||||
}
|
}
|
||||||
|
@@ -2065,7 +2065,7 @@ my @cases = (
|
|||||||
from => 'l ',
|
from => 'l ',
|
||||||
where => 'col<100'
|
where => 'col<100'
|
||||||
},
|
},
|
||||||
columns => [ { col => 'max(col)' } ],
|
columns => [ { col => 'col', func => 'MAX' } ],
|
||||||
context => 'scalar',
|
context => 'scalar',
|
||||||
from => [ { tbl => 'l' } ],
|
from => [ { tbl => 'l' } ],
|
||||||
nested => 1,
|
nested => 1,
|
||||||
|
Reference in New Issue
Block a user