提交 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
<h1>Change Log</h1>
<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>
<h2>Version 1.4.177 Beta (2014-04-12)</h2>
......
......@@ -92,6 +92,11 @@ public class Constants {
*/
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.
*/
......
......@@ -104,7 +104,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
trans.setSSL(ci.isSSL());
trans.init();
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(ci.getOriginalURL());
trans.writeString(ci.getUserName());
......@@ -127,12 +127,16 @@ public class SessionRemote extends SessionWithState implements DataHandler {
trans.writeInt(SessionRemote.SESSION_SET_ID);
trans.writeString(sessionId);
done(trans);
if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_15) {
autoCommit = trans.readBoolean();
} else {
autoCommit = true;
}
return trans;
} catch (DbException e) {
trans.close();
throw e;
}
autoCommit = true;
return trans;
}
@Override
......
......@@ -87,13 +87,13 @@ public class TcpServerThread implements Runnable {
if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + 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,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_14);
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_15);
}
int maxClientVersion = transfer.readInt();
if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_14) {
clientVersion = Constants.TCP_PROTOCOL_VERSION_14;
if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_15) {
clientVersion = Constants.TCP_PROTOCOL_VERSION_15;
} else {
clientVersion = minClientVersion;
}
......@@ -401,7 +401,9 @@ public class TcpServerThread implements Runnable {
}
case SessionRemote.SESSION_SET_ID: {
sessionId = transfer.readString();
transfer.writeInt(SessionRemote.STATUS_OK).flush();
transfer.writeInt(SessionRemote.STATUS_OK);
transfer.writeBoolean(session.getAutoCommit());
transfer.flush();
break;
}
case SessionRemote.SESSION_SET_AUTOCOMMIT: {
......
......@@ -242,7 +242,7 @@ public class FileLock implements Runnable {
transfer.setSocket(socket);
transfer.init();
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(id);
......
......@@ -41,6 +41,7 @@ public class TestCases extends TestBase {
@Override
public void test() throws Exception {
testAutoCommitInDatabaseURL();
testReferenceableIndexUsage();
testClearSyntaxException();
testEmptyStatements();
......@@ -106,6 +107,16 @@ public class TestCases extends TestBase {
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 {
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论