Commit 0811ac92 authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 292119: [PostgreSQL] POSITION(...) clause "must be type boolean, not type integer"

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=justdave
parent 4f25eedf
...@@ -988,10 +988,10 @@ sub init { ...@@ -988,10 +988,10 @@ sub init {
$term = "$ff != $q"; $term = "$ff != $q";
}, },
",casesubstring" => sub { ",casesubstring" => sub {
$term = $dbh->sql_position($q, $ff); $term = $dbh->sql_position($q, $ff) . " > 0";
}, },
",substring" => sub { ",substring" => sub {
$term = $dbh->sql_position(lc($q), "LOWER($ff)"); $term = $dbh->sql_position(lc($q), "LOWER($ff)") . " > 0";
}, },
",substr" => sub { ",substr" => sub {
$funcsbykey{",substring"}->(); $funcsbykey{",substring"}->();
...@@ -1466,7 +1466,7 @@ sub ListIDsForEmail { ...@@ -1466,7 +1466,7 @@ sub ListIDsForEmail {
} elsif ($type eq 'substring') { } elsif ($type eq 'substring') {
&::SendSQL("SELECT userid FROM profiles WHERE " . &::SendSQL("SELECT userid FROM profiles WHERE " .
$dbh->sql_position(lc(::SqlQuote($email)), "LOWER(login_name)") . $dbh->sql_position(lc(::SqlQuote($email)), "LOWER(login_name)") .
" " . $dbh->sql_limit(51)); " > 0 " . $dbh->sql_limit(51));
while (&::MoreSQLData()) { while (&::MoreSQLData()) {
my ($id) = &::FetchSQLData(); my ($id) = &::FetchSQLData();
push(@list, $id); push(@list, $id);
...@@ -1522,7 +1522,7 @@ sub GetByWordListSubstr { ...@@ -1522,7 +1522,7 @@ sub GetByWordListSubstr {
foreach my $word (split(/[\s,]+/, $strs)) { foreach my $word (split(/[\s,]+/, $strs)) {
if ($word ne "") { if ($word ne "") {
push(@list, $dbh->sql_position(lc(::SqlQuote($word)), push(@list, $dbh->sql_position(lc(::SqlQuote($word)),
"LOWER($field)")); "LOWER($field)") . " > 0");
} }
} }
......
...@@ -682,18 +682,18 @@ sub match { ...@@ -682,18 +682,18 @@ sub match {
&& (length($str) >= 3)) && (length($str) >= 3))
{ {
my $sqlstr = &::SqlQuote(uc($str)); my $sqlstr = &::SqlQuote(lc($str));
my $query = "SELECT DISTINCT userid, realname, login_name, " . my $query = "SELECT DISTINCT userid, realname, login_name, " .
"LENGTH(login_name) AS namelength " . "LENGTH(login_name) AS namelength " .
"FROM profiles"; "FROM profiles";
if (&::Param('usevisibilitygroups')) { if (&::Param('usevisibilitygroups')) {
$query .= ", user_group_map"; $query .= ", user_group_map";
} }
$query .= " WHERE " . $dbh->sql_position($sqlstr, $query .= " WHERE " .
"UPPER(login_name)") . $dbh->sql_position($sqlstr, 'LOWER(login_name)') . " > 0" .
" OR " . $dbh->sql_position($sqlstr, " OR " .
"UPPER(realname)"); $dbh->sql_position($sqlstr, 'LOWER(realname)') . " > 0";
if (&::Param('usevisibilitygroups')) { if (&::Param('usevisibilitygroups')) {
$query .= " AND user_group_map.user_id = userid" . $query .= " AND user_group_map.user_id = userid" .
" AND isbless = 0" . " AND isbless = 0" .
......
...@@ -3687,8 +3687,8 @@ if ($dbh->isa('Bugzilla::DB::Mysql') ...@@ -3687,8 +3687,8 @@ if ($dbh->isa('Bugzilla::DB::Mysql')
print "Removing paths from filenames in attachments table...\n"; print "Removing paths from filenames in attachments table...\n";
$sth = $dbh->prepare("SELECT attach_id, filename FROM attachments " . $sth = $dbh->prepare("SELECT attach_id, filename FROM attachments " .
"WHERE " . $dbh->sql_position(q{'/'}, 'filename') . "WHERE " . $dbh->sql_position(q{'/'}, 'filename') . " > 0 OR " .
" OR " . $dbh->sql_position(q{'\\\\'}, 'filename')); $dbh->sql_position(q{'\\\\'}, 'filename') . " > 0");
$sth->execute; $sth->execute;
while (my ($attach_id, $filename) = $sth->fetchrow_array) { while (my ($attach_id, $filename) = $sth->fetchrow_array) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment