summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-03-05 16:36:07 +0100
committermkanat%kerio.com <>2005-03-05 16:36:07 +0100
commit0c1b77e123dbafb96168fe6affd6373b9aa081fe (patch)
tree9f4bf1de4a3b85d423238ed47a56746d70181e24 /Bugzilla/Search.pm
parent8b47184604eb5868736e0a2a8ae894f6feceaa95 (diff)
downloadbugzilla-0c1b77e123dbafb96168fe6affd6373b9aa081fe.tar.gz
bugzilla-0c1b77e123dbafb96168fe6affd6373b9aa081fe.tar.xz
Bug 284598: INSTR function is not supported by postgres
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=justdave
Diffstat (limited to 'Bugzilla/Search.pm')
-rw-r--r--Bugzilla/Search.pm23
1 files changed, 9 insertions, 14 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 1a0cb9a7f..775778a9d 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -951,24 +951,16 @@ sub init {
$term = "$ff != $q";
},
",casesubstring" => sub {
- # 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 = $dbh->bz_server_version;
- if ($dbh->isa('Bugzilla::DB::Mysql') && $server_version =~ /^3\./) {
- $term = "INSTR($ff ,$q)";
- } else {
- $term = "INSTR(CAST($ff AS BINARY), CAST($q AS BINARY))";
- }
+ $term = $dbh->sql_position($q, $ff);
},
",substring" => sub {
- $term = "INSTR(LOWER($ff), " . lc($q) . ")";
+ $term = $dbh->sql_position(lc($q), "LOWER($ff)");
},
",substr" => sub {
$funcsbykey{",substring"}->();
},
",notsubstring" => sub {
- $term = "INSTR(LOWER($ff), " . lc($q) . ") = 0";
+ $term = $dbh->sql_position(lc($q), "LOWER($ff)") . " = 0";
},
",regexp" => sub {
$term = "LOWER($ff) " . $dbh->sql_regexp() . " $q";
@@ -1426,8 +1418,9 @@ sub ListIDsForEmail {
}
$list = join(',', @list);
} elsif ($type eq 'substring') {
- &::SendSQL("SELECT userid FROM profiles WHERE INSTR(login_name, " .
- &::SqlQuote($email) . ") " . $dbh->sql_limit(51));
+ &::SendSQL("SELECT userid FROM profiles WHERE " .
+ $dbh->sql_position(lc(::SqlQuote($email)), "LOWER(login_name)") .
+ " " . $dbh->sql_limit(51));
while (&::MoreSQLData()) {
my ($id) = &::FetchSQLData();
push(@list, $id);
@@ -1478,10 +1471,12 @@ sub GetByWordList {
sub GetByWordListSubstr {
my ($field, $strs) = (@_);
my @list;
+ my $dbh = Bugzilla->dbh;
foreach my $word (split(/[\s,]+/, $strs)) {
if ($word ne "") {
- push(@list, "INSTR(LOWER($field), " . lc(&::SqlQuote($word)) . ")");
+ push(@list, $dbh->sql_position(lc(::SqlQuote($word)),
+ "LOWER($field)"));
}
}