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