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

Documentation.

上级 fc60923d
......@@ -18,7 +18,10 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>The BNF parser now uses the visitor pattern.
<ul><li>When doing an index lookup, decimal values with the same value but different scale
(for example 0.00 and 0.0) where not considered equal in version 1.2.128.
Now they are (unlike BigDecimal.equals()).
</li><li>The BNF parser now uses the visitor pattern.
</li><li>The methods of the CloseListener are added to the Trigger interface.
The interface CloseListener is removed.
</li><li>Converting a UUID to bytes was incorrect. Because of that, updatable result sets on
......@@ -28,8 +31,7 @@ Change Log
</li><li>H2 Console: asynchronous login (using a DatabaseEventListener) is no longer supported.
</li><li>A workaround for a Windows socket problem has been implemented. Thanks a lot to Sergi Vladykin.
</li><li>The Recover tool did not convert correctly convert CLOB data with non-ASCII characters.
</li><li>Tools: the method run(String... args) has been renamed to runTool(String... args)
so it can't be confused with run().
</li><li>Tools: the method run(String... args) has been renamed to runTool(String... args).
</li><li>Server.startWebServer(Connection) was not working as expected.
</li><li>The database URL option ACCESS_MODE_LOG is no longer supported.
</li><li>The database URL option RECOVER has currently no effect.
......
......@@ -57,7 +57,7 @@ Here is the list of known and confirmed issues:
<ul><li>Tomcat and Glassfish 3 set most static fields (final or non-final) to <code>null</code> when
unloading a web application. This can cause a <code>NullPointerException</code> in H2 versions
1.1.107 and older, and may still not work in newer versions. Please report it if you
run into this issue. In Tomcat >= 6.0 this behavior can be disabled by setting the
run into this issue. In Tomcat &gt;= 6.0 this behavior can be disabled by setting the
system property <code>org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false</code>,
however Tomcat may then run out of memory. A known workaround is to
put the <code>h2*.jar</code> file in a shared <code>lib</code> directory
......@@ -208,15 +208,10 @@ or set the system property <a href="../javadoc/org/h2/constant/SysProperties.htm
<h3 id="slow_open">Why is Opening my Database Slow?</h3>
<p>
If it takes a long time to open a database, in most cases it was not closed the last time.
This is specially a problem for larger databases.
To close a database, close all connections to it before the application ends, or execute
the command <code>SHUTDOWN</code>.
The database is also closed when the virtual machine exits normally
by using a shutdown hook. However killing a Java process or calling <code>Runtime.halt</code> will prevent this.
The reason why opening is slow in this situations is that indexes are re-created.
If you can not guarantee the database is closed, consider using
<a href="grammar.html#set_log" class="notranslate">SET LOG 2</a>.
To find out what the problem is, use the H2 Console and click on "Test Connection"
instead of "Login". After the "Login Successful" appears, click on it (it's a link).
This will list the top stack traces. Then either analyze this yourself, or
post those stack traces in the Google Group.
</p>
<p>
To find out what the problem is, open the database in embedded mode using the H2 Console.
......
......@@ -478,7 +478,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>TCP Server: use a nonce (number used once) to protect unencrypted channels against replay attacks.
</li><li>Simplify running scripts and recovery: CREATE FORCE USER (overwrites an existing user).
</li><li>Support CREATE DATABASE LINK (a custom JDBC driver is already supported).
</li><li>Isse 163: Allow to create foreign keys on metadata types.
</li><li>Issue 163: Allow to create foreign keys on metadata types.
</li><li>Logback: write a native DBAppender.
</li></ul>
......
......@@ -74,7 +74,6 @@ org.h2.tools<br />
<b>Interfaces</b><br />
org.h2.api<br />
<a href="org/h2/api/AggregateFunction.html" target="javadoc">AggregateFunction</a><br />
<a href="org/h2/api/CloseListener.html" target="javadoc">CloseListener</a><br />
<a href="org/h2/api/DatabaseEventListener.html" target="javadoc">DatabaseEventListener</a><br />
<a href="org/h2/api/Trigger.html" target="javadoc">Trigger</a><br />
<br />
......
......@@ -120,6 +120,12 @@ public class Bnf {
addFixedRule("@close_bracket@", RuleFixed.CLOSE_BRACKET);
}
/**
* Parse the syntax and let the rule call the visitor.
*
* @param visitor the visitor
* @param s the syntax to parse
*/
public void visit(BnfVisitor visitor, String s) {
this.syntax = s;
tokens = tokenize();
......@@ -150,7 +156,7 @@ public class Bnf {
/**
* Get the rule head for the given title.
*
* @param title
* @param title the title
* @return the rule head, or null
*/
public RuleHead getRuleHead(String title) {
......
......@@ -78,7 +78,7 @@ public class SysProperties {
* alias (I in this case) in ResultSetMetaData.getColumnName() and 'null' in
* getTableName(). If disabled, the real column name (ID in this case) and
* table name is returned. This setting only affects the default mode.
* <p>
* <br />
* When using different modes, this feature is disabled for compatibility
* for all databases except MySQL. For MySQL, it is always enabled.
*/
......
......@@ -61,14 +61,42 @@ import org.h2.util.Tool;
*/
public class WebApp {
/**
* The web server.
*/
protected WebServer server;
/**
* The session.
*/
protected WebSession session;
/**
* The session attributes
*/
protected Properties attributes;
/**
* The mime type of the current response.
*/
protected String mimeType;
/**
* Whether the response can be cached.
*/
protected boolean cache;
/**
* Whether to close the connection.
*/
protected boolean stop;
/**
* The language in the HTTP header.
*/
protected String headerLanguage;
protected Profiler profiler;
private Profiler profiler;
WebApp(WebServer server) {
this.server = server;
......
......@@ -95,8 +95,9 @@ public class DataReader {
* @return the value
*/
// public int readInt() throws IOException {
// return (read() << 24) + ((read() & 0xff) << 16) + ((read() & 0xff) << 8) + (read() & 0xff);
// }
// return (read() << 24) + ((read() & 0xff) << 16) +
// ((read() & 0xff) << 8) + (read() & 0xff);
//}
/**
* Read a long.
......
......@@ -105,6 +105,13 @@ public class PageOutputStream {
data.initWrite();
}
/**
* Write the data.
*
* @param b the buffer
* @param off the offset
* @param len the length
*/
public void write(byte[] b, int off, int len) throws IOException {
if (len <= 0) {
return;
......@@ -145,6 +152,9 @@ public class PageOutputStream {
}
}
/**
* Write all data.
*/
public void flush() throws IOException {
if (needFlush) {
storePage();
......@@ -152,6 +162,9 @@ public class PageOutputStream {
}
}
/**
* Close the stream.
*/
public void close() {
store = null;
}
......
......@@ -8,7 +8,6 @@ package org.h2.util;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import org.h2.engine.Constants;
......@@ -147,15 +146,6 @@ public class Profiler implements Runnable {
}
}
public static void main(String... args) {
Profiler p = new Profiler();
p.startCollecting();
org.h2.Driver.load();
Locale.getAvailableLocales();
p.stopCollecting();
System.out.println(p.getTop(10));
}
/**
* Get the top stack traces.
*
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(id decimal(10, 2) primary key) as select 0;
> ok
select * from test where id = 0.00;
> ID
> ----
> 0.00
> rows: 1
select * from test where id = 0.0;
> ID
> ----
> 0.00
> rows: 1
drop table test;
> ok
select count(*) from (select 1 union (select 2 intersect select 2)) x;
> COUNT(*)
> --------
......
......@@ -17,6 +17,7 @@ import org.h2.store.FileStore;
import org.h2.test.TestBase;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.CompareMode;
import org.h2.value.Value;
import org.h2.value.ValueArray;
import org.h2.value.ValueBoolean;
......@@ -44,6 +45,7 @@ import org.h2.value.ValueUuid;
public class TestDataPage extends TestBase implements DataHandler {
private boolean testPerformance;
private CompareMode compareMode = CompareMode.getInstance(null, 0);
/**
* Run just this test.
......@@ -203,7 +205,7 @@ public class TestDataPage extends TestBase implements DataHandler {
data.reset();
Value v2 = data.readValue();
assertEquals(v.getType(), v2.getType());
assertTrue(v.compareEqual(v2));
assertEquals(0, v.compareTo(v2, compareMode));
assertEquals(123, data.readInt());
}
......
......@@ -22,6 +22,7 @@ import org.h2.util.NetUtils;
*/
public class TestNetUtils extends TestBase {
private static final int WORKER_COUNT = 10;
private static final int PORT = 9111;
/**
......@@ -34,10 +35,8 @@ public class TestNetUtils extends TestBase {
}
public void test() throws Exception {
testFrequentConnections(false, 1000);
testFrequentConnections(true, 100);
testFrequentConnections(false, 1000);
testFrequentConnections(true, 100);
testFrequentConnections(false, 2000);
}
private void testFrequentConnections(boolean ssl, int count) throws Exception {
......@@ -61,7 +60,7 @@ public class TestNetUtils extends TestBase {
serverThread.start();
try {
Set<ConnectWorker> workers = new HashSet<ConnectWorker>();
for (int i = 0; i < 1; i++) {
for (int i = 0; i < WORKER_COUNT; i++) {
workers.add(new ConnectWorker(ssl, counter));
}
// ensure the server is started
......
......@@ -84,7 +84,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
case 2:
Value v1 = map.get(key);
Value v2 = hash.get(key);
assertTrue(v1 == null ? v2 == null : v1.compareEqual(v2));
assertTrue(v1 == null ? v2 == null : v1.equals(v2));
break;
case 3: {
ArrayList<Value> a1 = map.keys();
......@@ -93,7 +93,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
Collections.sort(a1, vc);
Collections.sort(a2, vc);
for (int j = 0; j < a1.size(); j++) {
assertTrue(a1.get(j).compareEqual(a2.get(j)));
assertTrue(a1.get(j).equals(a2.get(j)));
}
break;
}
......@@ -104,7 +104,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
Collections.sort(a1, vc);
Collections.sort(a2, vc);
for (int j = 0; j < a1.size(); j++) {
assertTrue(a1.get(j).compareEqual(a2.get(j)));
assertTrue(a1.get(j).equals(a2.get(j)));
}
break;
default:
......
......@@ -60,11 +60,19 @@ public class TestValueMemory extends TestBase implements DataHandler {
}
public void test() throws SQLException {
testCompare();
for (int i = 0; i < Value.TYPE_COUNT; i++) {
testType(i);
}
}
private void testCompare() {
ValueDecimal a = ValueDecimal.get(new BigDecimal("0.0"));
ValueDecimal b = ValueDecimal.get(new BigDecimal("-0.00"));
assertTrue(a.hashCode() != b.hashCode());
assertFalse(a.equals(b));
}
private void testType(int type) throws SQLException {
System.gc();
System.gc();
......
......@@ -84,6 +84,12 @@ public class BnfRailroad implements BnfVisitor {
html = getHtmlText(type);
}
/**
* Get the HTML text for the given fixed rule.
*
* @param type the fixed rule type
* @return the HTML text
*/
static String getHtmlText(int type) {
switch(type) {
case RuleFixed.YMD:
......
......@@ -22,6 +22,13 @@ public class BnfSyntax implements BnfVisitor {
private String html;
/**
* Get the HTML syntax for the given syntax.
*
* @param bnf the BNF
* @param syntaxLines the syntax
* @return the HTML
*/
public String getHtml(Bnf bnf, String syntaxLines) {
syntaxLines = StringUtils.replaceAll(syntaxLines, "\n ", "\n");
StringTokenizer tokenizer = bnf.getTokenizer(syntaxLines);
......@@ -40,6 +47,13 @@ public class BnfSyntax implements BnfVisitor {
return s;
}
/**
* Get the HTML link to the given token.
*
* @param bnf the BNF
* @param token the token
* @return the HTML link
*/
String getLink(Bnf bnf, String token) {
RuleHead found = null;
String key = Bnf.getRuleMapKey(token);
......
......@@ -633,4 +633,5 @@ slowly prefs precedence mat verbose nonce complicate speedup replay
profiles superinterfaces conventions brace indentations increments
explicitconstructorcall switchstatements members parens alignment declarations
jdt continuation codegen parenthesized tabulation ellipsis imple inits guardian
postfix
postfix iconified deiconified deactivated activated worker frequent utilities
workers appender recovers
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论