提交 56f4e91a authored 作者: Thomas Mueller's avatar Thomas Mueller

The auto-server mode can't be combined with an in-memory database. This invalid…

The auto-server mode can't be combined with an in-memory database. This invalid combination wasn't detected so far. Now trying to open a database in this way fails.
上级 0c51adf3
...@@ -18,7 +18,10 @@ Change Log ...@@ -18,7 +18,10 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>Improved performance for reading and writing date and time values. <ul><li>The auto-server mode can't be combined with an in-memory database.
This invalid combination wasn't detected so far.
Now trying to open a database in this way fails.
</li><li>Improved performance for reading and writing date and time values.
</li><li>Java functions: array component types are now preserved, so that a ResultSet.getObject() </li><li>Java functions: array component types are now preserved, so that a ResultSet.getObject()
will return Integer[] if the Java functions returns Integer[]. Thanks to Noel Grandin for the patch. will return Integer[] if the Java functions returns Integer[]. Thanks to Noel Grandin for the patch.
Component types are transferred over the network, but not persisted in the database file as of now. Component types are transferred over the network, but not persisted in the database file as of now.
......
...@@ -518,9 +518,9 @@ public class Database implements DataHandler { ...@@ -518,9 +518,9 @@ public class Database implements DataHandler {
trace = traceSystem.getTrace(Trace.DATABASE); trace = traceSystem.getTrace(Trace.DATABASE);
trace.info("opening {0} (build {1})", databaseName, Constants.BUILD_ID); trace.info("opening {0} (build {1})", databaseName, Constants.BUILD_ID);
if (autoServerMode) { if (autoServerMode) {
if (readOnly || fileLockMethod == FileLock.LOCK_NO || fileLockMethod == FileLock.LOCK_SERIALIZED || fileLockMethod == FileLock.LOCK_FS) { if (readOnly || fileLockMethod == FileLock.LOCK_NO || fileLockMethod == FileLock.LOCK_SERIALIZED || fileLockMethod == FileLock.LOCK_FS || !persistent) {
throw DbException.getUnsupportedException("autoServerMode && (readOnly || fileLockMethod == NO" + throw DbException.getUnsupportedException("autoServerMode && (readOnly || fileLockMethod == NO" +
" || fileLockMethod == SERIALIZED)"); " || fileLockMethod == SERIALIZED || inMemory)");
} }
} }
String lockFileName = databaseName + Constants.SUFFIX_LOCK_FILE; String lockFileName = databaseName + Constants.SUFFIX_LOCK_FILE;
...@@ -548,6 +548,9 @@ public class Database implements DataHandler { ...@@ -548,6 +548,9 @@ public class Database implements DataHandler {
starting = false; starting = false;
writer = WriterThread.create(this, writeDelay); writer = WriterThread.create(this, writeDelay);
} else { } else {
if (autoServerMode) {
throw DbException.getUnsupportedException("autoServerMode && inMemory");
}
traceSystem = new TraceSystem(null); traceSystem = new TraceSystem(null);
trace = traceSystem.getTrace(Trace.DATABASE); trace = traceSystem.getTrace(Trace.DATABASE);
} }
......
...@@ -10,7 +10,6 @@ import java.sql.Connection; ...@@ -10,7 +10,6 @@ import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.SortedProperties; import org.h2.util.SortedProperties;
...@@ -34,10 +33,28 @@ public class TestAutoServer extends TestBase { ...@@ -34,10 +33,28 @@ public class TestAutoServer extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testUnsupportedCombinations();
testAutoServer(); testAutoServer();
testLinkedLocalTablesWithAutoServerReconnect(); testLinkedLocalTablesWithAutoServerReconnect();
} }
private void testUnsupportedCombinations() {
String[] urls = {
"jdbc:h2:test;file_lock=no;auto_server=true",
"jdbc:h2:test;file_lock=serialized;auto_server=true",
"jdbc:h2:test;access_mode_data=r;auto_server=true",
"jdbc:h2:mem:test;auto_server=true"
};
for (String url : urls) {
try {
DriverManager.getConnection(url);
fail(url);
} catch (SQLException e) {
assertKnownException(e);
}
}
}
/** /**
* Tests basic AUTO_SERVER functionality * Tests basic AUTO_SERVER functionality
* *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论