提交 36c23898 authored 作者: Thomas Mueller's avatar Thomas Mueller

When LOB objects are stored in the database (using the experimental setting…

When LOB objects are stored in the database (using the experimental setting h2.lobInDatabase), and using the MVCC mode, opening a database with uncommitted transactions could throw a NullPointerException.
上级 36702e9e
...@@ -47,13 +47,15 @@ public class PageDataIndex extends PageIndex { ...@@ -47,13 +47,15 @@ public class PageDataIndex extends PageIndex {
private DbException fastDuplicateKeyException; private DbException fastDuplicateKeyException;
private int memoryPerPage; private int memoryPerPage;
private int memoryCount; private int memoryCount;
private boolean multiVersion;
public PageDataIndex(RegularTable table, int id, IndexColumn[] columns, IndexType indexType, boolean create, Session session) { public PageDataIndex(RegularTable table, int id, IndexColumn[] columns, IndexType indexType, boolean create, Session session) {
initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType); initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType);
this.multiVersion = database.isMultiVersion();
// trace = database.getTrace(Trace.PAGE_STORE + "_di"); // trace = database.getTrace(Trace.PAGE_STORE + "_di");
// trace.setLevel(TraceSystem.DEBUG); // trace.setLevel(TraceSystem.DEBUG);
if (database.isMultiVersion()) { if (multiVersion) {
sessionRowCount = New.hashMap(); sessionRowCount = New.hashMap();
isMultiVersion = true; isMultiVersion = true;
} }
...@@ -178,7 +180,7 @@ public class PageDataIndex extends PageIndex { ...@@ -178,7 +180,7 @@ public class PageDataIndex extends PageIndex {
root = newRoot; root = newRoot;
} }
row.setDeleted(false); row.setDeleted(false);
if (database.isMultiVersion()) { if (multiVersion) {
if (delta == null) { if (delta == null) {
delta = New.hashSet(); delta = New.hashSet();
} }
...@@ -322,7 +324,7 @@ public class PageDataIndex extends PageIndex { ...@@ -322,7 +324,7 @@ public class PageDataIndex extends PageIndex {
store.incrementChangeCount(); store.incrementChangeCount();
} }
} }
if (database.isMultiVersion()) { if (multiVersion) {
// if storage is null, the delete flag is not yet set // if storage is null, the delete flag is not yet set
row.setDeleted(true); row.setDeleted(true);
if (delta == null) { if (delta == null) {
...@@ -355,7 +357,7 @@ public class PageDataIndex extends PageIndex { ...@@ -355,7 +357,7 @@ public class PageDataIndex extends PageIndex {
if (tableData.getContainsLargeObject() && tableData.isPersistData()) { if (tableData.getContainsLargeObject() && tableData.isPersistData()) {
database.getLobStorage().removeAllForTable(table.getId()); database.getLobStorage().removeAllForTable(table.getId());
} }
if (database.isMultiVersion()) { if (multiVersion) {
sessionRowCount.clear(); sessionRowCount.clear();
} }
tableData.setRowCount(0); tableData.setRowCount(0);
...@@ -422,7 +424,7 @@ public class PageDataIndex extends PageIndex { ...@@ -422,7 +424,7 @@ public class PageDataIndex extends PageIndex {
} }
public long getRowCount(Session session) { public long getRowCount(Session session) {
if (database.isMultiVersion()) { if (multiVersion) {
Integer i = sessionRowCount.get(session.getId()); Integer i = sessionRowCount.get(session.getId());
long count = i == null ? 0 : i.intValue(); long count = i == null ? 0 : i.intValue();
count += rowCount; count += rowCount;
...@@ -466,7 +468,7 @@ public class PageDataIndex extends PageIndex { ...@@ -466,7 +468,7 @@ public class PageDataIndex extends PageIndex {
} }
private void incrementRowCount(int sessionId, int count) { private void incrementRowCount(int sessionId, int count) {
if (database.isMultiVersion()) { if (multiVersion) {
Integer id = sessionId; Integer id = sessionId;
Integer c = sessionRowCount.get(id); Integer c = sessionRowCount.get(id);
int current = c == null ? 0 : c.intValue(); int current = c == null ? 0 : c.intValue();
...@@ -476,7 +478,7 @@ public class PageDataIndex extends PageIndex { ...@@ -476,7 +478,7 @@ public class PageDataIndex extends PageIndex {
} }
public void commit(int operation, Row row) { public void commit(int operation, Row row) {
if (database.isMultiVersion()) { if (multiVersion) {
if (delta != null) { if (delta != null) {
delta.remove(row); delta.remove(row);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论