提交 430e6959 authored 作者: christian.peter.io's avatar christian.peter.io

An IndexOutOfBoundsException could occur in the page store (eg. on "delete from table"). Fixed.

上级 14b1be3c
...@@ -25,6 +25,7 @@ Change Log ...@@ -25,6 +25,7 @@ Change Log
The exception contained the text "parent not found" (version 1.2.129) or The exception contained the text "parent not found" (version 1.2.129) or
"Table not found" (version 1.2.130). "Table not found" (version 1.2.130).
</li><li>After the database was closed, a null pointer exception could occur in Database.flush. </li><li>After the database was closed, a null pointer exception could occur in Database.flush.
</li><li>An IndexOutOfBoundsException could occur in the page store (eg. on "delete from table"). Fixed.
</li></ul> </li></ul>
<h2>Version 1.2.130 (2010-02-26)</h2> <h2>Version 1.2.130 (2010-02-26)</h2>
......
...@@ -230,10 +230,10 @@ public class Data { ...@@ -230,10 +230,10 @@ public class Data {
* @param len the new length * @param len the new length
*/ */
public void fill(int len) { public void fill(int len) {
if (pos > len) {
pos = len; pos = len;
if (data.length < len) {
checkCapacity(len - data.length);
} }
pos = len;
} }
/** /**
......
...@@ -35,6 +35,7 @@ public class TestCases extends TestBase { ...@@ -35,6 +35,7 @@ public class TestCases extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testDeleteIndexOutOfBounds();
testOrderByWithSubselect(); testOrderByWithSubselect();
testInsertDeleteRollback(); testInsertDeleteRollback();
testLargeRollback(); testLargeRollback();
...@@ -76,6 +77,20 @@ public class TestCases extends TestBase { ...@@ -76,6 +77,20 @@ public class TestCases extends TestBase {
deleteDb("cases"); deleteDb("cases");
} }
private void testDeleteIndexOutOfBounds() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE IF NOT EXISTS test (rowid INTEGER PRIMARY KEY AUTO_INCREMENT, txt VARCHAR(64000));");
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 3000; i++) {
builder.append("abc");
stat.execute("insert into test (txt) values ('" + builder.toString() + "');");
}
stat.execute("DELETE FROM test;");
conn.close();
}
private void testInsertDeleteRollback() throws SQLException { private void testInsertDeleteRollback() throws SQLException {
deleteDb("cases"); deleteDb("cases");
Connection conn = getConnection("cases"); Connection conn = getConnection("cases");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论