summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2011-08-16 03:10:16 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2011-08-16 03:10:16 +0200
commit3da85699775c76b1a1f982ee98011e6e501e884e (patch)
tree6490db9b44ff11fc7acc7174427fe5cfab0eae48
parentd9a3904454980dd10f5fddd973e254ab138764b6 (diff)
downloadbugzilla-3da85699775c76b1a1f982ee98011e6e501e884e.tar.gz
bugzilla-3da85699775c76b1a1f982ee98011e6e501e884e.tar.xz
Bug 582209: Bugzilla::DB::Oracle::adjust_statement() LIMIT code corrupts sub-selects
r/a=mkanat
-rw-r--r--Bugzilla/DB/Oracle.pm25
1 files changed, 11 insertions, 14 deletions
diff --git a/Bugzilla/DB/Oracle.pm b/Bugzilla/DB/Oracle.pm
index 9fdacf24c..f444129e1 100644
--- a/Bugzilla/DB/Oracle.pm
+++ b/Bugzilla/DB/Oracle.pm
@@ -379,20 +379,17 @@ sub adjust_statement {
if ($new_sql !~ /\bWHERE\b/) {
$new_sql = $new_sql." WHERE 1=1";
}
- my ($before_where, $after_where) = split /\bWHERE\b/i,$new_sql;
- if (defined($offset)) {
- if ($new_sql =~ /(.*\s+)FROM(\s+.*)/i) {
- my ($before_from,$after_from) = ($1,$2);
- $before_where = "$before_from FROM ($before_from,"
- . " ROW_NUMBER() OVER (ORDER BY 1) R "
- . " FROM $after_from ) ";
- $after_where = " R BETWEEN $offset+1 AND $limit+$offset";
- }
- } else {
- $after_where = " rownum <=$limit AND ".$after_where;
- }
-
- $new_sql = $before_where." WHERE ".$after_where;
+ my ($before_where, $after_where) = split(/\bWHERE\b/i, $new_sql, 2);
+ if (defined($offset)) {
+ my ($before_from, $after_from) = split(/\bFROM\b/i, $new_sql, 2);
+ $before_where = "$before_from FROM ($before_from,"
+ . " ROW_NUMBER() OVER (ORDER BY 1) R "
+ . " FROM $after_from ) ";
+ $after_where = " R BETWEEN $offset+1 AND $limit+$offset";
+ } else {
+ $after_where = " rownum <=$limit AND ".$after_where;
+ }
+ $new_sql = $before_where." WHERE ".$after_where;
}
return $new_sql;
}