Commit 9e902ebe authored by myk%mozilla.org's avatar myk%mozilla.org

Fix for bug 232150: Corrects "field changed" queries including [Bug creation] as…

Fix for bug 232150: Corrects "field changed" queries including [Bug creation] as one of the fields so that they actually work instead of taking forever. The query was structured as "[Bug creation] clause OR (bugs_activity JOIN clause OR (other field clauses))" when it should have been "bugs_activity JOIN CLAUSE AND ([Bug creation] clause OR other field clauses)" r=bbaetz a=myk
parent 088be66b
......@@ -255,35 +255,44 @@ sub init {
push(@wherepart, "bugs.delta_ts >= $sql_chfrom") if ($sql_chfrom);
push(@wherepart, "bugs.delta_ts <= $sql_chto") if ($sql_chto);
} else {
my $sql_bugschanged = '';
my $bug_creation_clause;
my @list;
foreach my $f (@chfield) {
if ($f eq "[Bug creation]") {
# Treat [Bug creation] differently because we need to look
# at bugs.creation_ts rather than the bugs_activity table.
my @l;
push(@l, "creation_ts >= $sql_chfrom") if($sql_chfrom);
push(@l, "creation_ts <= $sql_chto") if($sql_chto);
$sql_bugschanged = "(" . join(' AND ', @l) . ")";
$bug_creation_clause = "(" . join(' AND ', @l) . ")";
} else {
push(@list, "\nactcheck.fieldid = " . &::GetFieldID($f));
}
}
# @list won't have any elements if the only field being searched
# is [Bug creation] (in which case we don't need bugs_activity).
if(@list) {
push(@supptables, "bugs_activity actcheck");
$sql_bugschanged .= ' OR ' if($sql_bugschanged ne '');
$sql_bugschanged .= "(actcheck.bug_id = bugs.bug_id AND " .
"(" . join(' OR ', @list) . ")";
push(@wherepart, "actcheck.bug_id = bugs.bug_id");
if($sql_chfrom) {
$sql_bugschanged .= " AND actcheck.bug_when >= $sql_chfrom";
push(@wherepart, "actcheck.bug_when >= $sql_chfrom");
}
if($sql_chto) {
$sql_bugschanged .= " AND actcheck.bug_when <= $sql_chto";
push(@wherepart, "actcheck.bug_when <= $sql_chto");
}
if($sql_chvalue) {
$sql_bugschanged .= " AND actcheck.added = $sql_chvalue";
push(@wherepart, "actcheck.added = $sql_chvalue");
}
$sql_bugschanged .= ')';
}
push(@wherepart, "($sql_bugschanged)");
# Now that we're done using @list to determine if there are any
# regular fields to search (and thus we need bugs_activity),
# add the [Bug creation] criterion to the list so we can OR it
# together with the others.
push(@list, $bug_creation_clause) if $bug_creation_clause;
push(@wherepart, "(" . join(" OR ", @list) . ")");
}
}
......
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