diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/DB.pm index 9d4f41546b5..07b2c5fe94b 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB.pm @@ -313,6 +313,13 @@ sub sql_istring { return "LOWER($string)"; } +sub sql_iposition { + my ($self, $fragment, $text) = @_; + $fragment = $self->sql_istring($fragment); + $text = $self->sql_istring($text); + return $self->sql_position($fragment, $text); +} + sub sql_position { my ($self, $fragment, $text) = @_; @@ -1699,10 +1706,13 @@ Formatted SQL for interval function (scalar) =item B -Outputs proper SQL syntax determinig position of a substring +Outputs proper SQL syntax determining position of a substring (fragment) withing a string (text). Note: if the substring or text are string constants, they must be properly quoted (e.g. "'pattern'"). +It searches for the string in a case-sensitive manner. If you want to do +a case-insensitive search, use L. + =item B =over @@ -1719,6 +1729,10 @@ Formatted SQL for substring search (scalar) =back +=item C + +Just like L, but case-insensitive. + =item C =over diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB/Mysql.pm b/mozilla/webtools/bugzilla/Bugzilla/DB/Mysql.pm index 80f1cd79339..8a64d36465f 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB/Mysql.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB/Mysql.pm @@ -183,13 +183,14 @@ sub sql_interval { return "INTERVAL $interval $units"; } +sub sql_iposition { + my ($self, $fragment, $text) = @_; + return "INSTR($text, $fragment)"; +} + sub sql_position { my ($self, $fragment, $text) = @_; - # mysql 4.0.1 and lower do not support CAST - # (checksetup has a check for unsupported versions) - - my $server_version = $self->bz_server_version; return "INSTR(CAST($text AS BINARY), CAST($fragment AS BINARY))"; } diff --git a/mozilla/webtools/bugzilla/Bugzilla/Search.pm b/mozilla/webtools/bugzilla/Bugzilla/Search.pm index d74f09474f9..272b4115297 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Search.pm @@ -912,8 +912,7 @@ sub GetByWordListSubstr { if ($word ne "") { $sql_word = $dbh->quote($word); trick_taint($sql_word); - push(@list, $dbh->sql_position(lc($sql_word), - "LOWER($field)") . " > 0"); + push(@list, $dbh->sql_iposition($sql_word, $field) . " > 0"); } } @@ -1919,7 +1918,7 @@ sub _substring { my ($ff, $q, $term) = @func_args{qw(ff q term)}; my $dbh = Bugzilla->dbh; - $$term = $dbh->sql_position(lc($$q), "LOWER($$ff)") . " > 0"; + $$term = $dbh->sql_iposition($$q, $$ff) . " > 0"; } sub _notsubstring { @@ -1928,7 +1927,7 @@ sub _notsubstring { my ($ff, $q, $term) = @func_args{qw(ff q term)}; my $dbh = Bugzilla->dbh; - $$term = $dbh->sql_position(lc($$q), "LOWER($$ff)") . " = 0"; + $$term = $dbh->sql_iposition($$q, $$ff) . " = 0"; } sub _regexp {