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

In some cases, creating a new table or altering an existing table threw the…

In some cases, creating a new table or altering an existing table threw the exception: Unique index or primary key violation: "PRIMARY KEY ON """".PAGE_INDEX".
上级 c0a5d3a9
......@@ -607,6 +607,16 @@ public class Database implements DataHandler {
setting.setIntValue(Constants.BUILD_ID);
addDatabaseObject(systemSession, setting);
}
// mark all ids used in the page store
if (pageStore != null) {
BitField f = pageStore.getObjectIds();
for (int i = 0, len = f.length(); i < len; i++) {
if (f.get(i) && !objectIds.get(i)) {
trace.info("unused object id: " + i);
objectIds.set(i);
}
}
}
}
systemSession.commit(true);
trace.info("opened {0}", databaseName);
......
......@@ -1874,4 +1874,17 @@ public class PageStore implements CacheWriter {
this.lockFile = lockFile;
}
public BitField getObjectIds() {
BitField f = new BitField();
Cursor cursor = metaIndex.find(systemSession, null, null);
while (cursor.next()) {
Row row = cursor.get();
int id = row.getValue(0).getInt();
if (id > 0) {
f.set(id);
}
}
return f;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论