提交 159fe23a authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Formatting, code style, Javadocs

上级 524c1ed8
...@@ -11,4 +11,6 @@ package org.h2; ...@@ -11,4 +11,6 @@ package org.h2;
*/ */
public interface JdbcDriverBackwardsCompat { public interface JdbcDriverBackwardsCompat {
// compatibility interface
} }
...@@ -180,19 +180,25 @@ public class TimestampWithTimeZone implements Serializable, Cloneable { ...@@ -180,19 +180,25 @@ public class TimestampWithTimeZone implements Serializable, Cloneable {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) {
return true; return true;
if (obj == null) }
if (obj == null) {
return false; return false;
if (getClass() != obj.getClass()) }
if (getClass() != obj.getClass()) {
return false; return false;
}
TimestampWithTimeZone other = (TimestampWithTimeZone) obj; TimestampWithTimeZone other = (TimestampWithTimeZone) obj;
if (dateValue != other.dateValue) if (dateValue != other.dateValue) {
return false; return false;
if (timeNanos != other.timeNanos) }
if (timeNanos != other.timeNanos) {
return false; return false;
if (timeZoneOffsetMins != other.timeZoneOffsetMins) }
if (timeZoneOffsetMins != other.timeZoneOffsetMins) {
return false; return false;
}
return true; return true;
} }
......
...@@ -226,8 +226,9 @@ public class CommandRemote implements CommandInterface { ...@@ -226,8 +226,9 @@ public class CommandRemote implements CommandInterface {
for (ParameterInterface p : parameters) { for (ParameterInterface p : parameters) {
Value pVal = p.getParamValue(); Value pVal = p.getParamValue();
if (pVal == null && cmdType == EXPLAIN) if (pVal == null && cmdType == EXPLAIN) {
pVal = ValueNull.INSTANCE; pVal = ValueNull.INSTANCE;
}
transfer.writeValue(pVal); transfer.writeValue(pVal);
} }
......
...@@ -55,9 +55,8 @@ public class AlterIndexRename extends DefineCommand { ...@@ -55,9 +55,8 @@ public class AlterIndexRename extends DefineCommand {
if (!ifExists) { if (!ifExists) {
throw DbException.get(ErrorCode.INDEX_NOT_FOUND_1, throw DbException.get(ErrorCode.INDEX_NOT_FOUND_1,
newIndexName); newIndexName);
} else {
return 0;
} }
return 0;
} }
if (oldSchema.findIndex(session, newIndexName) != null || if (oldSchema.findIndex(session, newIndexName) != null ||
newIndexName.equals(oldIndexName)) { newIndexName.equals(oldIndexName)) {
......
...@@ -104,7 +104,7 @@ public class DropDatabase extends DefineCommand { ...@@ -104,7 +104,7 @@ public class DropDatabase extends DefineCommand {
// ignore these. the ones we want to drop will get dropped when we drop // ignore these. the ones we want to drop will get dropped when we drop
// their associated tables, and we will ignore the problematic ones // their associated tables, and we will ignore the problematic ones
// that belong to session-local temp tables. // that belong to session-local temp tables.
if (!((Sequence)obj).getBelongsToTable()) { if (!((Sequence) obj).getBelongsToTable()) {
list.add(obj); list.add(obj);
} }
} }
......
...@@ -92,9 +92,8 @@ public class AlterSequence extends SchemaCommand { ...@@ -92,9 +92,8 @@ public class AlterSequence extends SchemaCommand {
if (sequence == null) { if (sequence == null) {
if (!ifExists) { if (!ifExists) {
throw DbException.get(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName); throw DbException.get(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName);
} else {
return 0;
} }
return 0;
} }
} }
if (table != null) { if (table != null) {
......
...@@ -61,9 +61,10 @@ public class Explain extends Prepared { ...@@ -61,9 +61,10 @@ public class Explain extends Prepared {
@Override @Override
protected void checkParameters() { protected void checkParameters() {
// Check params only in case of EXPLAIN ANALYZE // Check params only in case of EXPLAIN ANALYZE
if (executeCommand) if (executeCommand) {
super.checkParameters(); super.checkParameters();
} }
}
@Override @Override
public ResultInterface query(int maxrows) { public ResultInterface query(int maxrows) {
......
...@@ -454,8 +454,7 @@ public class Database implements DataHandler { ...@@ -454,8 +454,7 @@ public class Database implements DataHandler {
} }
reconnectLastLock = old; reconnectLastLock = old;
reconnectChangePending = pending; reconnectChangePending = pending;
reconnectCheckNext = System.nanoTime() + reconnectCheckNext = System.nanoTime() + reconnectCheckDelayNs;
reconnectCheckDelayNs;
return true; return true;
} catch (Exception e) { } catch (Exception e) {
trace.error(e, "pending {0}", pending); trace.error(e, "pending {0}", pending);
......
...@@ -37,6 +37,8 @@ public abstract class DbObjectBase implements DbObject { ...@@ -37,6 +37,8 @@ public abstract class DbObjectBase implements DbObject {
private long modificationId; private long modificationId;
private boolean temporary; private boolean temporary;
private String invalidateStackTrace;
/** /**
* Initialize some attributes of this object. * Initialize some attributes of this object.
* *
...@@ -126,7 +128,6 @@ public abstract class DbObjectBase implements DbObject { ...@@ -126,7 +128,6 @@ public abstract class DbObjectBase implements DbObject {
return objectName; return objectName;
} }
private String invalidateStackTrace;
/** /**
* Set the main attributes to null to make sure the object is no longer * Set the main attributes to null to make sure the object is no longer
* used. * used.
......
...@@ -8,7 +8,6 @@ package org.h2.engine; ...@@ -8,7 +8,6 @@ package org.h2.engine;
import java.io.Closeable; import java.io.Closeable;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.jdbc.JdbcConnection;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.store.DataHandler; import org.h2.store.DataHandler;
import org.h2.value.Value; import org.h2.value.Value;
......
...@@ -283,8 +283,10 @@ public class CompareLike extends Condition { ...@@ -283,8 +283,10 @@ public class CompareLike extends Condition {
private static boolean containsIgnoreCase(String src, String what) { private static boolean containsIgnoreCase(String src, String what) {
final int length = what.length(); final int length = what.length();
if (length == 0) if (length == 0) {
return true; // Empty string is contained // Empty string is contained
return true;
}
final char firstLo = Character.toLowerCase(what.charAt(0)); final char firstLo = Character.toLowerCase(what.charAt(0));
final char firstUp = Character.toUpperCase(what.charAt(0)); final char firstUp = Character.toUpperCase(what.charAt(0));
...@@ -292,12 +294,14 @@ public class CompareLike extends Condition { ...@@ -292,12 +294,14 @@ public class CompareLike extends Condition {
for (int i = src.length() - length; i >= 0; i--) { for (int i = src.length() - length; i >= 0; i--) {
// Quick check before calling the more expensive regionMatches() method: // Quick check before calling the more expensive regionMatches() method:
final char ch = src.charAt(i); final char ch = src.charAt(i);
if (ch != firstLo && ch != firstUp) if (ch != firstLo && ch != firstUp) {
continue; continue;
}
if (src.regionMatches(true, i, what, 0, length)) if (src.regionMatches(true, i, what, 0, length)) {
return true; return true;
} }
}
return false; return false;
} }
......
...@@ -199,8 +199,9 @@ public class Comparison extends Condition { ...@@ -199,8 +199,9 @@ public class Comparison extends Condition {
int resType = Value.getHigherOrder(colType, constType); int resType = Value.getHigherOrder(colType, constType);
// If not the column values will need to be promoted // If not the column values will need to be promoted
// to constant type, but vise versa, then let's do this here once. // to constant type, but vise versa, then let's do this here once.
if (constType != resType) if (constType != resType) {
right = ValueExpression.get(r.convertTo(resType)); right = ValueExpression.get(r.convertTo(resType));
}
} else if (right instanceof Parameter) { } else if (right instanceof Parameter) {
((Parameter) right).setColumn( ((Parameter) right).setColumn(
((ExpressionColumn) left).getColumn()); ((ExpressionColumn) left).getColumn());
......
...@@ -83,7 +83,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -83,7 +83,7 @@ public class Function extends Expression implements FunctionCall {
TRUNCATE = 27, SECURE_RAND = 28, HASH = 29, ENCRYPT = 30, TRUNCATE = 27, SECURE_RAND = 28, HASH = 29, ENCRYPT = 30,
DECRYPT = 31, COMPRESS = 32, EXPAND = 33, ZERO = 34, DECRYPT = 31, COMPRESS = 32, EXPAND = 33, ZERO = 34,
RANDOM_UUID = 35, COSH = 36, SINH = 37, TANH = 38, LN = 39, RANDOM_UUID = 35, COSH = 36, SINH = 37, TANH = 38, LN = 39,
BITGET=40; BITGET = 40;
public static final int ASCII = 50, BIT_LENGTH = 51, CHAR = 52, public static final int ASCII = 50, BIT_LENGTH = 51, CHAR = 52,
CHAR_LENGTH = 53, CONCAT = 54, DIFFERENCE = 55, HEXTORAW = 56, CHAR_LENGTH = 53, CONCAT = 54, DIFFERENCE = 55, HEXTORAW = 56,
......
...@@ -11,4 +11,6 @@ package org.h2.jdbc; ...@@ -11,4 +11,6 @@ package org.h2.jdbc;
*/ */
public interface JdbcCallableStatementBackwardsCompat { public interface JdbcCallableStatementBackwardsCompat {
// compatibility interface
} }
...@@ -11,4 +11,6 @@ package org.h2.jdbc; ...@@ -11,4 +11,6 @@ package org.h2.jdbc;
*/ */
public interface JdbcConnectionBackwardsCompat { public interface JdbcConnectionBackwardsCompat {
// compatibility interface
} }
...@@ -11,4 +11,6 @@ package org.h2.jdbc; ...@@ -11,4 +11,6 @@ package org.h2.jdbc;
*/ */
public interface JdbcDatabaseMetaDataBackwardsCompat { public interface JdbcDatabaseMetaDataBackwardsCompat {
// compatibility interface
} }
...@@ -11,4 +11,6 @@ package org.h2.jdbc; ...@@ -11,4 +11,6 @@ package org.h2.jdbc;
*/ */
public interface JdbcResultSetBackwardsCompat { public interface JdbcResultSetBackwardsCompat {
// compatibility interface
} }
...@@ -11,4 +11,6 @@ package org.h2.jdbc; ...@@ -11,4 +11,6 @@ package org.h2.jdbc;
*/ */
public interface JdbcStatementBackwardsCompat { public interface JdbcStatementBackwardsCompat {
// compatibility interface
} }
...@@ -11,4 +11,6 @@ package org.h2.jdbcx; ...@@ -11,4 +11,6 @@ package org.h2.jdbcx;
*/ */
public interface JdbcConnectionPoolBackwardsCompat { public interface JdbcConnectionPoolBackwardsCompat {
// compatibility interface
} }
...@@ -11,4 +11,6 @@ package org.h2.jdbcx; ...@@ -11,4 +11,6 @@ package org.h2.jdbcx;
*/ */
public interface JdbcDataSourceBackwardsCompat { public interface JdbcDataSourceBackwardsCompat {
// compatibility interface
} }
...@@ -274,7 +274,6 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -274,7 +274,6 @@ public class MVPrimaryIndex extends BaseIndex {
} }
Value value = map.get(v); Value value = map.get(v);
Entry<Value, Value> e = new DataUtils.MapEntry<Value, Value>(v, value); Entry<Value, Value> e = new DataUtils.MapEntry<Value, Value>(v, value);
@SuppressWarnings("unchecked")
List<Entry<Value, Value>> list = Arrays.asList(e); List<Entry<Value, Value>> list = Arrays.asList(e);
MVStoreCursor c = new MVStoreCursor(session, list.iterator(), v); MVStoreCursor c = new MVStoreCursor(session, list.iterator(), v);
c.next(); c.next();
......
...@@ -606,9 +606,9 @@ public class Schema extends DbObjectBase { ...@@ -606,9 +606,9 @@ public class Schema extends DbObjectBase {
} }
} }
if (data.tableEngine != null) { if (data.tableEngine != null) {
if (data.tableEngineParams == null) if (data.tableEngineParams == null) {
data.tableEngineParams = this.tableEngineParams; data.tableEngineParams = this.tableEngineParams;
}
return database.getTableEngine(data.tableEngine).createTable(data); return database.getTableEngine(data.tableEngine).createTable(data);
} }
return new RegularTable(data); return new RegularTable(data);
......
...@@ -16,7 +16,6 @@ import java.sql.SQLException; ...@@ -16,7 +16,6 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.Command; import org.h2.command.Command;
import org.h2.command.CommandInterface;
import org.h2.engine.ConnectionInfo; import org.h2.engine.ConnectionInfo;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Engine; import org.h2.engine.Engine;
......
...@@ -456,7 +456,7 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -456,7 +456,7 @@ public class LobStorageBackend implements LobStorageInterface {
try { try {
init(); init();
ValueLobDb v = null; ValueLobDb v = null;
if(!old.isRecoveryReference()){ if (!old.isRecoveryReference()) {
long lobId = getNextLobId(); long lobId = getNextLobId();
String sql = "INSERT INTO " + LOB_MAP + "(LOB, SEQ, POS, HASH, BLOCK) " + String sql = "INSERT INTO " + LOB_MAP + "(LOB, SEQ, POS, HASH, BLOCK) " +
"SELECT ?, SEQ, POS, HASH, BLOCK FROM " + LOB_MAP + " WHERE LOB = ?"; "SELECT ?, SEQ, POS, HASH, BLOCK FROM " + LOB_MAP + " WHERE LOB = ?";
...@@ -476,7 +476,7 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -476,7 +476,7 @@ public class LobStorageBackend implements LobStorageInterface {
reuse(sql, prep); reuse(sql, prep);
v = ValueLobDb.create(type, database, tableId, lobId, null, length); v = ValueLobDb.create(type, database, tableId, lobId, null, length);
}else{ } else {
//Recovery process, no need to copy LOB using normal infrastructure //Recovery process, no need to copy LOB using normal infrastructure
v = ValueLobDb.create(type, database, tableId, oldLobId, null, length); v = ValueLobDb.create(type, database, tableId, oldLobId, null, length);
} }
......
...@@ -34,28 +34,24 @@ public abstract class FileBase extends FileChannel { ...@@ -34,28 +34,24 @@ public abstract class FileBase extends FileChannel {
public abstract int write(ByteBuffer src) throws IOException; public abstract int write(ByteBuffer src) throws IOException;
@Override @Override
public int read(ByteBuffer dst, long position) public synchronized int read(ByteBuffer dst, long position)
throws IOException { throws IOException {
synchronized(this) {
long oldPos = position(); long oldPos = position();
position(position); position(position);
int len = read(dst); int len = read(dst);
position(oldPos); position(oldPos);
return len; return len;
} }
}
@Override @Override
public int write(ByteBuffer src, long position) public synchronized int write(ByteBuffer src, long position)
throws IOException { throws IOException {
synchronized(this) {
long oldPos = position(); long oldPos = position();
position(position); position(position);
int len = write(src); int len = write(src);
position(oldPos); position(oldPos);
return len; return len;
} }
}
@Override @Override
public abstract FileChannel truncate(long size) throws IOException; public abstract FileChannel truncate(long size) throws IOException;
......
...@@ -14,8 +14,8 @@ import java.util.concurrent.Future; ...@@ -14,8 +14,8 @@ import java.util.concurrent.Future;
import org.h2.command.dml.Query; import org.h2.command.dml.Query;
import org.h2.command.dml.Select; import org.h2.command.dml.Select;
import org.h2.command.dml.SelectUnion; import org.h2.command.dml.SelectUnion;
import org.h2.index.BaseIndex;
import org.h2.index.Cursor; import org.h2.index.Cursor;
import org.h2.index.Index;
import org.h2.index.IndexCursor; import org.h2.index.IndexCursor;
import org.h2.index.IndexLookupBatch; import org.h2.index.IndexLookupBatch;
import org.h2.index.ViewCursor; import org.h2.index.ViewCursor;
...@@ -33,7 +33,7 @@ import org.h2.value.ValueLong; ...@@ -33,7 +33,7 @@ import org.h2.value.ValueLong;
/** /**
* Support for asynchronous batched index lookups on joins. * Support for asynchronous batched index lookups on joins.
* *
* @see Index#createLookupBatch(org.h2.table.TableFilter[], int) * @see BaseIndex#createLookupBatch(org.h2.table.TableFilter[], int)
* @see IndexLookupBatch * @see IndexLookupBatch
* @author Sergi Vladykin * @author Sergi Vladykin
*/ */
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
*/ */
package org.h2.table; package org.h2.table;
/**
* The table types.
*/
public enum TableType { public enum TableType {
/** /**
......
...@@ -355,8 +355,8 @@ ShutdownHandler { ...@@ -355,8 +355,8 @@ ShutdownHandler {
} }
System.gc(); System.gc();
// Mac OS X: Console tool process did not stop on exit // Mac OS X: Console tool process did not stop on exit
String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if (OS.indexOf("mac") >= 0) { if (os.indexOf("mac") >= 0) {
for (Thread t : Thread.getAllStackTraces().keySet()) { for (Thread t : Thread.getAllStackTraces().keySet()) {
if (t.getName().startsWith("AWT-")) { if (t.getName().startsWith("AWT-")) {
t.interrupt(); t.interrupt();
......
...@@ -15,6 +15,8 @@ import org.h2.message.DbException; ...@@ -15,6 +15,8 @@ import org.h2.message.DbException;
* Single threaded lazy future. * Single threaded lazy future.
* *
* @author Sergi Vladykin * @author Sergi Vladykin
*
* @param <T> the result type
*/ */
public abstract class LazyFuture<T> implements Future<T> { public abstract class LazyFuture<T> implements Future<T> {
......
...@@ -158,9 +158,11 @@ public abstract class Value { ...@@ -158,9 +158,11 @@ public abstract class Value {
* The value type for string values with a fixed size. * The value type for string values with a fixed size.
*/ */
public static final int GEOMETRY = 22; public static final int GEOMETRY = 22;
/** /**
* 23 was a short-lived experiment "TIMESTAMP UTC" which has been removed. * 23 was a short-lived experiment "TIMESTAMP UTC" which has been removed.
*/ */
/** /**
* The value type for TIMESTAMP WITH TIME ZONE values. * The value type for TIMESTAMP WITH TIME ZONE values.
*/ */
...@@ -866,9 +868,8 @@ public abstract class Value { ...@@ -866,9 +868,8 @@ public abstract class Value {
java.util.UUID uuid = (java.util.UUID) object; java.util.UUID uuid = (java.util.UUID) object;
return ValueUuid.get(uuid.getMostSignificantBits(), return ValueUuid.get(uuid.getMostSignificantBits(),
uuid.getLeastSignificantBits()); uuid.getLeastSignificantBits());
} else {
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, getString());
} }
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, getString());
case TIMESTAMP_TZ: case TIMESTAMP_TZ:
throw DbException.get( throw DbException.get(
ErrorCode.DATA_CONVERSION_ERROR_1, getString()); ErrorCode.DATA_CONVERSION_ERROR_1, getString());
......
...@@ -58,7 +58,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -58,7 +58,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
//Arbonaut: 13.07.2016 //Arbonaut: 13.07.2016
// Fix for recovery tool. // Fix for recovery tool.
private boolean isRecoveryReference = false; private boolean isRecoveryReference;
private ValueLobDb(int type, DataHandler handler, int tableId, long lobId, private ValueLobDb(int type, DataHandler handler, int tableId, long lobId,
byte[] hmac, long precision) { byte[] hmac, long precision) {
......
...@@ -25,8 +25,6 @@ import org.h2.util.StringUtils; ...@@ -25,8 +25,6 @@ import org.h2.util.StringUtils;
*/ */
public class ValueTimestampTimeZone extends Value { public class ValueTimestampTimeZone extends Value {
private static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
/** /**
* The precision in digits. * The precision in digits.
*/ */
...@@ -43,6 +41,8 @@ public class ValueTimestampTimeZone extends Value { ...@@ -43,6 +41,8 @@ public class ValueTimestampTimeZone extends Value {
*/ */
static final int DEFAULT_SCALE = 10; static final int DEFAULT_SCALE = 10;
private static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
/** /**
* A bit field with bits for the year, month, and day (see DateTimeUtils for * A bit field with bits for the year, month, and day (see DateTimeUtils for
* encoding) * encoding)
......
...@@ -70,8 +70,8 @@ public class DirectInsert { ...@@ -70,8 +70,8 @@ public class DirectInsert {
(optimize ? "(optimized)" : "")); (optimize ? "(optimized)" : ""));
long time = System.nanoTime(); long time = System.nanoTime();
stat.execute("CREATE TABLE TEST2 AS SELECT * FROM TEST"); stat.execute("CREATE TABLE TEST2 AS SELECT * FROM TEST");
System.out.printf("%.3f sec.\n", System.out.printf("%.3f sec.\n", (double) (System.nanoTime() - time) /
(double)(System.nanoTime() - time) / TimeUnit.SECONDS.toNanos(1)); TimeUnit.SECONDS.toNanos(1));
stat.execute("INSERT INTO TEST2 SELECT * FROM TEST2"); stat.execute("INSERT INTO TEST2 SELECT * FROM TEST2");
stat.close(); stat.close();
conn.close(); conn.close();
......
...@@ -269,6 +269,11 @@ java org.h2.test.TestAll timer ...@@ -269,6 +269,11 @@ java org.h2.test.TestAll timer
*/ */
/**
* Set to true if any of the tests fail. Used to return an error code from the whole program.
*/
static boolean atLeastOneTestFailed;
/** /**
* Whether the MVStore storage is used. * Whether the MVStore storage is used.
*/ */
...@@ -415,11 +420,6 @@ java org.h2.test.TestAll timer ...@@ -415,11 +420,6 @@ java org.h2.test.TestAll timer
*/ */
ArrayList<TestBase> tests = New.arrayList(); ArrayList<TestBase> tests = New.arrayList();
/**
* Set to true if any of the tests fail. Used to return an error code from the whole program.
*/
static boolean atLeastOneTestFailed;
private Server server; private Server server;
/** /**
...@@ -929,12 +929,13 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -929,12 +929,13 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// event queue watchdog for tests that get stuck when running in Jenkins CI // event queue watchdog for tests that get stuck when running in Jenkins CI
final java.util.Timer watchdog = new java.util.Timer(); final java.util.Timer watchdog = new java.util.Timer();
// 5 minutes
watchdog.schedule(new TimerTask() { watchdog.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
ThreadDeadlockDetector.dumpAllThreadsAndLocks("test watchdog timed out"); ThreadDeadlockDetector.dumpAllThreadsAndLocks("test watchdog timed out");
} }
}, 5 * 60 * 1000); // 5 minutes }, 5 * 60 * 1000);
try { try {
test.runTest(this); test.runTest(this);
} finally { } finally {
......
...@@ -196,7 +196,7 @@ class Database { ...@@ -196,7 +196,7 @@ class Database {
} }
} else if (url.startsWith("jdbc:hsqldb:")) { } else if (url.startsWith("jdbc:hsqldb:")) {
// HSQLDB: use a WRITE_DELAY of 1 second // HSQLDB: use a WRITE_DELAY of 1 second
try (Statement s = newConn.createStatement()){ try (Statement s = newConn.createStatement()) {
s.execute("SET WRITE_DELAY 1"); s.execute("SET WRITE_DELAY 1");
} }
} }
......
...@@ -176,6 +176,7 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -176,6 +176,7 @@ public class TestCompatibilityOracle extends TestBase {
stat.executeQuery("SELECT * FROM A WHERE ID IN ()"); stat.executeQuery("SELECT * FROM A WHERE ID IN ()");
fail(); fail();
} catch (SQLException e) { } catch (SQLException e) {
// expected
} finally { } finally {
conn.close(); conn.close();
} }
......
...@@ -1296,7 +1296,9 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1296,7 +1296,9 @@ public class TestFunctions extends TestBase implements AggregateFunction {
try { try {
ToDateParser.toDate("1-DEC-0000", "DD-MON-RRRR"); ToDateParser.toDate("1-DEC-0000", "DD-MON-RRRR");
fail("Oracle to_date should reject year 0 (ORA-01841)"); fail("Oracle to_date should reject year 0 (ORA-01841)");
} catch (Exception e) { } } catch (Exception e) {
// expected
}
} }
private void testToDate() throws ParseException { private void testToDate() throws ParseException {
......
...@@ -438,14 +438,14 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -438,14 +438,14 @@ public class TestMultiThread extends TestBase implements Runnable {
private void testConcurrentUpdate() throws Exception { private void testConcurrentUpdate() throws Exception {
deleteDb("lockMode"); deleteDb("lockMode");
final int OBJ_CNT = 10000; final int objectCount = 10000;
final String url = getURL("lockMode;MULTI_THREADED=1;LOCK_TIMEOUT=10000", true); final String url = getURL("lockMode;MULTI_THREADED=1;LOCK_TIMEOUT=10000", true);
final Connection conn = getConnection(url); final Connection conn = getConnection(url);
conn.createStatement().execute( conn.createStatement().execute(
"CREATE TABLE IF NOT EXISTS ACCOUNT ( ID NUMBER(18,0) not null PRIMARY KEY, BALANCE NUMBER null)"); "CREATE TABLE IF NOT EXISTS ACCOUNT ( ID NUMBER(18,0) not null PRIMARY KEY, BALANCE NUMBER null)");
final PreparedStatement mergeAcctStmt = conn final PreparedStatement mergeAcctStmt = conn
.prepareStatement("MERGE INTO Account(id, balance) key (id) VALUES (?, ?)"); .prepareStatement("MERGE INTO Account(id, balance) key (id) VALUES (?, ?)");
for (int i = 0; i < OBJ_CNT; i++) { for (int i = 0; i < objectCount; i++) {
mergeAcctStmt.setLong(1, i); mergeAcctStmt.setLong(1, i);
mergeAcctStmt.setBigDecimal(2, BigDecimal.ZERO); mergeAcctStmt.setBigDecimal(2, BigDecimal.ZERO);
mergeAcctStmt.execute(); mergeAcctStmt.execute();
...@@ -463,7 +463,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -463,7 +463,7 @@ public class TestMultiThread extends TestBase implements Runnable {
public Void call() throws Exception { public Void call() throws Exception {
for (int j = 0; j < 1000; j++) { for (int j = 0; j < 1000; j++) {
updateAcctStmt.setDouble(1, Math.random()); updateAcctStmt.setDouble(1, Math.random());
updateAcctStmt.setLong(2, (int) (Math.random() * OBJ_CNT)); updateAcctStmt.setLong(2, (int) (Math.random() * objectCount));
updateAcctStmt.execute(); updateAcctStmt.execute();
taskConn.commit(); taskConn.commit();
} }
......
...@@ -100,7 +100,8 @@ public class TestOutOfMemory extends TestBase { ...@@ -100,7 +100,8 @@ public class TestOutOfMemory extends TestBase {
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("select 1"); stat.execute("select 1");
conn.close(); conn.close();
FileUtils.delete(filename); // release the static data this test generates // release the static data this test generates
FileUtils.delete(filename);
} }
private void testUpdateWhenNearlyOutOfMemory() throws SQLException { private void testUpdateWhenNearlyOutOfMemory() throws SQLException {
......
...@@ -468,7 +468,7 @@ public class TestCallableStatement extends TestBase { ...@@ -468,7 +468,7 @@ public class TestCallableStatement extends TestBase {
getClass().getName() + ".arrayIdentiy\""); getClass().getName() + ".arrayIdentiy\"");
for (Object[] arrayToTest : arraysToTest) { for (Object[] arrayToTest : arraysToTest) {
Array sqlInputArray = connection.createArrayOf("ignored",arrayToTest); Array sqlInputArray = connection.createArrayOf("ignored", arrayToTest);
try { try {
try (CallableStatement callableStatement = connection.prepareCall("{call arrayIdentiy(?)}")) { try (CallableStatement callableStatement = connection.prepareCall("{call arrayIdentiy(?)}")) {
callableStatement.setArray(1, sqlInputArray); callableStatement.setArray(1, sqlInputArray);
......
...@@ -192,7 +192,8 @@ public class TestReorderWrites extends TestBase { ...@@ -192,7 +192,8 @@ public class TestReorderWrites extends TestBase {
} }
assertTrue(minSize < maxSize); assertTrue(minSize < maxSize);
assertTrue(minWritten < maxWritten); assertTrue(minWritten < maxWritten);
FileUtils.delete(fileName); // release the static data this test generates // release the static data this test generates
FileUtils.delete(fileName);
} }
} }
...@@ -7,6 +7,9 @@ import org.h2.test.TestBase; ...@@ -7,6 +7,9 @@ import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
import org.h2.tools.Recover; import org.h2.tools.Recover;
/**
* Tests BLOB/CLOB recovery.
*/
public class RecoverLobTest extends TestBase { public class RecoverLobTest extends TestBase {
public static void main(String... a) throws Exception { public static void main(String... a) throws Exception {
...@@ -16,7 +19,7 @@ public class RecoverLobTest extends TestBase { ...@@ -16,7 +19,7 @@ public class RecoverLobTest extends TestBase {
@Override @Override
public TestBase init() throws Exception { public TestBase init() throws Exception {
TestBase tb = super.init(); TestBase tb = super.init();
config.mvStore=false; config.mvStore = false;
return tb; return tb;
} }
......
...@@ -131,7 +131,8 @@ public class TestBenchmark extends TestBase { ...@@ -131,7 +131,8 @@ public class TestBenchmark extends TestBase {
Statement stat; Statement stat;
String url = "mvstore"; String url = "mvstore";
if (mvStore) { if (mvStore) {
url += ";MV_STORE=TRUE"; // ;COMPRESS=TRUE"; // ;COMPRESS=TRUE";
url += ";MV_STORE=TRUE";
} }
url = getURL(url, true); url = getURL(url, true);
......
...@@ -68,7 +68,9 @@ public class TestValue extends TestBase { ...@@ -68,7 +68,9 @@ public class TestValue extends TestBase {
rs.addRow(new Object[]{null}); rs.addRow(new Object[]{null});
rs.next(); rs.next();
for (int type = Value.NULL; type < Value.TYPE_COUNT; type++) { for (int type = Value.NULL; type < Value.TYPE_COUNT; type++) {
if (type != 23) { // a defunct experimental type if (type == 23) {
// a defunct experimental type
} else {
Value v = DataType.readValue(null, rs, 1, type); Value v = DataType.readValue(null, rs, 1, type);
assertTrue(v == ValueNull.INSTANCE); assertTrue(v == ValueNull.INSTANCE);
} }
......
...@@ -283,9 +283,8 @@ class FileReorderWrites extends FileBase { ...@@ -283,9 +283,8 @@ class FileReorderWrites extends FileBase {
x += addOperation( x += addOperation(
new FileWriteOperation(id++, position + len1, buf2)); new FileWriteOperation(id++, position + len1, buf2));
return x; return x;
} else {
return addOperation(new FileWriteOperation(id++, position, src));
} }
return addOperation(new FileWriteOperation(id++, position, src));
} }
private void checkError() throws IOException { private void checkError() throws IOException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论