Commit 4707614b authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 804505: Oracle crashes when typing "word1 word2" in QuickSearch with…

Bug 804505: Oracle crashes when typing "word1 word2" in QuickSearch with "ORA-29907: found duplicate labels in primary invocations" r=dkl a=LpSolit
parent 8954b0c3
...@@ -519,17 +519,14 @@ sub possible_duplicates { ...@@ -519,17 +519,14 @@ sub possible_duplicates {
if ($dbh->FULLTEXT_OR) { if ($dbh->FULLTEXT_OR) {
my $joined_terms = join($dbh->FULLTEXT_OR, @words); my $joined_terms = join($dbh->FULLTEXT_OR, @words);
($where_sql, $relevance_sql) = ($where_sql, $relevance_sql) =
$dbh->sql_fulltext_search('bugs_fulltext.short_desc', $dbh->sql_fulltext_search('bugs_fulltext.short_desc', $joined_terms);
$joined_terms, 1);
$relevance_sql ||= $where_sql; $relevance_sql ||= $where_sql;
} }
else { else {
my (@where, @relevance); my (@where, @relevance);
my $count = 0;
foreach my $word (@words) { foreach my $word (@words) {
$count++;
my ($term, $rel_term) = $dbh->sql_fulltext_search( my ($term, $rel_term) = $dbh->sql_fulltext_search(
'bugs_fulltext.short_desc', $word, $count); 'bugs_fulltext.short_desc', $word);
push(@where, $term); push(@where, $term);
push(@relevance, $rel_term || $term); push(@relevance, $rel_term || $term);
} }
......
...@@ -41,6 +41,8 @@ use constant BLOB_TYPE => { ora_type => ORA_BLOB }; ...@@ -41,6 +41,8 @@ use constant BLOB_TYPE => { ora_type => ORA_BLOB };
use constant MIN_LONG_READ_LEN => 32 * 1024; use constant MIN_LONG_READ_LEN => 32 * 1024;
use constant FULLTEXT_OR => ' OR '; use constant FULLTEXT_OR => ' OR ';
our $fulltext_label = 0;
sub new { sub new {
my ($class, $params) = @_; my ($class, $params) = @_;
my ($user, $pass, $host, $dbname, $port) = my ($user, $pass, $host, $dbname, $port) =
...@@ -156,11 +158,13 @@ sub sql_from_days{ ...@@ -156,11 +158,13 @@ sub sql_from_days{
return " TO_DATE($date,'J') "; return " TO_DATE($date,'J') ";
} }
sub sql_fulltext_search { sub sql_fulltext_search {
my ($self, $column, $text, $label) = @_; my ($self, $column, $text) = @_;
$text = $self->quote($text); $text = $self->quote($text);
trick_taint($text); trick_taint($text);
return "CONTAINS($column,$text,$label) > 0", "SCORE($label)"; $fulltext_label++;
return "CONTAINS($column,$text,$fulltext_label) > 0", "SCORE($fulltext_label)";
} }
sub sql_date_format { sub sql_date_format {
......
...@@ -2340,9 +2340,9 @@ sub _content_matches { ...@@ -2340,9 +2340,9 @@ sub _content_matches {
# Create search terms to add to the SELECT and WHERE clauses. # Create search terms to add to the SELECT and WHERE clauses.
my ($term1, $rterm1) = my ($term1, $rterm1) =
$dbh->sql_fulltext_search("$table.$comments_col", $value, 1); $dbh->sql_fulltext_search("$table.$comments_col", $value);
my ($term2, $rterm2) = my ($term2, $rterm2) =
$dbh->sql_fulltext_search("$table.short_desc", $value, 2); $dbh->sql_fulltext_search("$table.short_desc", $value);
$rterm1 = $term1 if !$rterm1; $rterm1 = $term1 if !$rterm1;
$rterm2 = $term2 if !$rterm2; $rterm2 = $term2 if !$rterm2;
......
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