From 9e902ebec4fb35ba8cd566905914adcd189dc99a Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" <> Date: Mon, 26 Jan 2004 12:04:28 +0000 Subject: 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 --- Bugzilla/Search.pm | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index cf42e073f..75cb65af6 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -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) . ")"); } } -- cgit v1.2.3-24-g4f1b