提交 b5fb4c38 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #578 from andreitokar/issue#493

issue#493 Query with distinct/limit/offset subquery returns unexpected rows
......@@ -410,10 +410,12 @@ public class LocalResult implements ResultInterface, ResultTarget {
if (rows.size() > limit) {
rows = New.arrayList(rows.subList(0, limit));
rowCount = limit;
distinctRows = null;
}
} else {
if (limit < rowCount) {
rowCount = limit;
distinctRows = null;
}
}
}
......@@ -513,6 +515,7 @@ public class LocalResult implements ResultInterface, ResultTarget {
rowCount -= offset;
}
}
distinctRows = null;
}
@Override
......
......@@ -10308,6 +10308,9 @@ create table test(id int, name varchar);
insert into test values(5, 'b'), (5, 'b'), (20, 'a');
> update count: 3
drop table test;
> ok
select 0 from ((
select 0 as f from dual u1 where null in (?, ?, ?, ?, ?)
) union all (
......@@ -10739,3 +10742,22 @@ drop table card;
drop type CARD_SUIT;
> ok
----- Issue#493 -----
create table test (year int, action varchar(10));
> ok
insert into test values (2015, 'order'), (2016, 'order'), (2014, 'order');
> update count: 3
insert into test values (2014, 'execution'), (2015, 'execution'), (2016, 'execution');
> update count: 3
select * from test where year in (select distinct year from test order by year desc limit 1 offset 0);
> YEAR ACTION
> ---- ---------
> 2016 order
> 2016 execution
drop table test;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论