提交 b4616c5e authored 作者: noelgrandin's avatar noelgrandin

make the code read easier

上级 b69287cb
...@@ -112,14 +112,23 @@ public class Sequence extends SchemaObjectBase { ...@@ -112,14 +112,23 @@ public class Sequence extends SchemaObjectBase {
* @param session the session * @param session the session
*/ */
public synchronized void flush(Session session) { public synchronized void flush(Session session) {
Session sysSession = database.getSystemSession();
if (session == null || !database.isSysTableLocked()) { if (session == null || !database.isSysTableLocked()) {
// this session may not lock the sys table (except if it already has locked it) // this session may not lock the sys table (except if it already has locked it)
// because it must be committed immediately // because it must be committed immediately
// otherwise other threads can not access the sys table. // otherwise other threads can not access the sys table.
session = sysSession; Session sysSession = database.getSystemSession();
synchronized (sysSession) {
flushInternal(sysSession);
sysSession.commit(false);
} }
} else {
synchronized (session) { synchronized (session) {
flushInternal(session);
}
}
}
private void flushInternal(Session session) {
// just for this case, use the value with the margin for the script // just for this case, use the value with the margin for the script
long realValue = value; long realValue = value;
try { try {
...@@ -128,12 +137,6 @@ public class Sequence extends SchemaObjectBase { ...@@ -128,12 +137,6 @@ public class Sequence extends SchemaObjectBase {
} finally { } finally {
value = realValue; value = realValue;
} }
if (session == sysSession) {
// if the system session is used,
// the transaction must be committed immediately
sysSession.commit(false);
}
}
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论