зеркало из https://github.com/mozilla/gecko-dev.git
Bug 245158: Combine multiple redundant LEFT JOINs into a single LEFT JOIN in Search.pm
r=zach,justdave a=justdave
This commit is contained in:
Родитель
d44bebbdef
Коммит
95e9a2e8a4
|
@ -980,6 +980,8 @@ sub init {
|
||||||
# @supptables = Tables and/or table aliases used in query
|
# @supptables = Tables and/or table aliases used in query
|
||||||
# %suppseen = A hash used to store all the tables in supptables to weed
|
# %suppseen = A hash used to store all the tables in supptables to weed
|
||||||
# out duplicates.
|
# out duplicates.
|
||||||
|
# @supplist = A list used to accumulate all the JOIN clauses for each
|
||||||
|
# chart to merge the ON sections of each.
|
||||||
# $suppstring = String which is pasted into query containing all table names
|
# $suppstring = String which is pasted into query containing all table names
|
||||||
|
|
||||||
# get a list of field names to verify the user-submitted chart fields against
|
# get a list of field names to verify the user-submitted chart fields against
|
||||||
|
@ -1061,15 +1063,25 @@ sub init {
|
||||||
}
|
}
|
||||||
my %suppseen = ("bugs" => 1);
|
my %suppseen = ("bugs" => 1);
|
||||||
my $suppstring = "bugs";
|
my $suppstring = "bugs";
|
||||||
|
my @supplist = (" ");
|
||||||
foreach my $str (@supptables) {
|
foreach my $str (@supptables) {
|
||||||
if (!$suppseen{$str}) {
|
if (!$suppseen{$str}) {
|
||||||
if ($str !~ /^(LEFT|INNER) JOIN/i) {
|
if ($str =~ /^(LEFT|INNER) JOIN/i) {
|
||||||
$suppstring .= ",";
|
$str =~ /^(.*?)\s+ON\s+(.*)$/i;
|
||||||
|
my ($leftside, $rightside) = ($1, $2);
|
||||||
|
if ($suppseen{$leftside}) {
|
||||||
|
$supplist[$suppseen{$leftside}] .= " AND ($rightside)";
|
||||||
|
} else {
|
||||||
|
$suppseen{$leftside} = scalar @supplist;
|
||||||
|
push @supplist, " $leftside ON ($rightside)";
|
||||||
}
|
}
|
||||||
$suppstring .= " $str";
|
} else {
|
||||||
|
$suppstring .= ", $str";
|
||||||
$suppseen{$str} = 1;
|
$suppseen{$str} = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$suppstring .= join('', @supplist);
|
||||||
|
|
||||||
# Make sure we create a legal SQL query.
|
# Make sure we create a legal SQL query.
|
||||||
@andlist = ("1 = 1") if !@andlist;
|
@andlist = ("1 = 1") if !@andlist;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче