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