提交 4658e526 authored 作者: Thomas Mueller's avatar Thomas Mueller

Page store: getting the min value from a descending index with NULL entries…

Page store: getting the min value from a descending index with NULL entries could return the wrong result.
上级 01bd822e
...@@ -300,7 +300,7 @@ public class PageBtreeNode extends PageBtree { ...@@ -300,7 +300,7 @@ public class PageBtreeNode extends PageBtree {
} }
PageBtreeLeaf getLastLeaf() throws SQLException { PageBtreeLeaf getLastLeaf() throws SQLException {
int child = childPageIds[entryCount - 1]; int child = childPageIds[entryCount];
return index.getPage(child).getLastLeaf(); return index.getPage(child).getLastLeaf();
} }
......
...@@ -36,6 +36,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -36,6 +36,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
} }
public void test() throws Exception { public void test() throws Exception {
testReverseIndex();
testLargeUpdates(); testLargeUpdates();
testLargeInserts(); testLargeInserts();
testAutoConvert(); testAutoConvert();
...@@ -53,6 +54,27 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -53,6 +54,27 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
testFuzzOperations(); testFuzzOperations();
} }
private void testReverseIndex() throws SQLException {
if (config.memory) {
return;
}
deleteDb("pageStore");
Connection conn = getConnection("pageStore");
Statement stat = conn.createStatement();
stat.execute("create table test(x int, y varchar default space(200))");
for (int i = 30; i < 100; i++) {
stat.execute("insert into test(x) select null from system_range(1, " + i + ")");
stat.execute("insert into test(x) select x from system_range(1, " + i + ")");
stat.execute("create index idx on test(x desc, y)");
ResultSet rs = stat.executeQuery("select min(x) from test");
rs.next();
assertEquals(1, rs.getInt(1));
stat.execute("drop index idx");
stat.execute("truncate table test");
}
conn.close();
}
private void testLargeUpdates() throws SQLException { private void testLargeUpdates() throws SQLException {
if (config.memory) { if (config.memory) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论