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

--no commit message

--no commit message
上级 825fd604
......@@ -768,7 +768,7 @@ The two methods are 'file method' and 'socket methods'.
</p>
<p>
The file locking protocols have the following limitation: if a shared file system is used,
and the machine with the lock owner is sent to sleep (standby or hibernate),
and the machine with the lock owner is sent to sleep (standby or hibernate),
another machine may take over. If the machine that originally held the lock
wakes up, the database may become corrupt. If this situation can occur,
the application must ensure the database is closed when the application
......
......@@ -18,15 +18,17 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><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.
<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.
This could cause problems in recovery when the process was killed.
</li><li>Trigger that are called before a select statement are now supported.
This allows to create tables that work like materialized views.
</li><li>Non-row based triggers were called even if the action didn't match the
declared action (INSERT triggers were also called when deleting rows).
</li><li>Non-row based triggers were called even if the action didn't match the
declared action (INSERT triggers were also called when deleting rows).
This has been changed. The MERGE statement calls both INSERT and DELETE triggers.
</li><li>Statements with IN(..) conditions could produce the wrong result or a data conversion error (since version 1.2.120).
Examples: index on id, name, condition: id=1 and name in('Hello', 'x'); index on id, query:
......@@ -34,14 +36,14 @@ Change Log
</li><li>The CompressTool was not multithreading safe. Because of this, the following database
operations where also not multithreading safe (even when using different databases): the SCRIPT command
(only when using compression), the COMPRESS function, and storing CLOB or BLOB data (only when compression is enabled).
</li><li>The compression algorithm "LZF" is now about 33% faster than before when compressing small block
</li><li>The compression algorithm "LZF" is now about 33% faster than before when compressing small block
(around 2 KB). It is much faster than Deflate, but the compression ratio is lower.
</li><li>Compressing large blocks of data didn't work when using the "Deflate" compression algorithm.
Compressing a lot of data could run out of heap memory.
</li><li>The test cases don't access the file system directly, this simplifies GAE for Java testing.
Thanks to Vince Bonfanti.
</li><li>More bugs in the server-less multi-connection mode have been fixed.
</li><li>When running against an old database, the SCRIPT statement could generate a
</li><li>When running against an old database, the SCRIPT statement could generate a
SQL script that contained duplicate indexes (PRIMARY_KEY_E).
</li><li>JdbcConnectionPool.getConnection() could throw a NullPointerException.
</li><li>User defined functions: the source code is now available using
......
......@@ -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 />
......
......@@ -68,19 +68,19 @@ The main reasons to use a Java database are:
</li></ul>
<p>
Some think Java is too slow for low level operations,
but this is no longer true. Garbage collection for example is
now faster than manual memory management.
but this is no longer true. Garbage collection for example is
now faster than manual memory management.
</p><p>
Developing Java code is faster than C or C++ code. When using Java,
most time can be spent on improving the algorithms instead of
porting the code to different platforms or doing memory management.
Developing Java code is faster than C or C++ code. When using Java,
most time can be spent on improving the algorithms instead of
porting the code to different platforms or doing memory management.
Features such as Unicode and network libraries are already built-in.
In Java, writing secure code is easier because buffer overflows can not occur.
Features such as reflection can be used for randomized testing.
</p><p>
Java is future proof: a lot of companies support Java. Java is now open source.
</p><p>
To increase the portability and ease of use, this software depends on
To increase the portability and ease of use, this software depends on
very few libraries. Features that are not available in open source
Java implementations (such as Swing) are not used, or only used for optional features.
</p>
......
......@@ -234,8 +234,8 @@ Java job scheduler, file transfer, workflow, and BPM.
<p><a href="http://code.google.com/p/gbif-providertoolkit">
GBIF Integrated Publishing Toolkit (IPT)</a><br />
The GBIF IPT is an open source, Java based web application that connects and serves
three types of biodiversity data: taxon primary occurrence data,
The GBIF IPT is an open source, Java based web application that connects and serves
three types of biodiversity data: taxon primary occurrence data,
taxon checklists and general resource metadata.
</p>
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论