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

Temporary local tables did not always work after reconnect if AUTO_SERVER=TRUE

I wrote the code, it belongs to Docware GmbH, and Docware GmbH is contributing
it to H2 for distribution.
Multiple-licensed under the H2 License, version 1.0, and under the
Eclipse Public License, version 1.0 (http://h2database.com/html/license.html).
上级 8cd3fdce
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>New system property h2.defaultMaxLengthInplaceLob to change the default maximum size
<ul><li>Temporary local tables did not always work after reconnect if AUTO_SERVER=TRUE
</li><li>New system property h2.defaultMaxLengthInplaceLob to change the default maximum size
of an in-place LOB object.
</li><li>New system property h2.nullConcatIsNull to change the default null concatenation behavior.
The default will be enabled in version 1.2.
......
......@@ -299,8 +299,10 @@ public class TableLink extends Table {
if (isTemporary()) {
if (globalTemporary) {
buff.append("GLOBAL ");
} else {
buff.append("LOCAL ");
}
buff.append("TEMP ");
buff.append("TEMPORARY ");
}
buff.append("LINKED TABLE ").append(getSQL());
if (comment != null) {
......
......@@ -34,6 +34,16 @@ public class TestAutoServer extends TestBase {
}
public void test() throws Exception {
testAutoServer();
testLinkedLocalTablesWithAutoServerReconnect();
}
/**
* Tests basic AUTO_SERVER functionality
*
* @throws Exception
*/
public void testAutoServer() throws Exception {
if (config.memory || config.networked) {
return;
}
......@@ -74,6 +84,48 @@ public class TestAutoServer extends TestBase {
deleteDb("autoServer");
}
/**
* Tests recreation of temporary linked tables on reconnect
*
* @throws SQLException
*/
private void testLinkedLocalTablesWithAutoServerReconnect() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("autoServerLinkedTable1");
deleteDb("autoServerLinkedTable2");
String url = getURL("autoServerLinkedTable1;AUTO_SERVER=TRUE", true);
String urlLinked = getURL("autoServerLinkedTable2", true);
String user = getUser(), password = getPassword();
Connection connLinked = getConnection(urlLinked + ";OPEN_NEW=TRUE", "sa", "sa");
Statement statLinked = connLinked.createStatement();
statLinked.execute("CREATE TABLE TEST(ID VARCHAR)");
connLinked.close();
// Server is connection 1
Connection connAutoServer1 = getConnection(url + ";OPEN_NEW=TRUE", user, password);
Statement statAutoServer1 = connAutoServer1.createStatement();
statAutoServer1.execute("CREATE LOCAL TEMPORARY LINKED TABLE T('org.h2.Driver', '" + urlLinked + ";OPEN_NEW=TRUE', 'sa', 'sa', 'TEST')");
// Connection 2 connects
Connection connAutoServer2 = getConnection(url + ";OPEN_NEW=TRUE", user, password);
Statement statAutoServer2 = connAutoServer2.createStatement();
statAutoServer2.execute("CREATE LOCAL TEMPORARY LINKED TABLE T('org.h2.Driver', '" + urlLinked + ";OPEN_NEW=TRUE', 'sa', 'sa', 'TEST')");
// Server 1 closes the connection => connection 2 will be the server
// => the "force create local linked..." must be reissued
connAutoServer1.close();
// Now test insert
statAutoServer2.execute("INSERT INTO T (ID) VALUES('abc')");
connAutoServer2.close();
deleteDb("autoServerLinkedTable1");
deleteDb("autoServerLinkedTable2");
}
/**
* This method is called via reflection from the database.
*
......
......@@ -612,4 +612,4 @@ locals multianewarray icmpne fneg faload ifeq decompiler zeroes forgot
modern slight boost characteristics significantly gae vfs centrally ten
approach risky getters suxxess gmb delegate delegating delegates collisions
linkage superfluous disallow scoop moebius inputs copilot dmoebius leod jenkov
jakob poker docware peter unstable measurable scramble
\ No newline at end of file
jakob poker docware peter unstable measurable scramble reissued recreation
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论