提交 9510db6b authored 作者: Thomas Mueller's avatar Thomas Mueller

Inserting rows in reverse order could throw an ArrayIndexOutOfBoundsException in…

Inserting rows in reverse order could throw an ArrayIndexOutOfBoundsException in some cases (specially rows larger than the page size, which is 2 KB by default). Issue 226.
上级 2b68ce3e
......@@ -214,7 +214,7 @@ abstract class PageData extends Page {
* @param key the key
* @return the row
*/
abstract Row getRow(long key);
abstract Row getRowWithKey(long key);
/**
* Get the estimated memory size.
......
......@@ -380,7 +380,7 @@ public class PageDataIndex extends PageIndex {
}
public Row getRow(Session session, long key) {
return getRow(key);
return getRowWithKey(key);
}
/**
......@@ -389,9 +389,9 @@ public class PageDataIndex extends PageIndex {
* @param key the key
* @return the row
*/
public Row getRow(long key) {
public Row getRowWithKey(long key) {
PageData root = getPage(rootPageId, 0);
return root.getRow(key);
return root.getRowWithKey(key);
}
PageStore getPageStore() {
......
......@@ -270,7 +270,7 @@ public class PageDataLeaf extends PageData {
if (!SysProperties.OPTIMIZE_UPDATE) {
readAllRows();
}
Row r = getRow(i);
Row r = getRowAt(i);
if (r != null) {
memoryChange(false, r);
}
......@@ -278,10 +278,13 @@ public class PageDataLeaf extends PageData {
if (entryCount < 0) {
DbException.throwInternalError();
}
if (firstOverflowPageId != 0) {
start -= 4;
freeOverflow();
firstOverflowPageId = 0;
overflowRowSize = 0;
rowRef = null;
}
int keyOffsetPairLen = 2 + Data.getVarLongLen(keys[i]);
int startNext = i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize();
int rowLength = startNext - offsets[i];
......@@ -430,7 +433,7 @@ public class PageDataLeaf extends PageData {
}
}
Row getRow(long key) {
Row getRowWithKey(long key) {
int at = find(key);
return getRowAt(at);
}
......
......@@ -264,10 +264,10 @@ public class PageDataNode extends PageData {
}
}
Row getRow(long key) {
Row getRowWithKey(long key) {
int at = find(key);
PageData page = index.getPage(childPageIds[at], getPos());
return page.getRow(key);
return page.getRowWithKey(key);
}
int getRowCount() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论