提交 be2d01c8 authored 作者: Thomas Mueller's avatar Thomas Mueller

In server mode, appending ";autocommit=false" to the database URL was working,…

In server mode, appending ";autocommit=false" to the database URL was working, but the return value of Connection.getAutoCommit() was wrong.
上级 074adb0d
...@@ -18,7 +18,11 @@ Change Log ...@@ -18,7 +18,11 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>- <ul><li>In server mode, appending ";autocommit=false" to the database URL was working,
but the return value of Connection.getAutoCommit() was wrong.
</li><li>OSGi: the import package declaration of org.h2 excluded version 1.4.
</li><li>Issue 558: with the MVStore, a NullPointerException could occur when using LOBs
at session commit (LobStorageMap.removeLob).
</li></ul> </li></ul>
<h2>Version 1.4.177 Beta (2014-04-12)</h2> <h2>Version 1.4.177 Beta (2014-04-12)</h2>
......
...@@ -92,6 +92,11 @@ public class Constants { ...@@ -92,6 +92,11 @@ public class Constants {
*/ */
public static final int TCP_PROTOCOL_VERSION_14 = 14; public static final int TCP_PROTOCOL_VERSION_14 = 14;
/**
* The TCP protocol version number 15.
*/
public static final int TCP_PROTOCOL_VERSION_15 = 15;
/** /**
* The major version of this database. * The major version of this database.
*/ */
......
...@@ -104,7 +104,7 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -104,7 +104,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
trans.setSSL(ci.isSSL()); trans.setSSL(ci.isSSL());
trans.init(); trans.init();
trans.writeInt(Constants.TCP_PROTOCOL_VERSION_6); trans.writeInt(Constants.TCP_PROTOCOL_VERSION_6);
trans.writeInt(Constants.TCP_PROTOCOL_VERSION_14); trans.writeInt(Constants.TCP_PROTOCOL_VERSION_15);
trans.writeString(db); trans.writeString(db);
trans.writeString(ci.getOriginalURL()); trans.writeString(ci.getOriginalURL());
trans.writeString(ci.getUserName()); trans.writeString(ci.getUserName());
...@@ -127,12 +127,16 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -127,12 +127,16 @@ public class SessionRemote extends SessionWithState implements DataHandler {
trans.writeInt(SessionRemote.SESSION_SET_ID); trans.writeInt(SessionRemote.SESSION_SET_ID);
trans.writeString(sessionId); trans.writeString(sessionId);
done(trans); done(trans);
if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_15) {
autoCommit = trans.readBoolean();
} else {
autoCommit = true;
}
return trans;
} catch (DbException e) { } catch (DbException e) {
trans.close(); trans.close();
throw e; throw e;
} }
autoCommit = true;
return trans;
} }
@Override @Override
......
...@@ -87,13 +87,13 @@ public class TcpServerThread implements Runnable { ...@@ -87,13 +87,13 @@ public class TcpServerThread implements Runnable {
if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) { if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6); "" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6);
} else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_14) { } else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_15) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_14); "" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_15);
} }
int maxClientVersion = transfer.readInt(); int maxClientVersion = transfer.readInt();
if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_14) { if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_15) {
clientVersion = Constants.TCP_PROTOCOL_VERSION_14; clientVersion = Constants.TCP_PROTOCOL_VERSION_15;
} else { } else {
clientVersion = minClientVersion; clientVersion = minClientVersion;
} }
...@@ -401,7 +401,9 @@ public class TcpServerThread implements Runnable { ...@@ -401,7 +401,9 @@ public class TcpServerThread implements Runnable {
} }
case SessionRemote.SESSION_SET_ID: { case SessionRemote.SESSION_SET_ID: {
sessionId = transfer.readString(); sessionId = transfer.readString();
transfer.writeInt(SessionRemote.STATUS_OK).flush(); transfer.writeInt(SessionRemote.STATUS_OK);
transfer.writeBoolean(session.getAutoCommit());
transfer.flush();
break; break;
} }
case SessionRemote.SESSION_SET_AUTOCOMMIT: { case SessionRemote.SESSION_SET_AUTOCOMMIT: {
......
...@@ -242,7 +242,7 @@ public class FileLock implements Runnable { ...@@ -242,7 +242,7 @@ public class FileLock implements Runnable {
transfer.setSocket(socket); transfer.setSocket(socket);
transfer.init(); transfer.init();
transfer.writeInt(Constants.TCP_PROTOCOL_VERSION_6); transfer.writeInt(Constants.TCP_PROTOCOL_VERSION_6);
transfer.writeInt(Constants.TCP_PROTOCOL_VERSION_14); transfer.writeInt(Constants.TCP_PROTOCOL_VERSION_15);
transfer.writeString(null); transfer.writeString(null);
transfer.writeString(null); transfer.writeString(null);
transfer.writeString(id); transfer.writeString(id);
......
...@@ -41,6 +41,7 @@ public class TestCases extends TestBase { ...@@ -41,6 +41,7 @@ public class TestCases extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
testAutoCommitInDatabaseURL();
testReferenceableIndexUsage(); testReferenceableIndexUsage();
testClearSyntaxException(); testClearSyntaxException();
testEmptyStatements(); testEmptyStatements();
...@@ -105,6 +106,16 @@ public class TestCases extends TestBase { ...@@ -105,6 +106,16 @@ public class TestCases extends TestBase {
testBinaryCollation(); testBinaryCollation();
deleteDb("cases"); deleteDb("cases");
} }
private void testAutoCommitInDatabaseURL() throws SQLException {
Connection conn = getConnection("cases;autocommit=false");
assertFalse(conn.getAutoCommit());
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("call autocommit()");
rs.next();
assertFalse(rs.getBoolean(1));
conn.close();
}
private void testReferenceableIndexUsage() throws SQLException { private void testReferenceableIndexUsage() throws SQLException {
Connection conn = getConnection("cases"); Connection conn = getConnection("cases");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论