提交 eb221f73 authored 作者: Thomas Mueller's avatar Thomas Mueller

Indexes on column that are larger than half the page size (wide indexes) could…

Indexes on column that are larger than half the page size (wide indexes)  could sometimes get corrupt, resulting in an ArrayIndexOutOfBoundsException in PageBtree.getRow or "Row not found" in PageBtreeLeaf. Also, such indexes used too much disk space.
上级 53f933d2
......@@ -120,6 +120,7 @@ public class PageBtreeLeaf extends PageBtree {
return x < third ? third : x >= 2 * third ? 2 * third : x;
}
readAllRows();
writtenData = false;
onlyPosition = true;
// change the offsets (now storing only positions)
int o = pageSize;
......
......@@ -124,7 +124,7 @@ public class PageBtreeNode extends PageBtree {
* @return the split point of this page, or -1 if no split is required
*/
private int addChildTry(SearchRow row) {
if (entryCount < 3) {
if (entryCount < 4) {
return -1;
}
int startData;
......
......@@ -38,6 +38,7 @@ public class TestCases extends TestBase {
}
public void test() throws Exception {
testLargeKeys();
testExtraSemicolonInDatabaseURL();
testGroupSubquery();
testCountDistinctNotNull();
......@@ -97,6 +98,24 @@ public class TestCases extends TestBase {
deleteDb("cases");
}
private void testLargeKeys() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("create index on test(name)");
stat.execute("insert into test values(1, '1' || space(1500))");
conn.close();
conn = getConnection("cases");
stat = conn.createStatement();
stat.execute("insert into test values(2, '2' || space(1500))");
conn.close();
conn = getConnection("cases");
stat = conn.createStatement();
stat.executeQuery("select name from test order by name");
conn.close();
}
private void testExtraSemicolonInDatabaseURL() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases;");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论