diff --git a/bin/pt-query-advisor b/bin/pt-query-advisor index 85bc76d8..5f26b3fc 100755 --- a/bin/pt-query-advisor +++ b/bin/pt-query-advisor @@ -4056,8 +4056,8 @@ sub determine_table_for_column { sub _looks_like_column { my $col = shift; - return if $col eq '*' || $col eq 'NULL'; - return if $col =~ /\A(?:\b[0-9]+\b|[^(]+\(|\@{1,2}.+)/; + return if $col eq '*' || uc($col) eq 'NULL'; + return if $col =~ /\A(?:\b[0-9]+\b|\@{1,2}.+)/; return $col; } diff --git a/lib/QueryAdvisorRules.pm b/lib/QueryAdvisorRules.pm index 119eb1d0..3d4cddc1 100644 --- a/lib/QueryAdvisorRules.pm +++ b/lib/QueryAdvisorRules.pm @@ -667,8 +667,8 @@ sub determine_table_for_column { sub _looks_like_column { my $col = shift; # NULL, numbers, variables and functions are definitely not columns - return if $col eq '*' || $col eq 'NULL'; - return if $col =~ /\A(?:\b[0-9]+\b|[^(]+\(|\@{1,2}.+)/; + return if $col eq '*' || uc($col) eq 'NULL'; + return if $col =~ /\A(?:\b[0-9]+\b|\@{1,2}.+)/; return $col; } diff --git a/t/lib/QueryAdvisorRules.t b/t/lib/QueryAdvisorRules.t index 2733d390..3a8f6ca5 100644 --- a/t/lib/QueryAdvisorRules.t +++ b/t/lib/QueryAdvisorRules.t @@ -468,7 +468,7 @@ my @cases = ( }, { name => 'Bug 937234: wrong RES.001', - query => q{select NULL, 1, COUNT(*), @@time_zone, foo as field2 from t1 group by field2}, + query => q{select NULL, null, 1, COUNT(*), @@time_zone, foo as field2 from t1 group by field2}, advice => [qw(CLA.001)], }, {