提交 87be3ddb authored 作者: Thomas Mueller's avatar Thomas Mueller

Descending indexes on MVStore tables did not work properly.

上级 e4791847
......@@ -119,8 +119,17 @@ public class ValueDataType implements DataType {
if (a == b) {
return 0;
}
boolean aNull = a == null || a == ValueNull.INSTANCE;
boolean bNull = b == null || b == ValueNull.INSTANCE;
// null is never stored;
// comparison with null is used to retrieve all entries
// in which case null is always lower than all entries
// (even for descending ordered indexes)
if (a == null) {
return -1;
} else if (b == null) {
return 1;
}
boolean aNull = a == ValueNull.INSTANCE;
boolean bNull = b == ValueNull.INSTANCE;
if (aNull || bNull) {
return SortOrder.compareNull(aNull, sortType);
}
......
......@@ -3,6 +3,24 @@
-- Initial Developer: H2 Group
--
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(a int, b int);
> ok
insert into test values(1, 1);
> update count: 1
create index on test(a, b desc);
> ok
select * from test where a = 1;
> A B
> - -
> 1 1
> rows: 1
drop table test;
> ok
create table test(id int, name varchar) as select 1, 'a';
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论