summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DB.pm10
-rw-r--r--Bugzilla/Search.pm10
2 files changed, 19 insertions, 1 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 684869006..a766a6e04 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -164,6 +164,16 @@ sub _handle_error {
return 0; # Now let DBI handle raising the error
}
+my $cached_server_version;
+sub server_version {
+ return $cached_server_version if defined($cached_server_version);
+ my $dbh = Bugzilla->dbh;
+ my $sth = $dbh->prepare('SELECT VERSION()');
+ $sth->execute();
+ ($cached_server_version) = $sth->fetchrow_array();
+ return $cached_server_version;
+}
+
1;
__END__
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 241439cf5..5f0e625aa 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -711,7 +711,15 @@ sub init {
$term = "$ff != $q";
},
",casesubstring" => sub {
- $term = "INSTR(CAST($ff AS BINARY), CAST($q AS BINARY))";
+ # mysql 4.0.1 and lower do not support CAST
+ # mysql 3.*.* had a case-sensitive INSTR
+ # (checksetup has a check for unsupported versions)
+ my $server_version = Bugzilla::DB->server_version;
+ if ($server_version =~ /^3\./) {
+ $term = "INSTR($ff ,$q)";
+ } else {
+ $term = "INSTR(CAST($ff AS BINARY), CAST($q AS BINARY))";
+ }
},
",substring" => sub {
$term = "INSTR(LOWER($ff), " . lc($q) . ")";