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

--no commit message

--no commit message
上级 825fd604
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Trying to alter a temporary table threw a strange exception.
<ul><li>Right outer joins on tables that were already 'inner joined' was processed incorrectly.
</li><li>Temporary files from LOB objects were not deleted early enough when using the server mode.
</li><li>Trying to alter a temporary table threw a strange exception.
It is still not possible to do that, but the exception message is better now.
</li><li>When the system property h2.maxMemoryRowsDistinct was set, and
using SELECT DISTINCT, the temporary table was not correctly dropped.
......
......@@ -78,6 +78,7 @@ translate -->
<a href="sourceError.html">Error Analyzer</a><br />
<a href="http://groups.google.com/group/h2-database">Google Group (English)</a><br />
<a href="http://groups.google.co.jp/group/h2-database-jp">Google Group (Japanese)</a><br />
<a href="http://groups.google.com/group/h2-cn">Google Group (Chinese)</a><br />
<br />
<b>Appendix</b><br />
<a href="jaqu.html">JaQu</a><br />
......
......@@ -40,6 +40,8 @@ Tutorial
Upgrade, Backup, and Restore</a><br />
<a href="#command_line_tools">
Command Line Tools</a><br />
<a href="shell_tool">
The Shell Tool</a><br />
<a href="#open_office">
Using OpenOffice Base</a><br />
<a href="#web_start">
......@@ -376,7 +378,7 @@ To enable it, change the following setting in persistence.xml:
<pre>
&lt;property
name="toplink.target-database"
value="oracle.toplink.essentials.platform.database.H2Platform"/>
value="oracle.toplink.essentials.platform.database.H2Platform"/&gt;
</pre>
<p>
In old versions of Glassfish, the property name is <code>toplink.platform.class.name</code>.
......@@ -428,9 +430,9 @@ add the following snippet to your web.xml file (between the
<code>context-param</code> and the <code>filter</code> section):
</p>
<pre>
&lt;listener>
&lt;listener-class>org.h2.server.web.DbStarter&lt;/listener-class>
&lt;/listener>
&lt;listener&gt;
&lt;listener-class&gt;org.h2.server.web.DbStarter&lt;/listener-class&gt;
&lt;/listener&gt;
</pre>
<p>
For details on how to access the database, see the file <code>DbStarter.java</code>.
......@@ -450,22 +452,22 @@ These options need to be placed between the <code>description</code> tag
and the <code>listener</code> / <code>filter</code> tags:
</p>
<pre>
&lt;context-param>
&lt;param-name>db.url&lt;/param-name>
&lt;param-value>jdbc:h2:~/test&lt;/param-value>
&lt;/context-param>
&lt;context-param>
&lt;param-name>db.user&lt;/param-name>
&lt;param-value>sa&lt;/param-value>
&lt;/context-param>
&lt;context-param>
&lt;param-name>db.password&lt;/param-name>
&lt;param-value>sa&lt;/param-value>
&lt;/context-param>
&lt;context-param>
&lt;param-name>db.tcpServer&lt;/param-name>
&lt;param-value>-tcpAllowOthers&lt;/param-value>
&lt;/context-param>
&lt;context-param&gt;
&lt;param-name&gt;db.url&lt;/param-name&gt;
&lt;param-value&gt;jdbc:h2:~/test&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;context-param&gt;
&lt;param-name&gt;db.user&lt;/param-name&gt;
&lt;param-value&gt;sa&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;context-param&gt;
&lt;param-name&gt;db.password&lt;/param-name&gt;
&lt;param-value&gt;sa&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;context-param&gt;
&lt;param-name&gt;db.tcpServer&lt;/param-name&gt;
&lt;param-value&gt;-tcpAllowOthers&lt;/param-value&gt;
&lt;/context-param&gt;
</pre>
<p>
When the web application is stopped, the database connection will be closed automatically.
......@@ -675,6 +677,40 @@ The tools can also be called from an application by calling the main or another
For details, see the Javadoc documentation.
</p>
<h2 id="shell_tool">The Shell Tool</h2>
<p>
The Shell tool is a simple interactive command line tool. To start it, type:
</p>
<pre>
java -cp h2*.jar org.h2.tools.Shell
</pre>
<p>
You will be prompted for a database URL, JDBC driver, user name, and password.
The connection setting can also be set as command line parameters.
After connecting, you will get the list of options.
The built-in commands don't need to end with a semicolon, but
SQL statements are only executed if the line ends with a semicolon <code>;</code>.
This allows to enter multi-line statements:
</p>
<pre>
sql&gt; select * from test
...&gt; where id = 0;
</pre>
<p>
By default, results are printed as a table. For results with many column, consinder using the list mode:
</p>
<pre>
sql&gt; list
Result list mode is now on
sql&gt; select * from test;
ID : 1
NAME: Hello
ID : 2
NAME: World
(2 rows, 0 ms)
</pre>
<h2 id="open_office">Using OpenOffice Base</h2>
<p>
OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database
......@@ -731,9 +767,9 @@ access denied (<code>java.io.FilePermission ... read</code>).
Example permission tags:
</p>
<pre>
&lt;security>
&lt;all-permissions/>
&lt;/security>
&lt;security&gt;
&lt;all-permissions/&gt;
&lt;/security&gt;
</pre>
<h2 id="connection_pool">Using a Connection Pool</h2>
......
......@@ -1351,6 +1351,10 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
/**
* INTERNAL.
* Called after executing a command that could have written something.
*/
protected void afterWriting() {
session.afterWriting();
}
......
......@@ -39,6 +39,11 @@ public abstract class TestBase {
*/
protected static String baseDir = getTestDir("");
/**
* The temporary directory.
*/
protected static final String TEMP_DIR = "data/temp";
/**
* An id used to create unique file names.
*/
......@@ -97,6 +102,7 @@ public abstract class TestBase {
*/
public TestBase init(TestAll conf) throws Exception {
baseDir = getTestDir("");
System.setProperty("java.io.tmpdir", TEMP_DIR);
this.config = conf;
return this;
}
......
......@@ -65,7 +65,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
ResultSet rs;
stat.execute("create force alias sayHi as 'String test(String name) {\nreturn \"Hello \" + name;\n}'");
stat.execute("create force alias sayHi as 'String test(String name) {\n" +
"return \"Hello \" + name;\n}'");
rs = stat.executeQuery("call sayHi('Joe')");
rs.next();
assertEquals("Hello Joe", rs.getString(1));
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.io.ByteArrayInputStream;
import java.io.CharArrayReader;
import java.io.File;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
......@@ -24,6 +25,7 @@ import java.util.ArrayList;
import java.util.Random;
import org.h2.constant.SysProperties;
import org.h2.store.FileLister;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles;
import org.h2.util.FileUtils;
......@@ -47,6 +49,7 @@ public class TestLob extends TestBase {
}
public void test() throws Exception {
testTempFilesDeleted();
testAddLobRestart();
testLobServerMemory();
if (config.memory) {
......@@ -77,6 +80,32 @@ public class TestLob extends TestBase {
deleteDb("lob");
}
private void testTempFilesDeleted() throws Exception {
String[] list;
FileSystem.getInstance(TEMP_DIR).deleteRecursive(TEMP_DIR, false);
FileUtils.mkdirs(new File(TEMP_DIR));
list = FileUtils.listFiles(TEMP_DIR);
if (list.length > 0) {
fail("Unexpected temp file: " + list[0]);
}
deleteDb("lob");
Connection conn = getConnection("lob");
Statement stat;
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name text)");
stat.execute("insert into test values(1, space(100000))");
ResultSet rs;
rs = stat.executeQuery("select * from test");
rs.next();
rs.getCharacterStream("name").close();
rs.close();
conn.close();
list = FileUtils.listFiles(TEMP_DIR);
if (list.length > 0) {
fail("Unexpected temp file: " + list[0]);
}
}
private void testAddLobRestart() throws SQLException {
DeleteDbFiles.execute("memFS:", "lob", true);
Connection conn = org.h2.Driver.load().connect("jdbc:h2:memFS:lob", null);
......
......@@ -51,7 +51,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat = conn.createStatement();
stat.execute("drop table if exists meta_tables");
stat.execute("create table meta_tables(name varchar)");
stat.execute("create trigger meta_tables_sel before select on meta_tables call \"" + TestSelect.class.getName() + "\"");
stat.execute("create trigger meta_tables_select before select on meta_tables call \"" + TestSelect.class.getName() + "\"");
ResultSet rs;
rs = stat.executeQuery("select * from meta_tables");
assertTrue(rs.next());
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table a(a int) as select 1;
> ok
create table b(b int) as select 1;
> ok
create table c(c int) as select x from system_range(1, 2);
> ok
select * from a inner join b on a=b right outer join c on c=a;
> C A B
> - ---- ----
> 1 1 1
> 2 null null
> rows: 2
select * from c left outer join (a inner join b on b=a) on c=a;
> C A B
> - ---- ----
> 1 1 1
> 2 null null
> rows: 2
select * from c left outer join a on c=a inner join b on b=a;
> C A B
> - - -
> 1 1 1
> rows: 1
drop table a, b, c;
> ok
create table test(a int, b int) as select x, x from system_range(1, 100);
> ok
......
......@@ -623,3 +623,4 @@ autovacuum vacuuming endlessly talking evicted splitting unbound declaring
selector descendant isdescendantnode issamenode ischildnode localname
weakreference ancestor junctions wake fills rail sleeps turns grammars straight
answers attachments emails clipboard prioritize tips urgently standby
checklists serves gbif biodiversity wakes taxon ratio ended ipt
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论