提交 f8fca82f authored 作者: christian.peter.io's avatar christian.peter.io

Serialized mode: set getGeneratedKeys and other fields to null if session…

Serialized mode: set getGeneratedKeys and other fields to null if session reconnects. Actually Thomas wrote most of the patch.
上级 ea50a557
......@@ -31,6 +31,7 @@ Change Log
</li><li>CompressLZF: faster decompression.
</li><li>PgServer: the wrong size was sent for VARCHAR data.
Thanks again to Sergi Vladykin for the patch.
</li><li>Serialized access mode (server-less multi-connection mode): fixed getGeneratedKeys() for sequences.
</li></ul>
<h2>Version 1.2.127 (2010-01-15)</h2>
......
......@@ -311,17 +311,7 @@ public class JdbcConnection extends TraceObject implements Connection {
rollbackInternal();
session.afterWriting();
}
commit = closeAndSetNull(commit);
rollback = closeAndSetNull(rollback);
setAutoCommitTrue = closeAndSetNull(setAutoCommitTrue);
setAutoCommitFalse = closeAndSetNull(setAutoCommitFalse);
getAutoCommit = closeAndSetNull(getAutoCommit);
getReadOnly = closeAndSetNull(getReadOnly);
getGeneratedKeys = closeAndSetNull(getGeneratedKeys);
getLockMode = closeAndSetNull(getLockMode);
setLockMode = closeAndSetNull(setLockMode);
getQueryTimeout = closeAndSetNull(getQueryTimeout);
setQueryTimeout = closeAndSetNull(setQueryTimeout);
closePreparedCommands();
} finally {
session.close();
}
......@@ -335,6 +325,20 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
private void closePreparedCommands() {
commit = closeAndSetNull(commit);
rollback = closeAndSetNull(rollback);
setAutoCommitTrue = closeAndSetNull(setAutoCommitTrue);
setAutoCommitFalse = closeAndSetNull(setAutoCommitFalse);
getAutoCommit = closeAndSetNull(getAutoCommit);
getReadOnly = closeAndSetNull(getReadOnly);
getGeneratedKeys = closeAndSetNull(getGeneratedKeys);
getLockMode = closeAndSetNull(getLockMode);
setLockMode = closeAndSetNull(setLockMode);
getQueryTimeout = closeAndSetNull(getQueryTimeout);
setQueryTimeout = closeAndSetNull(setQueryTimeout);
}
private CommandInterface closeAndSetNull(CommandInterface command) {
if (command != null) {
command.close();
......@@ -1346,6 +1350,7 @@ public class JdbcConnection extends TraceObject implements Connection {
}
if (session.isReconnectNeeded(write)) {
trace.debug("reconnect");
closePreparedCommands();
session = session.reconnect(write);
setTrace(session.getTrace());
}
......
......@@ -355,7 +355,13 @@ public class TestFileLockSerialized extends TestBase {
}
}
nextInt[0]++;
c.createStatement().execute("insert into test (id2) values(" + nextInt[0] + ")");
Statement stat = c.createStatement();
stat.execute("insert into test (id2) values(" + nextInt[0] + ")");
ResultSet rsKeys = stat.getGeneratedKeys();
while (rsKeys.next()) {
assertEquals(nextInt[0], rsKeys.getInt(1));
}
rsKeys.close();
}
Thread.sleep(waitTime);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论