提交 a2cad38b authored 作者: Andrei Tokar's avatar Andrei Tokar

cancel ids release on rollback

address review comments
上级 9bfb3448
......@@ -154,7 +154,6 @@ public class Insert extends Prepared implements ResultTarget {
Mode mode = session.getDatabase().getMode();
int columnLen = columns.length;
for (int x = 0; x < listSize; x++) {
session.startStatementWithinTransaction();
generatedKeys.nextRow();
Row newRow = table.getTemplateRow();
Expression[] expr = list.get(x);
......
......@@ -1084,7 +1084,7 @@ public class Database implements DataHandler {
// otherwise it might be re-used prematurely, and it would make
// rollback impossible or lead to MVMaps name collision,
// so until then ids are accumulated within session
session.releaseDatabaseObjectId(id);
session.scheduleDatabaseObjectIdForRelease(id);
} else {
// but PageStore, on the other hand, for reasons unknown to me,
// requires immediate id release
......
......@@ -166,7 +166,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
/**
* Set of database object ids to be released at the end of transaction
*/
private final BitSet idsToRelease = new BitSet();
private BitSet idsToRelease;
public Session(Database database, User user, int id) {
......@@ -634,7 +634,15 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
return command;
}
void releaseDatabaseObjectId(int id) {
/**
* Arranges for the specified database object id to be released
* at the end of the current transaction.
* @param id to be scheduled
*/
void scheduleDatabaseObjectIdForRelease(int id) {
if (idsToRelease == null) {
idsToRelease = new BitSet();
}
idsToRelease.set(id);
}
......@@ -757,8 +765,10 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
removeLobMap = null;
}
unlockAll();
if (idsToRelease != null) {
database.releaseDatabaseObjectIds(idsToRelease);
idsToRelease.clear();
idsToRelease = null;
}
}
/**
......@@ -775,6 +785,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
if (!locks.isEmpty() || needCommit) {
database.commit(this);
}
idsToRelease = null;
cleanTempTables(false);
if (autoCommitAtTransactionEnd) {
autoCommit = true;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论