Unverified 提交 199c7ec4 authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Fix updateMeta()

上级 ab9408d9
...@@ -915,11 +915,6 @@ public class Database implements DataHandler { ...@@ -915,11 +915,6 @@ public class Database implements DataHandler {
verifyMetaLocked(session); verifyMetaLocked(session);
} }
meta.addRow(session, r); meta.addRow(session, r);
if (isMVStore()) {
// TODO this should work without MVCC, but avoid risks at the
// moment
session.log(meta, UndoLogRecord.INSERT, r);
}
} }
} }
...@@ -1021,11 +1016,6 @@ public class Database implements DataHandler { ...@@ -1021,11 +1016,6 @@ public class Database implements DataHandler {
} }
Row found = cursor.get(); Row found = cursor.get();
meta.removeRow(session, found); meta.removeRow(session, found);
if (isMVStore()) {
// TODO this should work without MVCC, but avoid risks at
// the moment
session.log(meta, UndoLogRecord.DELETE, found);
}
if (SysProperties.CHECK) { if (SysProperties.CHECK) {
checkMetaFree(session, id); checkMetaFree(session, id);
} }
...@@ -1724,22 +1714,32 @@ public class Database implements DataHandler { ...@@ -1724,22 +1714,32 @@ public class Database implements DataHandler {
* @param obj the database object * @param obj the database object
*/ */
public void updateMeta(Session session, DbObject obj) { public void updateMeta(Session session, DbObject obj) {
lockMeta(session); if (isMVStore()) {
synchronized (this) { synchronizes (this) {
int id = obj.getId(); int id = obj.getId();
if(id > 0) { if (id > 0) {
if(!starting && !obj.isTemporary()) { if (!starting && !obj.isTemporary()) {
Row newRow = meta.getTemplateRow(); Row newRow = meta.getTemplateRow();
MetaRecord.populateRowFromDBObject(obj, newRow); MetaRecord.populateRowFromDBObject(obj, newRow);
Row oldRow = metaIdIndex.getRow(session, id); Row oldRow = metaIdIndex.getRow(session, id);
if (oldRow != null) { if (oldRow != null) {
meta.updateRow(session, oldRow, newRow); meta.updateRow(session, oldRow, newRow);
}
} }
// removeMeta(session, id); // for temporary objects
// addMeta(session, obj); objectIds.set(id);
} }
}
} else {
lockMeta(session);
synchronized (this) {
int id = obj.getId();
removeMeta(session, id);
addMeta(session, obj);
// for temporary objects // for temporary objects
objectIds.set(id); if(id > 0) {
objectIds.set(id);
}
} }
} }
} }
...@@ -1796,9 +1796,6 @@ public class Database implements DataHandler { ...@@ -1796,9 +1796,6 @@ public class Database implements DataHandler {
} }
} }
obj.checkRename(); obj.checkRename();
int id = obj.getId();
lockMeta(session);
removeMeta(session, id);
map.remove(obj.getName()); map.remove(obj.getName());
obj.rename(newName); obj.rename(newName);
map.put(newName, obj); map.put(newName, obj);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论