提交 26000a01 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix WITH TIES for data types without total ordering

上级 b5737548
......@@ -405,15 +405,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
}
int to = offset + limit;
if (withTies && sort != null) {
int[] indexes = sort.getQueryColumnIndexes();
Value[] expected = rows.get(to - 1);
loop: while (to < rows.size()) {
Value[] current = rows.get(to);
for (int idx : indexes) {
if (!expected[idx].equals(current[idx])) {
break loop;
}
}
while (to < rows.size() && sort.compare(expected, rows.get(to)) == 0) {
to++;
rowCount++;
}
......@@ -446,14 +439,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
}
}
if (withTies && sort != null && row != null) {
int[] indexes = sort.getQueryColumnIndexes();
Value[] expected = row;
loop: while ((row = temp.next()) != null) {
for (int idx : indexes) {
if (!expected[idx].equals(row[idx])) {
break loop;
}
}
while ((row = temp.next()) != null && sort.compare(expected, row) == 0) {
rows.add(row);
rowCount++;
if (rows.size() > maxMemoryRows) {
......
......@@ -131,3 +131,20 @@ EXPLAIN SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIE
DROP TABLE TEST;
> ok
CREATE TABLE TEST(A NUMERIC, B NUMERIC);
> ok
INSERT INTO TEST VALUES (0, 1), (0.0, 2), (0, 3), (1, 4);
> update count: 4
SELECT A, B FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES;
> A B
> --- -
> 0 1
> 0 3
> 0.0 2
> rows: 3
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论