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

Documentation / cleanup

上级 05519749
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -367,28 +367,33 @@ public class SysProperties { ...@@ -367,28 +367,33 @@ public class SysProperties {
Utils.getProperty("h2.useThreadContextClassLoader", false); Utils.getProperty("h2.useThreadContextClassLoader", false);
/** /**
* System property <code>h2.serializeJavaObject</code> * System property <code>h2.serializeJavaObject</code> (default: true).<br />
* (default: true).<br />
* <b>If true</b>, values of type OTHER will be stored in serialized form * <b>If true</b>, values of type OTHER will be stored in serialized form
* and have the semantics of binary data for all operations (such as sorting and conversion to string). * and have the semantics of binary data for all operations (such as sorting
* and conversion to string).
* <br /> * <br />
* <b>If false</b>, the objects will be serialized only for I/O operations and a few other special cases * <b>If false</b>, the objects will be serialized only for I/O operations
* (for example when someone tries to get the value in binary form or when comparing objects * and a few other special cases (for example when someone tries to get the
* that are not comparable otherwise). * value in binary form or when comparing objects that are not comparable
* otherwise).
* <br /> * <br />
* If the object implements the Comparable interface, the method compareTo * If the object implements the Comparable interface, the method compareTo
* will be used for sorting (but only if objects being compared have a common comparable * will be used for sorting (but only if objects being compared have a
* super type). Otherwise the objects will be compared by type, and if they are the same by hashCode, and * common comparable super type). Otherwise the objects will be compared by
* if the hash codes are equal, but objects are not, the serialized forms (the byte arrays) are compared. * type, and if they are the same by hashCode, and if the hash codes are
* equal, but objects are not, the serialized forms (the byte arrays) are
* compared.
* <br /> * <br />
* The string representation of the values use the toString method of object. * The string representation of the values use the toString method of
* object.
* <br /> * <br />
* In client-server mode, the server must have all required classes in the class path. * In client-server mode, the server must have all required classes in the
* On the client side, this setting is required to be disabled as well, to have correct string representation * class path. On the client side, this setting is required to be disabled
* and display size. * as well, to have correct string representation and display size.
* <br /> * <br />
* In embedded mode, no data copying occurs, so the user has to make defensive copy himself before storing, * In embedded mode, no data copying occurs, so the user has to make
* or ensure that the value object is immutable. * defensive copy himself before storing, or ensure that the value object is
* immutable.
*/ */
public static final boolean SERIALIZE_JAVA_OBJECT = Utils.getProperty("h2.serializeJavaObject", true); public static final boolean SERIALIZE_JAVA_OBJECT = Utils.getProperty("h2.serializeJavaObject", true);
......
...@@ -75,7 +75,7 @@ public class Constants { ...@@ -75,7 +75,7 @@ public class Constants {
* The TCP protocol version number 11. * The TCP protocol version number 11.
*/ */
public static final int TCP_PROTOCOL_VERSION_12 = 12; public static final int TCP_PROTOCOL_VERSION_12 = 12;
/** /**
* The major version of this database. * The major version of this database.
*/ */
......
...@@ -72,7 +72,11 @@ public class FullTextLucene extends FullText { ...@@ -72,7 +72,11 @@ public class FullTextLucene extends FullText {
private static final String LUCENE_FIELD_MODIFIED = "_modified"; private static final String LUCENE_FIELD_MODIFIED = "_modified";
private static final String LUCENE_FIELD_COLUMN_PREFIX = "_"; private static final String LUCENE_FIELD_COLUMN_PREFIX = "_";
private static final String IN_MEMORY_PERFIX = "mem:"; /**
* The prefix for a in-memory path. This prefix is only used internally
* within this class and not related to the database URL.
*/
private static final String IN_MEMORY_PREFIX = "mem:";
/** /**
* Initializes full text search functionality for this database. This adds * Initializes full text search functionality for this database. This adds
...@@ -265,7 +269,7 @@ public class FullTextLucene extends FullText { ...@@ -265,7 +269,7 @@ public class FullTextLucene extends FullText {
access.modifier = new IndexModifier(path, analyzer, recreate); access.modifier = new IndexModifier(path, analyzer, recreate);
//*/ //*/
//## LUCENE3 ## //## LUCENE3 ##
Directory indexDir = path.startsWith(IN_MEMORY_PERFIX) ? new RAMDirectory() : FSDirectory.open(new File(path)); Directory indexDir = path.startsWith(IN_MEMORY_PREFIX) ? new RAMDirectory() : FSDirectory.open(new File(path));
boolean recreate = !IndexReader.indexExists(indexDir); boolean recreate = !IndexReader.indexExists(indexDir);
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
IndexWriter writer = new IndexWriter(indexDir, analyzer, IndexWriter writer = new IndexWriter(indexDir, analyzer,
...@@ -299,10 +303,11 @@ public class FullTextLucene extends FullText { ...@@ -299,10 +303,11 @@ public class FullTextLucene extends FullText {
String path = rs.getString(1); String path = rs.getString(1);
if (path == null) { if (path == null) {
/*## LUCENE2 ## /*## LUCENE2 ##
throw throwException("Fulltext search for in-memory databases is not supported with Lucene 2. Please use Lucene 3 instead."); throw throwException("Fulltext search for in-memory databases " +
//*/ "is not supported with Lucene 2. Please use Lucene 3 instead.");
//*/
//## LUCENE3 ## //## LUCENE3 ##
return IN_MEMORY_PERFIX + conn.getCatalog(); return IN_MEMORY_PREFIX + conn.getCatalog();
//*/ //*/
} }
int index = path.lastIndexOf(':'); int index = path.lastIndexOf(':');
...@@ -343,7 +348,7 @@ public class FullTextLucene extends FullText { ...@@ -343,7 +348,7 @@ public class FullTextLucene extends FullText {
if (access != null) { if (access != null) {
removeIndexAccess(access, path); removeIndexAccess(access, path);
} }
if (!path.startsWith(IN_MEMORY_PERFIX)) { if (!path.startsWith(IN_MEMORY_PREFIX)) {
FileUtils.deleteRecursive(path, false); FileUtils.deleteRecursive(path, false);
} }
} }
......
...@@ -31,7 +31,6 @@ import org.h2.engine.Constants; ...@@ -31,7 +31,6 @@ import org.h2.engine.Constants;
import org.h2.engine.SessionInterface; import org.h2.engine.SessionInterface;
import org.h2.engine.SessionRemote; import org.h2.engine.SessionRemote;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.Trace;
import org.h2.message.TraceObject; import org.h2.message.TraceObject;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.util.CloseWatcher; import org.h2.util.CloseWatcher;
...@@ -81,7 +80,6 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -81,7 +80,6 @@ public class JdbcConnection extends TraceObject implements Connection {
private CommandInterface setQueryTimeout, getQueryTimeout; private CommandInterface setQueryTimeout, getQueryTimeout;
private int savepointId; private int savepointId;
private Trace trace;
private String catalog; private String catalog;
private Statement executingStatement; private Statement executingStatement;
private CompareMode compareMode = CompareMode.getInstance(null, 0); private CompareMode compareMode = CompareMode.getInstance(null, 0);
......
...@@ -103,6 +103,7 @@ public interface DataHandler { ...@@ -103,6 +103,7 @@ public interface DataHandler {
* Read from a lob. * Read from a lob.
* *
* @param lobId the lob * @param lobId the lob
* @param hmac the message authentication code
* @param offset the offset within the lob * @param offset the offset within the lob
* @param buff the target buffer * @param buff the target buffer
* @param off the offset within the target buffer * @param off the offset within the target buffer
......
...@@ -282,7 +282,7 @@ public class LobStorage { ...@@ -282,7 +282,7 @@ public class LobStorage {
private final long lob; private final long lob;
private final byte[] hmac; private final byte[] hmac;
/** /**
* The position. * The position.
*/ */
...@@ -547,6 +547,7 @@ public class LobStorage { ...@@ -547,6 +547,7 @@ public class LobStorage {
* Get the input stream for the given lob. * Get the input stream for the given lob.
* *
* @param lobId the lob id * @param lobId the lob id
* @param hmac the message authentication code (for remote input streams)
* @param byteCount the number of bytes to read, or -1 if not known * @param byteCount the number of bytes to read, or -1 if not known
* @return the stream * @return the stream
*/ */
......
...@@ -268,8 +268,10 @@ public class FilePathDisk extends FilePath { ...@@ -268,8 +268,10 @@ public class FilePathDisk extends FilePath {
} }
public InputStream newInputStream() throws IOException { public InputStream newInputStream() throws IOException {
if (name.indexOf(':') > 1) { int index = name.indexOf(':');
// if the : is in position 1, a windows file access is assumed: C:.. or D: if (index > 1 && index < 20) {
// if the ':' is in position 1, a windows file access is assumed: C:.. or D:
// if the ':' is not at the beginning, assume its a file name with a colon
if (name.startsWith(CLASSPATH_PREFIX)) { if (name.startsWith(CLASSPATH_PREFIX)) {
String fileName = name.substring(CLASSPATH_PREFIX.length()); String fileName = name.substring(CLASSPATH_PREFIX.length());
if (!fileName.startsWith("/")) { if (!fileName.startsWith("/")) {
......
...@@ -626,7 +626,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -626,7 +626,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
// Mac OS: to open a page with Safari, use "open -a Safari" // Mac OS: to open a page with Safari, use "open -a Safari"
Runtime.getRuntime().exec(new String[] { "open", url }); Runtime.getRuntime().exec(new String[] { "open", url });
} else { } else {
String[] browsers = { "google-chrome", "firefox", "mozilla-firefox", "mozilla", "konqueror", "netscape", "opera", "midori" }; String[] browsers = { "google-chrome", "firefox", "mozilla-firefox",
"mozilla", "konqueror", "netscape", "opera", "midori" };
boolean ok = false; boolean ok = false;
for (String b : browsers) { for (String b : browsers) {
try { try {
......
...@@ -404,7 +404,11 @@ public class Utils { ...@@ -404,7 +404,11 @@ public class Utils {
} }
/** /**
* Checks if given classes have common Comparable superclass. * Checks if given classes have a common Comparable superclass.
*
* @param c1 the first class
* @param c2 the second class
* @return true if they have
*/ */
public static boolean haveCommonComparableSuperclass(Class<?> c1, Class<?> c2) { public static boolean haveCommonComparableSuperclass(Class<?> c1, Class<?> c2) {
if (c1 == c2 || c1.isAssignableFrom(c2) || c2.isAssignableFrom(c1)) { if (c1 == c2 || c1.isAssignableFrom(c2) || c2.isAssignableFrom(c1)) {
......
...@@ -21,7 +21,6 @@ import java.sql.ResultSetMetaData; ...@@ -21,7 +21,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Time; import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Arrays;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.SessionInterface; import org.h2.engine.SessionInterface;
...@@ -729,11 +728,13 @@ public class Transfer { ...@@ -729,11 +728,13 @@ public class Transfer {
/** /**
* Verify the HMAC. * Verify the HMAC.
* *
* @throws DbException if the HMAC does not verify * @param hmac the message authentication code
* @param lobId the lobId
* @throws DbException if the HMAC does not match
*/ */
public void verifyLobMac(byte[] hmacData, long lobId) { public void verifyLobMac(byte[] hmac, long lobId) {
byte[] result = calculateLobMac(lobId); byte[] result = calculateLobMac(lobId);
if (!Arrays.equals(result, hmacData)) { if (!Utils.compareSecure(hmac, result)) {
throw DbException.get(ErrorCode.REMOTE_CONNECTION_NOT_ALLOWED); throw DbException.get(ErrorCode.REMOTE_CONNECTION_NOT_ALLOWED);
} }
} }
......
...@@ -21,7 +21,14 @@ public class ValueBytes extends Value { ...@@ -21,7 +21,14 @@ public class ValueBytes extends Value {
private static final ValueBytes EMPTY = new ValueBytes(Utils.EMPTY_BYTES); private static final ValueBytes EMPTY = new ValueBytes(Utils.EMPTY_BYTES);
/**
* The value.
*/
protected byte[] value; protected byte[] value;
/**
* The hash code.
*/
protected int hash; protected int hash;
protected ValueBytes(byte[] v) { protected ValueBytes(byte[] v) {
......
...@@ -97,17 +97,19 @@ public class ValueJavaObject extends ValueBytes { ...@@ -97,17 +97,19 @@ public class ValueJavaObject extends ValueBytes {
boolean o1Comparable = o1 instanceof Comparable; boolean o1Comparable = o1 instanceof Comparable;
boolean o2Comparable = o2 instanceof Comparable; boolean o2Comparable = o2 instanceof Comparable;
if (o1Comparable && o2Comparable && if (o1Comparable && o2Comparable &&
Utils.haveCommonComparableSuperclass(o1.getClass(), o2.getClass())) { Utils.haveCommonComparableSuperclass(o1.getClass(), o2.getClass())) {
return ((Comparable) o1).compareTo(o2); @SuppressWarnings("unchecked")
Comparable<Object> c1 = (Comparable<Object>) o1;
return c1.compareTo(o2);
} }
// group by types // group by types
if (o1.getClass() != o2.getClass()) { if (o1.getClass() != o2.getClass()) {
if (o1Comparable != o2Comparable) { if (o1Comparable != o2Comparable) {
return o1Comparable ? -1 : 1; return o1Comparable ? -1 : 1;
} }
return o1.getClass().getName().compareTo(o2.getClass().getName()); return o1.getClass().getName().compareTo(o2.getClass().getName());
} }
...@@ -119,7 +121,7 @@ public class ValueJavaObject extends ValueBytes { ...@@ -119,7 +121,7 @@ public class ValueJavaObject extends ValueBytes {
if (o1.equals(o2)) { if (o1.equals(o2)) {
return 0; return 0;
} }
return Utils.compareNotNull(getBytesNoCopy(), v.getBytesNoCopy()); return Utils.compareNotNull(getBytesNoCopy(), v.getBytesNoCopy());
} }
......
...@@ -69,6 +69,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo ...@@ -69,6 +69,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
* @param lobStorage the storage * @param lobStorage the storage
* @param tableId the table id * @param tableId the table id
* @param id the lob id * @param id the lob id
* @param hmac the message authentication code
* @param precision the precision (number of bytes / characters) * @param precision the precision (number of bytes / characters)
* @return the value * @return the value
*/ */
......
...@@ -42,7 +42,7 @@ public class TestFullText extends TestBase { ...@@ -42,7 +42,7 @@ public class TestFullText extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testUuidPrimaryKey(false); testUuidPrimaryKey(false);
testAutoAnalyze(); testAutoAnalyze();
testNativeFeatures(); testNativeFeatures();
testTransaction(false); testTransaction(false);
...@@ -75,16 +75,16 @@ public class TestFullText extends TestBase { ...@@ -75,16 +75,16 @@ public class TestFullText extends TestBase {
deleteDb("fullTextReopen"); deleteDb("fullTextReopen");
} }
private static void close(Collection<Connection> conns) throws SQLException { private static void close(Collection<Connection> list) throws SQLException {
for (Connection conn : conns) { for (Connection conn : list) {
conn.close(); conn.close();
} }
} }
private Connection getConnection(String name, Collection<Connection> conns) throws SQLException { private Connection getConnection(String name, Collection<Connection> list) throws SQLException {
Connection conn = getConnection(name); Connection conn = getConnection(name);
conns.add(conn); list.add(conn);
return conn; return conn;
} }
private void testAutoAnalyze() throws SQLException { private void testAutoAnalyze() throws SQLException {
...@@ -92,9 +92,9 @@ public class TestFullText extends TestBase { ...@@ -92,9 +92,9 @@ public class TestFullText extends TestBase {
Connection conn; Connection conn;
Statement stat; Statement stat;
ArrayList<Connection> conns = new ArrayList<Connection>(); ArrayList<Connection> connList = new ArrayList<Connection>();
conn = getConnection("fullTextNative", conns); conn = getConnection("fullTextNative", connList);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create alias if not exists ft_init for \"org.h2.fulltext.FullText.init\""); stat.execute("create alias if not exists ft_init for \"org.h2.fulltext.FullText.init\"");
stat.execute("call ft_init()"); stat.execute("call ft_init()");
...@@ -102,19 +102,19 @@ public class TestFullText extends TestBase { ...@@ -102,19 +102,19 @@ public class TestFullText extends TestBase {
stat.execute("call ft_create_index('PUBLIC', 'TEST', 'NAME')"); stat.execute("call ft_create_index('PUBLIC', 'TEST', 'NAME')");
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
} }
conn = getConnection("fullTextNative", conns); conn = getConnection("fullTextNative", connList);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("insert into test select x, 'x' from system_range(1, 3000)"); stat.execute("insert into test select x, 'x' from system_range(1, 3000)");
close(conns); close(connList);
} }
private void testNativeFeatures() throws SQLException { private void testNativeFeatures() throws SQLException {
deleteDb("fullTextNative"); deleteDb("fullTextNative");
ArrayList<Connection> conns = new ArrayList<Connection>(); ArrayList<Connection> connList = new ArrayList<Connection>();
Connection conn = getConnection("fullTextNative", conns); Connection conn = getConnection("fullTextNative", connList);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\""); stat.execute("CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\"");
stat.execute("CALL FT_INIT()"); stat.execute("CALL FT_INIT()");
...@@ -149,9 +149,9 @@ public class TestFullText extends TestBase { ...@@ -149,9 +149,9 @@ public class TestFullText extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
} }
conn = getConnection("fullTextNative", conns); conn = getConnection("fullTextNative", connList);
stat = conn.createStatement(); stat = conn.createStatement();
conn.setAutoCommit(false); conn.setAutoCommit(false);
stat.execute("delete from test"); stat.execute("delete from test");
...@@ -161,14 +161,14 @@ public class TestFullText extends TestBase { ...@@ -161,14 +161,14 @@ public class TestFullText extends TestBase {
rs = stat.executeQuery("SELECT * FROM FT_SEARCH_DATA('Welcome', 0, 0)"); rs = stat.executeQuery("SELECT * FROM FT_SEARCH_DATA('Welcome', 0, 0)");
assertTrue(rs.next()); assertTrue(rs.next());
conn.setAutoCommit(true); conn.setAutoCommit(true);
close(conns); close(connList);
} }
private void testUuidPrimaryKey(boolean lucene) throws SQLException { private void testUuidPrimaryKey(boolean lucene) throws SQLException {
deleteDb("fullText"); deleteDb("fullText");
Connection conn = getConnection("fullText"); Connection conn = getConnection("fullText");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String prefix = lucene ? "FTL" : "FT"; String prefix = lucene ? "FTL" : "FT";
String className = lucene ? "FullTextLucene" : "FullText"; String className = lucene ? "FullTextLucene" : "FullText";
stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\""); stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\"");
stat.execute("CALL " + prefix + "_INIT()"); stat.execute("CALL " + prefix + "_INIT()");
...@@ -193,8 +193,8 @@ public class TestFullText extends TestBase { ...@@ -193,8 +193,8 @@ public class TestFullText extends TestBase {
String prefix = lucene ? "FTL" : "FT"; String prefix = lucene ? "FTL" : "FT";
deleteDb("fullTextTransaction"); deleteDb("fullTextTransaction");
FileUtils.deleteRecursive(getBaseDir() + "/fullTextTransaction", false); FileUtils.deleteRecursive(getBaseDir() + "/fullTextTransaction", false);
ArrayList<Connection> conns = new ArrayList<Connection>(); ArrayList<Connection> connList = new ArrayList<Connection>();
Connection conn = getConnection("fullTextTransaction", conns); Connection conn = getConnection("fullTextTransaction", connList);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText"; String className = lucene ? "FullTextLucene" : "FullText";
stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\""); stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\"");
...@@ -210,16 +210,16 @@ public class TestFullText extends TestBase { ...@@ -210,16 +210,16 @@ public class TestFullText extends TestBase {
stat.execute("insert into test values(2, 'Hello Moon!')"); stat.execute("insert into test values(2, 'Hello Moon!')");
conn.rollback(); conn.rollback();
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
} }
conn = getConnection("fullTextTransaction", conns); conn = getConnection("fullTextTransaction", connList);
stat = conn.createStatement(); stat = conn.createStatement();
rs = stat.executeQuery("SELECT * FROM " + prefix + "_SEARCH('Hello', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "_SEARCH('Hello', 0, 0)");
assertTrue(rs.next()); assertTrue(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "_SEARCH('Moon', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "_SEARCH('Moon', 0, 0)");
assertFalse(rs.next()); assertFalse(rs.next());
FullText.dropAll(conn); FullText.dropAll(conn);
close(conns); close(connList);
deleteDb("fullTextTransaction"); deleteDb("fullTextTransaction");
FileUtils.deleteRecursive(getBaseDir() + "/fullTextTransaction", false); FileUtils.deleteRecursive(getBaseDir() + "/fullTextTransaction", false);
} }
...@@ -228,13 +228,13 @@ public class TestFullText extends TestBase { ...@@ -228,13 +228,13 @@ public class TestFullText extends TestBase {
final String prefix = lucene ? "FTL" : "FT"; final String prefix = lucene ? "FTL" : "FT";
trace("Testing multithreaded " + prefix); trace("Testing multithreaded " + prefix);
deleteDb("fullText"); deleteDb("fullText");
ArrayList<Connection> conns = new ArrayList<Connection>(); ArrayList<Connection> connList = new ArrayList<Connection>();
int len = 2; int len = 2;
Task[] task = new Task[len]; Task[] task = new Task[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
// final Connection conn = // final Connection conn =
// getConnection("fullText;MULTI_THREADED=1;LOCK_TIMEOUT=10000"); // getConnection("fullText;MULTI_THREADED=1;LOCK_TIMEOUT=10000");
final Connection conn = getConnection("fullText", conns); final Connection conn = getConnection("fullText", connList);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText"; String className = lucene ? "FullTextLucene" : "FullText";
stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\""); stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\"");
...@@ -271,7 +271,7 @@ public class TestFullText extends TestBase { ...@@ -271,7 +271,7 @@ public class TestFullText extends TestBase {
} }
trace("closing connection"); trace("closing connection");
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
} }
trace("completed thread " + Thread.currentThread()); trace("completed thread " + Thread.currentThread());
} }
...@@ -289,7 +289,7 @@ public class TestFullText extends TestBase { ...@@ -289,7 +289,7 @@ public class TestFullText extends TestBase {
t.get(); t.get();
trace("done joining " + t); trace("done joining " + t);
} }
close(conns); close(connList);
} }
private void testStreamLob() throws SQLException { private void testStreamLob() throws SQLException {
...@@ -347,8 +347,8 @@ public class TestFullText extends TestBase { ...@@ -347,8 +347,8 @@ public class TestFullText extends TestBase {
} }
private void testReopen(boolean lucene) throws SQLException { private void testReopen(boolean lucene) throws SQLException {
if (config.memory) { if (config.memory) {
return; return;
} }
String prefix = lucene ? "FTL" : "FT"; String prefix = lucene ? "FTL" : "FT";
deleteDb("fullTextReopen"); deleteDb("fullTextReopen");
...@@ -427,8 +427,8 @@ public class TestFullText extends TestBase { ...@@ -427,8 +427,8 @@ public class TestFullText extends TestBase {
return; return;
} }
deleteDb("fullText"); deleteDb("fullText");
ArrayList<Connection> conns = new ArrayList<Connection>(); ArrayList<Connection> connList = new ArrayList<Connection>();
Connection conn = getConnection("fullText", conns); Connection conn = getConnection("fullText", connList);
String prefix = lucene ? "FTL_" : "FT_"; String prefix = lucene ? "FTL_" : "FT_";
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText"; String className = lucene ? "FullTextLucene" : "FullText";
...@@ -512,15 +512,15 @@ public class TestFullText extends TestBase { ...@@ -512,15 +512,15 @@ public class TestFullText extends TestBase {
} }
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
} }
conn = getConnection("fullText", conns); conn = getConnection("fullText", connList);
stat = conn.createStatement(); stat = conn.createStatement();
stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0)"); stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0)");
stat.execute("CALL " + prefix + "DROP_ALL()"); stat.execute("CALL " + prefix + "DROP_ALL()");
close(conns); close(connList);
} }
} }
...@@ -46,6 +46,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -46,6 +46,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
} }
public void test() throws Exception { public void test() throws Exception {
testLogLimitFalsePositive();
testLogLimit(); testLogLimit();
testRecoverLobInDatabase(); testRecoverLobInDatabase();
testWriteTransactionLogBeforeData(); testWriteTransactionLogBeforeData();
...@@ -105,6 +106,23 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -105,6 +106,23 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
conn.close(); conn.close();
} }
private void testLogLimitFalsePositive() throws Exception {
deleteDb("pageStore");
String url = "pageStore;TRACE_LEVEL_FILE=2";
Connection conn = getConnection(url);
Statement stat = conn.createStatement();
stat.execute("set max_log_size 1");
stat.execute("create table test(x varchar)");
for (int i = 0; i < 1000; ++i) {
stat.execute("insert into test values (space(2000))");
}
stat.execute("checkpoint");
InputStream in = FileUtils.newInputStream(getBaseDir() + "/pageStore.trace.db");
String s = IOUtils.readStringAndClose(new InputStreamReader(in), -1);
assertFalse(s.indexOf("Transaction log could not be truncated") > 0);
conn.close();
}
private void testRecoverLobInDatabase() throws SQLException { private void testRecoverLobInDatabase() throws SQLException {
deleteDb("pageStore"); deleteDb("pageStore");
String url = getURL("pageStore;MVCC=TRUE;CACHE_SIZE=1", true); String url = getURL("pageStore;MVCC=TRUE;CACHE_SIZE=1", true);
......
...@@ -25,6 +25,7 @@ public class H2Cursor extends AbstractWindowedCursor { ...@@ -25,6 +25,7 @@ public class H2Cursor extends AbstractWindowedCursor {
private ResultInterface result; private ResultInterface result;
H2Cursor(H2Database db, H2CursorDriver driver, String editTable, H2Query query) { H2Cursor(H2Database db, H2CursorDriver driver, String editTable, H2Query query) {
this.database = db;
// TODO // TODO
} }
......
...@@ -80,12 +80,6 @@ public class CheckJavadoc { ...@@ -80,12 +80,6 @@ public class CheckJavadoc {
System.out.println("No Javadoc comment: " + file.getAbsolutePath()); System.out.println("No Javadoc comment: " + file.getAbsolutePath());
errorCount++; errorCount++;
} }
int open = text.indexOf('{');
if (open < 0 || open < comment) {
System.out.println("No '{' or '{' before the first Javadoc comment: " +
file.getAbsolutePath());
errorCount++;
}
int pos = 0; int pos = 0;
int lineNumber = 1; int lineNumber = 1;
boolean inComment = false; boolean inComment = false;
......
...@@ -701,4 +701,8 @@ hub rewind spawn shimizu fumiyuki nelson github laird rollover millions ...@@ -701,4 +701,8 @@ hub rewind spawn shimizu fumiyuki nelson github laird rollover millions
ljnelson edugility sormula pushed backslashes slashes lukas batched typesafe ljnelson edugility sormula pushed backslashes slashes lukas batched typesafe
bundled jacob terrence policies periodic eases eder corporate regulatory bundled jacob terrence policies periodic eases eder corporate regulatory
burden isnull periodically suse optimisation krenger qvortrup huang jmxremote burden isnull periodically suse optimisation krenger qvortrup huang jmxremote
clusterable shortcut quota clusterable shortcut quota wcslen flyway cacao tea memcpy someone iced
\ No newline at end of file korea cpp raspberry inttypes korean hmac swprintf ptr agile rawtypes belgium
jia laurent midori stdc macros clocks xaltjvm teruo dylan debian counted
serializes semantics advances severe defensive maintaining collision
authenticating
...@@ -89,7 +89,7 @@ public class FilePathCache extends FilePathWrapper { ...@@ -89,7 +89,7 @@ public class FilePathCache extends FilePathWrapper {
return len; return len;
} }
private long getCachePos(long pos) { private static long getCachePos(long pos) {
return (pos / CACHE_BLOCK_SIZE) * CACHE_BLOCK_SIZE; return (pos / CACHE_BLOCK_SIZE) * CACHE_BLOCK_SIZE;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论