summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2011-08-16 03:15:05 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2011-08-16 03:15:05 +0200
commita14cd9ea38a1fefe3b4d586ea33920fd40ee4f65 (patch)
treec693d04b66fc52246168a9aec48c4e4cdfdfc9a2 /Bugzilla/DB
parent92944f05e0626b212a17c4a0641c78453805a4c3 (diff)
downloadbugzilla-a14cd9ea38a1fefe3b4d586ea33920fd40ee4f65.tar.gz
bugzilla-a14cd9ea38a1fefe3b4d586ea33920fd40ee4f65.tar.xz
Bug 582209: Bugzilla::DB::Oracle::adjust_statement() LIMIT code corrupts sub-selects
r/a=mkanat
Diffstat (limited to 'Bugzilla/DB')
-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;
}