提交 8968c0b6 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix limit in Select.queryFlat()

上级 a1713995
......@@ -639,7 +639,7 @@ public class Select extends Query {
private LazyResult queryFlat(int columnCount, ResultTarget result, long offset, long limitRows, boolean withTies,
boolean quickOffset) {
if (limitRows > 0 && offset > 0) {
if (limitRows > 0 && offset > 0 && !quickOffset) {
limitRows += offset;
if (limitRows < 0) {
// Overflow
......@@ -654,7 +654,7 @@ public class Select extends Query {
if (result == null) {
return lazyResult;
}
if (sort != null && !sortUsingIndex || limitRows <= 0 || withTies) {
if (sort != null && !sortUsingIndex || limitRows < 0 || withTies) {
limitRows = Long.MAX_VALUE;
}
while (result.getRowCount() < limitRows && lazyResult.next()) {
......@@ -726,6 +726,7 @@ public class Select extends Query {
!session.getDatabase().getSettings().optimizeInsertFromSelect)) {
result = createLocalResult(result);
}
// Do not add rows before OFFSET to result if possible
boolean quickOffset = true;
if (sort != null && (!sortUsingIndex || isAnyDistinct() || withTies)) {
result = createLocalResult(result);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论