]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 243351: Fix mysql version sensitivity in case-sensitive search
authorbugreport%peshkin.net <>
Thu, 27 May 2004 09:40:17 +0000 (09:40 +0000)
committerbugreport%peshkin.net <>
Thu, 27 May 2004 09:40:17 +0000 (09:40 +0000)
r=jouni
a=justdave

Bugzilla/DB.pm
Bugzilla/Search.pm
checksetup.pl

index 684869006ecdc1ff8e4cbbd85b0d078c48712bef..a766a6e04ba5558fa416f093c7c405367555bdc4 100644 (file)
@@ -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__
index 241439cf5904888cec18c7985b25b4b2322ccbc0..5f0e625aa5d4d98d099e86db1d50fb34b1936ee8 100644 (file)
@@ -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) . ")";
index 8fc37f2ad5eec81c15646c360a55bc8a0f10b4df..9d23579454a0b97dae9d25d68e852a53ffc64e37 100755 (executable)
@@ -1449,6 +1449,11 @@ if ($my_db_check) {
             "   Bugzilla requires version $sql_want or later of MySQL.\n" . 
             "   Please visit http://www.mysql.com/ and download a newer version.\n";
     }
+    if (( $sql_vers =~ /^4\.0\.(\d+)/ ) && ($1 < 2)) {
+        die "\nYour MySQL server is incompatible with Bugzilla.\n" .
+            "   Bugzilla does not support versions 4.x.x below 4.0.2.\n" .
+            "   Please visit http://www.mysql.com/ and download a newer version.\n";
+    }
 
     my @databases = $dbh->func('_ListDBs');
     unless (grep /^$my_db_name$/, @databases) {