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

--no commit message

--no commit message
上级 7365295e
...@@ -35,7 +35,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -35,7 +35,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3> <h3>Version 1.0 (Current)</h3>
<h3>Version 1.0 / 2007-TODO</h3><ul> <h3>Version 1.0 / 2007-TODO</h3><ul>
<li> <li>It was possible to drop the sequence of a temporary tables with DROP ALL OBJECTS, resulting in a null pointer exception afterwards.
<li>Prepard statements with non-constant functions such as CURRENT_TIMESTAMP() did not get re-evaluated if the result of the function changed. Fixed.
<li>The (relative or absolute) directory where the script files are stored or read can now be changed using the system property h2.scriptDirectory <li>The (relative or absolute) directory where the script files are stored or read can now be changed using the system property h2.scriptDirectory
<li>Client trace files now created in the directory 'trace.db' and no longer the application directory. <li>Client trace files now created in the directory 'trace.db' and no longer the application directory.
This can be changed using the system property h2.clientTraceDirectory. This can be changed using the system property h2.clientTraceDirectory.
......
...@@ -111,7 +111,7 @@ public class CreateTable extends SchemaCommand { ...@@ -111,7 +111,7 @@ public class CreateTable extends SchemaCommand {
Column c = (Column) columns.get(i); Column c = (Column) columns.get(i);
if(c.getAutoIncrement()) { if(c.getAutoIncrement()) {
int objId = getObjectId(true, true); int objId = getObjectId(true, true);
c.convertAutoIncrementToSequence(session, getSchema(), objId); c.convertAutoIncrementToSequence(session, getSchema(), objId, temporary);
} }
Sequence seq = c.getSequence(); Sequence seq = c.getSequence();
if(seq != null) { if(seq != null) {
......
...@@ -66,6 +66,7 @@ public class DropDatabase extends DefineCommand { ...@@ -66,6 +66,7 @@ public class DropDatabase extends DefineCommand {
db.removeSchemaObject(session, t); db.removeSchemaObject(session, t);
} }
} }
session.findLocalTempTable(null);
list = db.getAllSchemaObjects(DbObject.SEQUENCE); list = db.getAllSchemaObjects(DbObject.SEQUENCE);
// maybe constraints and triggers on system tables will be allowed in the future // maybe constraints and triggers on system tables will be allowed in the future
list.addAll(db.getAllSchemaObjects(DbObject.CONSTRAINT)); list.addAll(db.getAllSchemaObjects(DbObject.CONSTRAINT));
......
...@@ -1398,6 +1398,9 @@ public class Function extends Expression implements FunctionCall { ...@@ -1398,6 +1398,9 @@ public class Function extends Expression implements FunctionCall {
} }
public boolean isEverything(ExpressionVisitor visitor) { public boolean isEverything(ExpressionVisitor visitor) {
if(visitor.type == ExpressionVisitor.DETERMINISTIC && !info.isDeterministic) {
return false;
}
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
Expression e = args[i]; Expression e = args[i];
if (e != null && !e.isEverything(visitor)) { if (e != null && !e.isEverything(visitor)) {
......
...@@ -74,7 +74,7 @@ public class Sequence extends SchemaObject { ...@@ -74,7 +74,7 @@ public class Sequence extends SchemaObject {
value += increment; value += increment;
return v; return v;
} }
public void flush() throws SQLException { public void flush() throws SQLException {
// can not use the session, because it must be committed immediately // can not use the session, because it must be committed immediately
// otherwise other threads can not access the sys table. // otherwise other threads can not access the sys table.
......
...@@ -208,7 +208,7 @@ public class Column { ...@@ -208,7 +208,7 @@ public class Column {
} }
} }
public void convertAutoIncrementToSequence(Session session, Schema schema, int id) throws SQLException { public void convertAutoIncrementToSequence(Session session, Schema schema, int id, boolean temporary) throws SQLException {
if(!getAutoIncrement()) { if(!getAutoIncrement()) {
throw Message.getInternalError(); throw Message.getInternalError();
} }
...@@ -225,7 +225,9 @@ public class Column { ...@@ -225,7 +225,9 @@ public class Column {
Sequence sequence = new Sequence(schema, id, sequenceName, true); Sequence sequence = new Sequence(schema, id, sequenceName, true);
sequence.setStartValue(start); sequence.setStartValue(start);
sequence.setIncrement(increment); sequence.setIncrement(increment);
session.getDatabase().addSchemaObject(session, sequence); if(!temporary) {
session.getDatabase().addSchemaObject(session, sequence);
}
setAutoIncrement(false, 0, 0); setAutoIncrement(false, 0, 0);
SequenceValue seq = new SequenceValue(sequence); SequenceValue seq = new SequenceValue(sequence);
setDefaultExpression(session, seq); setDefaultExpression(session, seq);
......
...@@ -144,7 +144,9 @@ public abstract class Table extends SchemaObject { ...@@ -144,7 +144,9 @@ public abstract class Table extends SchemaObject {
while(sequences != null && sequences.size() > 0) { while(sequences != null && sequences.size() > 0) {
Sequence sequence = (Sequence)sequences.get(0); Sequence sequence = (Sequence)sequences.get(0);
sequences.remove(0); sequences.remove(0);
database.removeSchemaObject(session, sequence); if(!getTemporary()) {
database.removeSchemaObject(session, sequence);
}
} }
ObjectArray rights = database.getAllRights(); ObjectArray rights = database.getAllRights();
for(int i=0; i<rights.size(); i++) { for(int i=0; i<rights.size(); i++) {
......
...@@ -87,18 +87,9 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -87,18 +87,9 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
TestAll test = new TestAll(); TestAll test = new TestAll();
test.printSystem(); test.printSystem();
// here is a difference in behavior between the 9-24-2006 H2.jar and the later jars. // Expression.isConstant is not really needed?
// Or it simply could be I didn't see a feature change in the docs.
// In my code, this statement in 9-24 works: // test: use fixed amount of disk space
// SELECT ID FROM EVE_ALARMS WHERE TIME_ESCALATE = true AND ACTIVE = true AND current_timestamp() > NEXT_TIME_ESCALATION
// in latest versions, the query returns zero rows.
// Most of my queries are preparedStatements that are prepared once at process startup.
// Things I have tested:
// 1. Run the query in the H2 console. SUCCESS
// 2. Generate a preparedStatement each time it is needed. SUCCESS
// 3. Generate a preparedStatement, save the statement to a instance variable for reuse. FAIL
// There are several queries that use current_timestamp, but I think the cache is saving the original time value, ie not recalculating. This may be because there are no parameters set in the statement. The other queries that use current_timestamp have parameters that must be set, which I thinking causes the time value to be recalculated.
// I will try and put together a simple test case this week. Unless this a configuration issue and I need to RTFM. :)
// append errors from all programs atomically to errors.txt (use nio file lock mechanism) // append errors from all programs atomically to errors.txt (use nio file lock mechanism)
// ftp client // ftp client
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
package org.h2.test; package org.h2.test;
import java.io.File; import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.Reader; import java.io.Reader;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
...@@ -17,6 +19,8 @@ import java.text.SimpleDateFormat; ...@@ -17,6 +19,8 @@ import java.text.SimpleDateFormat;
import java.util.Properties; import java.util.Properties;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.TraceSystem;
import org.h2.store.FileLock;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
/** /**
...@@ -55,8 +59,7 @@ public abstract class TestBase { ...@@ -55,8 +59,7 @@ public abstract class TestBase {
test(); test();
println("done "); println("done ");
} catch(Exception e) { } catch(Exception e) {
println("FAIL " + e.toString()); fail("FAIL " + e.toString(), e);
e.printStackTrace();
if(config.stopOnError) { if(config.stopOnError) {
throw new Error("ERROR"); throw new Error("ERROR");
} }
...@@ -206,6 +209,32 @@ public abstract class TestBase { ...@@ -206,6 +209,32 @@ public abstract class TestBase {
throw new Exception(string); throw new Exception(string);
} }
protected void fail(String s, Throwable e) {
println(s);
logError(s, e);
}
public static void logError(String s, Throwable e) {
if(e==null) {
e = new Exception(s);
}
System.out.println("ERROR: " + s + " " + e.toString() + " ------------------------------");
e.printStackTrace();
try {
TraceSystem ts = new TraceSystem(null);
FileLock lock = new FileLock(ts, 1000);
lock.lock("error.lock", false);
FileWriter fw = new FileWriter("ERROR.txt", true);
PrintWriter pw = new PrintWriter(fw);
e.printStackTrace(pw);
pw.close();
fw.close();
lock.unlock();
} catch(Throwable t) {
t.printStackTrace();
}
}
protected void println(String s) { protected void println(String s) {
printlnWithTime(s); printlnWithTime(s);
} }
...@@ -520,8 +549,7 @@ public abstract class TestBase { ...@@ -520,8 +549,7 @@ public abstract class TestBase {
protected void checkNotGeneralException(SQLException e) throws Exception { protected void checkNotGeneralException(SQLException e) throws Exception {
if(e!=null && e.getSQLState().startsWith("HY000")) { if(e!=null && e.getSQLState().startsWith("HY000")) {
e.printStackTrace(); TestBase.logError("Unexpected General error", e);
error("Unexpected General error: " + e.toString());
} }
} }
......
...@@ -253,7 +253,7 @@ class Database { ...@@ -253,7 +253,7 @@ class Database {
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
// time = System.currentTimeMillis() - time; // time = System.currentTimeMillis() - time;
// if(time > 100) { // if(time > 100) {
// new Error("time="+time).printStackTrace(); // System.out.println("time="+time);
// } // }
executedStatements++; executedStatements++;
return rs; return rs;
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
*/ */
package org.h2.test.cases; package org.h2.test.cases;
import java.sql.*; import java.sql.Connection;
import java.util.Random; import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/* /*
del *.db del *.db
...@@ -15,41 +17,16 @@ java org.h2.test.cases.TestConnect ...@@ -15,41 +17,16 @@ java org.h2.test.cases.TestConnect
public class TestConnect { public class TestConnect {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
long time = System.currentTimeMillis(); String url = "jdbc:h2:test";
String url = "jdbc:h2:test;LOG=2;STORAGE=TEXT;DATABASE_EVENT_LISTENER='org.h2.samples.ShowProgress'";
Connection conn = DriverManager.getConnection(url, "sa", "sa"); Connection conn = DriverManager.getConnection(url, "sa", "sa");
time = System.currentTimeMillis() - time; PreparedStatement prep = conn.prepareStatement("SELECT CURRENT_TIMESTAMP()");
System.out.println("connected in " + time); ResultSet rs = prep.executeQuery();
ResultSet rs = conn.getMetaData().getTables(null, null, "TEST", null); rs.next();
Random random = new Random(1); System.out.println(rs.getString(1));
if(!rs.next()) { Thread.sleep(50);
conn.createStatement().execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)"); rs = prep.executeQuery();
rs.next();
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(NAME) VALUES(space(2000))"); System.out.println(rs.getString(1));
// PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(NAME) VALUES(space(20000))");
int len = 5000;
for(int i=0; i<len; i++) {
long t2 = System.currentTimeMillis();
if(t2 - time > 1000) {
System.out.println("Inserting " + i + " of " + len);
time = t2;
}
prep.executeUpdate();
}
prep = conn.prepareStatement("UPDATE TEST SET NAME = space(2000) WHERE ID=?");
for(int i=0; i<len; i++) {
long t2 = System.currentTimeMillis();
if(t2 - time > 1000) {
System.out.println("Updating " + i + " of " + len);
time = t2;
}
prep.setInt(1, random.nextInt(len));
prep.executeUpdate();
}
// @LOOP 50000 UPDATE TEST SET NAME=space(20000) WHERE ID=?/*RND*/;
Thread.sleep(2000);
Runtime.getRuntime().halt(0);
}
conn.close(); conn.close();
} }
......
...@@ -92,7 +92,7 @@ public class TestBigDb extends TestBase { ...@@ -92,7 +92,7 @@ public class TestBigDb extends TestBase {
} }
} }
} catch(OutOfMemoryError e) { } catch(OutOfMemoryError e) {
e.printStackTrace(); TestBase.logError("memory", e);
conn.close(); conn.close();
throw e; throw e;
} }
......
...@@ -153,7 +153,7 @@ public class TestCases extends TestBase { ...@@ -153,7 +153,7 @@ public class TestCases extends TestBase {
try { try {
ResultSet rs = stat.executeQuery("SELECT MAX(T.ID) FROM TEST T, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST"); ResultSet rs = stat.executeQuery("SELECT MAX(T.ID) FROM TEST T, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST");
rs.next(); rs.next();
new Error("query was too quick; result: " + rs.getInt(1)).printStackTrace(); TestBase.logError("query was too quick; result: " + rs.getInt(1), null);
} catch(SQLException e) { } catch(SQLException e) {
// ok // ok
} }
......
...@@ -96,8 +96,8 @@ public class TestCsv extends TestBase { ...@@ -96,8 +96,8 @@ public class TestCsv extends TestBase {
for(int i=0; i<len; i++) { for(int i=0; i<len; i++) {
stat.execute("INSERT INTO TEST(NAME) VALUES('Ruebezahl')"); stat.execute("INSERT INTO TEST(NAME) VALUES('Ruebezahl')");
} }
Csv.getInstance().write(conn, BASE_DIR + "/test.csv", "SELECT * FROM TEST", "UTF8"); Csv.getInstance().write(conn, BASE_DIR + "/testRW.csv", "SELECT * FROM TEST", "UTF8");
ResultSet rs = Csv.getInstance().read(BASE_DIR + "/test.csv", null, "UTF8"); ResultSet rs = Csv.getInstance().read(BASE_DIR + "/testRW.csv", null, "UTF8");
// stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\""); // stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\"");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
check(2, meta.getColumnCount()); check(2, meta.getColumnCount());
...@@ -107,6 +107,7 @@ public class TestCsv extends TestBase { ...@@ -107,6 +107,7 @@ public class TestCsv extends TestBase {
check(rs.getString("NAME"), "Ruebezahl"); check(rs.getString("NAME"), "Ruebezahl");
} }
checkFalse(rs.next()); checkFalse(rs.next());
rs.close();
conn.close(); conn.close();
} }
......
...@@ -229,7 +229,7 @@ public class TestFunctions extends TestBase { ...@@ -229,7 +229,7 @@ public class TestFunctions extends TestBase {
public static int root(int value) { public static int root(int value) {
if (value < 0) { if (value < 0) {
new Exception("function called but should not").printStackTrace(); TestBase.logError("function called but should not", null);
} }
return (int) Math.sqrt(value); return (int) Math.sqrt(value);
} }
......
...@@ -47,7 +47,7 @@ public class TestListener extends TestBase implements DatabaseEventListener { ...@@ -47,7 +47,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
} }
public void exceptionThrown(SQLException e) { public void exceptionThrown(SQLException e) {
e.printStackTrace(); TestBase.logError("exceptionThrown", e);
} }
public void setProgress(int state, String name, int current, int max) { public void setProgress(int state, String name, int current, int max) {
...@@ -68,7 +68,7 @@ public class TestListener extends TestBase implements DatabaseEventListener { ...@@ -68,7 +68,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
stateName = "Recover"; stateName = "Recover";
break; break;
default: default:
new Error("unknownn state: " + state).printStackTrace(); TestBase.logError("unknownn state: " + state, null);
stateName = "? " + name; stateName = "? " + name;
} }
try { try {
......
...@@ -52,7 +52,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -52,7 +52,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
s3.execute("INSERT INTO TEST2 VALUES(4)"); s3.execute("INSERT INTO TEST2 VALUES(4)");
conn3.commit(); conn3.commit();
} catch(SQLException e) { } catch(SQLException e) {
e.printStackTrace(); TestBase.logError("insert", e);
} }
} }
}); });
...@@ -64,7 +64,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -64,7 +64,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
s2.execute("INSERT INTO TEST1 VALUES(5)"); s2.execute("INSERT INTO TEST1 VALUES(5)");
conn2.commit(); conn2.commit();
} catch(SQLException e) { } catch(SQLException e) {
e.printStackTrace(); TestBase.logError("insert", e);
} }
} }
}); });
...@@ -101,7 +101,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -101,7 +101,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
Connection c1 = getConnection("multiConn;DATABASE_EVENT_LISTENER='"+listener+"';file_lock=socket"); Connection c1 = getConnection("multiConn;DATABASE_EVENT_LISTENER='"+listener+"';file_lock=socket");
c1.close(); c1.close();
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); TestBase.logError("connect", e);
} }
} }
}; };
...@@ -126,7 +126,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -126,7 +126,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
Thread.sleep(wait); Thread.sleep(wait);
wait = 0; wait = 0;
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); TestBase.logError("sleep", e);
} }
} }
} }
......
...@@ -78,8 +78,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -78,8 +78,7 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
conn.close(); conn.close();
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); logError("multi", e);
System.exit(0);
} }
} }
......
...@@ -76,8 +76,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -76,8 +76,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
prep.execute(); prep.execute();
conn.close(); conn.close();
} catch(Throwable e) { } catch(Throwable e) {
// e.printStackTrace(); TestBase.logError("insert", e);
System.out.println("FAIL: " + e.toString());
} }
} }
}; };
......
...@@ -21,6 +21,7 @@ public class TestOptimizations extends TestBase { ...@@ -21,6 +21,7 @@ public class TestOptimizations extends TestBase {
if(config.networked) { if(config.networked) {
return; return;
} }
testQueryCacheTimestamp();
testQueryCacheSpeed(); testQueryCacheSpeed();
testQueryCache(true); testQueryCache(true);
testQueryCache(false); testQueryCache(false);
...@@ -29,6 +30,21 @@ public class TestOptimizations extends TestBase { ...@@ -29,6 +30,21 @@ public class TestOptimizations extends TestBase {
testMinMaxCountOptimization(false); testMinMaxCountOptimization(false);
} }
private void testQueryCacheTimestamp() throws Exception {
deleteDb("optimizations");
Connection conn=getConnection("optimizations");
PreparedStatement prep = conn.prepareStatement("SELECT CURRENT_TIMESTAMP()");
ResultSet rs = prep.executeQuery();
rs.next();
String a = rs.getString(1);
Thread.sleep(50);
rs = prep.executeQuery();
rs.next();
String b = rs.getString(1);
checkFalse(a.equals(b));
conn.close();
}
private void testQueryCacheSpeed() throws Exception { private void testQueryCacheSpeed() throws Exception {
deleteDb("optimizations"); deleteDb("optimizations");
Connection conn=getConnection("optimizations"); Connection conn=getConnection("optimizations");
......
...@@ -77,7 +77,7 @@ public class TestPowerOff extends TestBase { ...@@ -77,7 +77,7 @@ public class TestPowerOff extends TestBase {
conn.close(); conn.close();
} catch(SQLException e) { } catch(SQLException e) {
if(!e.getSQLState().equals("90098")) { if(!e.getSQLState().equals("90098")) {
e.printStackTrace(); TestBase.logError("power", e);
} }
} }
} }
...@@ -228,8 +228,6 @@ public class TestPowerOff extends TestBase { ...@@ -228,8 +228,6 @@ public class TestPowerOff extends TestBase {
} else { } else {
throw e; throw e;
} }
//log("error="+e);
// e.printStackTrace();
} }
return state; return state;
} }
......
...@@ -325,11 +325,11 @@ public class TestScript extends TestBase { ...@@ -325,11 +325,11 @@ public class TestScript extends TestBase {
errors.append("\ngot: "); errors.append("\ngot: ");
errors.append(s); errors.append(s);
errors.append("\n"); errors.append("\n");
if(e!=null) { if(e != null) {
e.printStackTrace(); TestBase.logError("script", e);
} }
if(failFast) { if(failFast) {
new Exception(errors.toString()).printStackTrace(); TestBase.logError(errors.toString(), null);
conn.close(); conn.close();
System.exit(1); System.exit(1);
} }
......
command=cmd /c "del /s /q /f *.* 2> nul | rmdir /s /q data dataCrash dataIndex dataJoin dataScript dataSynth trace.db org 2> nul" command=cmd /c "del /s /q /f *.* 2> nul | rmdir /s /q data dataCrash dataIndex dataJoin dataScript dataSynth trace.db org 2> nul | rmdir /s /q data 2> nul"
\ No newline at end of file \ No newline at end of file
...@@ -29,7 +29,7 @@ public class TestCancel extends TestBase { ...@@ -29,7 +29,7 @@ public class TestCancel extends TestBase {
} catch (SQLException e) { } catch (SQLException e) {
// ignore errors on closed statements // ignore errors on closed statements
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); TestBase.logError("sleep", e);
} }
} }
} }
......
...@@ -9,6 +9,8 @@ import java.io.StringWriter; ...@@ -9,6 +9,8 @@ import java.io.StringWriter;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import org.h2.test.TestBase;
class Result implements Comparable { class Result implements Comparable {
static final int SUCCESS=0, BOOLEAN=1, INT=2, EXCEPTION=3, RESULTSET=4; static final int SUCCESS=0, BOOLEAN=1, INT=2, EXCEPTION=3, RESULTSET=4;
private int type; private int type;
...@@ -62,8 +64,7 @@ class Result implements Comparable { ...@@ -62,8 +64,7 @@ class Result implements Comparable {
} catch(SQLException e) { } catch(SQLException e) {
// type = EXCEPTION; // type = EXCEPTION;
// exception = e; // exception = e;
e.printStackTrace(); TestBase.logError("error reading result set", e);
throw new Error("error reading result set");
} }
} }
......
...@@ -70,7 +70,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -70,7 +70,7 @@ public class TestBtreeIndex extends TestBase {
if(e.getSQLState().equals("23001")) { if(e.getSQLState().equals("23001")) {
// ignore // ignore
} else { } else {
e.printStackTrace(); TestBase.logError("error", e);
break; break;
} }
} }
...@@ -85,7 +85,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -85,7 +85,7 @@ public class TestBtreeIndex extends TestBase {
} }
count -= deleted; count -= deleted;
} catch(SQLException e) { } catch(SQLException e) {
e.printStackTrace(); TestBase.logError("error", e);
break; break;
} }
} else { } else {
...@@ -98,7 +98,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -98,7 +98,7 @@ public class TestBtreeIndex extends TestBase {
} }
count -= deleted; count -= deleted;
} catch(SQLException e) { } catch(SQLException e) {
e.printStackTrace(); TestBase.logError("error", e);
break; break;
} }
} }
......
...@@ -202,8 +202,7 @@ public class TestCrashAPI extends TestBase { ...@@ -202,8 +202,7 @@ public class TestCrashAPI extends TestBase {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
t.printStackTrace(new PrintWriter(writer)); t.printStackTrace(new PrintWriter(writer));
String s = writer.toString(); String s = writer.toString();
System.out.println("new TestCrashAPI().init(test).testCase("+seed+"); // Bug " + s.hashCode()+" seed="+seed+" id=" + id + " callCount=" + callCount+" openCount="+openCount + " " + t.getMessage()); TestBase.logError("new TestCrashAPI().init(test).testCase("+seed+"); // Bug " + s.hashCode()+" seed="+seed+" id=" + id + " callCount=" + callCount+" openCount="+openCount + " " + t.getMessage(), t);
t.printStackTrace();
} }
private Object callRandom(int seed, int id, int objectId, Object o, Method m) throws Exception { private Object callRandom(int seed, int id, int objectId, Object o, Method m) throws Exception {
...@@ -217,9 +216,9 @@ public class TestCrashAPI extends TestBase { ...@@ -217,9 +216,9 @@ public class TestCrashAPI extends TestBase {
callCount++; callCount++;
result = m.invoke(o, params); result = m.invoke(o, params);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); TestBase.logError("error", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); TestBase.logError("error", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Throwable t = e.getTargetException(); Throwable t = e.getTargetException();
printIfBad(seed, id, objectId, t); printIfBad(seed, id, objectId, t);
......
...@@ -246,7 +246,6 @@ public class TestJoin extends TestBase { ...@@ -246,7 +246,6 @@ public class TestJoin extends TestBase {
s = "updateCount: " + stat.getUpdateCount(); s = "updateCount: " + stat.getUpdateCount();
} }
} catch(SQLException e) { } catch(SQLException e) {
// e.printStackTrace();
s = "exception"; s = "exception";
} }
if(i==0) { if(i==0) {
......
...@@ -10,6 +10,7 @@ import java.sql.PreparedStatement; ...@@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import org.h2.test.TestBase;
import org.h2.tools.FileBase; import org.h2.tools.FileBase;
public class TestKillProcess { public class TestKillProcess {
...@@ -58,7 +59,7 @@ public class TestKillProcess { ...@@ -58,7 +59,7 @@ public class TestKillProcess {
} }
} }
} catch(Throwable e) { } catch(Throwable e) {
e.printStackTrace(); TestBase.logError("error", e);
} }
} }
......
...@@ -7,6 +7,8 @@ package org.h2.test.synth; ...@@ -7,6 +7,8 @@ package org.h2.test.synth;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Random; import java.util.Random;
import org.h2.test.TestBase;
abstract class TestMultiThread extends Thread { abstract class TestMultiThread extends Thread {
TestMulti base; TestMulti base;
...@@ -29,8 +31,7 @@ abstract class TestMultiThread extends Thread { ...@@ -29,8 +31,7 @@ abstract class TestMultiThread extends Thread {
} }
end(); end();
} catch(Throwable e) { } catch(Throwable e) {
e.printStackTrace(); TestBase.logError("error", e);
System.out.println("FAIL: " + e.toString());
} }
} }
......
...@@ -27,10 +27,8 @@ public class TestRandomSQL extends TestBase { ...@@ -27,10 +27,8 @@ public class TestRandomSQL extends TestBase {
private void processException(String sql, SQLException e) { private void processException(String sql, SQLException e) {
if(e.getSQLState().equals("HY000")) { if(e.getSQLState().equals("HY000")) {
System.out.println("new TestRandomSQL().init(test).testCase("+seed+"); // FAIL: " + e.toString()); TestBase.logError("new TestRandomSQL().init(test).testCase("+seed+"); // FAIL: " + e.toString(), e);
e.printStackTrace();
if(exitOnError) { if(exitOnError) {
new Error(sql, e).printStackTrace();
System.exit(0); System.exit(0);
} }
} }
......
...@@ -103,7 +103,7 @@ public class TestSynth extends TestBase { ...@@ -103,7 +103,7 @@ public class TestSynth extends TestBase {
add(Command.getCreateTable(this, table)); add(Command.getCreateTable(this, table));
add(Command.getCreateIndex(this, table.newRandomIndex())); add(Command.getCreateIndex(this, table.newRandomIndex()));
} }
for(int i=0; i<400; i++) { for(int i=0; i<2000; i++) {
addRandomCommands(); addRandomCommands();
} }
// for (int i = 0; i < 20; i++) { // for (int i = 0; i < 20; i++) {
...@@ -165,7 +165,7 @@ public class TestSynth extends TestBase { ...@@ -165,7 +165,7 @@ public class TestSynth extends TestBase {
} catch(Error e) { } catch(Error e) {
if(showError) { if(showError) {
e.printStackTrace(); TestBase.logError("synth", e);
} }
System.out.println("new TestSynth().init(test).testCase(" + seed+"); // id="+id +" " + e.toString()); System.out.println("new TestSynth().init(test).testCase(" + seed+"); // id="+id +" " + e.toString());
if(stopImmediately) { if(stopImmediately) {
...@@ -262,8 +262,7 @@ public class TestSynth extends TestBase { ...@@ -262,8 +262,7 @@ public class TestSynth extends TestBase {
printTime("TestSynth " + i); printTime("TestSynth " + i);
testRun(i); testRun(i);
} catch (Error e) { } catch (Error e) {
System.out.println(e.toString()); TestBase.logError("error", e);
e.printStackTrace();
System.exit(0); System.exit(0);
} }
BASE_DIR = "data"; BASE_DIR = "data";
......
...@@ -145,7 +145,7 @@ public class TestThreads extends TestBase implements Runnable { ...@@ -145,7 +145,7 @@ public class TestThreads extends TestBase implements Runnable {
} }
conn.close(); conn.close();
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); TestBase.logError("error", e);
} }
} }
......
...@@ -103,7 +103,7 @@ public class TestExit extends TestBase implements DatabaseEventListener { ...@@ -103,7 +103,7 @@ public class TestExit extends TestBase implements DatabaseEventListener {
try { try {
getClosedFile().createNewFile(); getClosedFile().createNewFile();
} catch(IOException e) { } catch(IOException e) {
e.printStackTrace(); TestBase.logError("error", e);
} }
} }
......
...@@ -96,7 +96,6 @@ public class TestFileLock extends TestBase implements Runnable { ...@@ -96,7 +96,6 @@ public class TestFileLock extends TestBase implements Runnable {
} }
} catch (Exception e) { } catch (Exception e) {
// log(id+" cannot lock: " + e); // log(id+" cannot lock: " + e);
// e.printStackTrace();
} }
try { try {
Thread.sleep(wait + (int) (Math.random() * wait)); Thread.sleep(wait + (int) (Math.random() * wait));
......
...@@ -49,8 +49,7 @@ public class TestSampleApps extends TestBase { ...@@ -49,8 +49,7 @@ public class TestSampleApps extends TestBase {
try { try {
m.invoke(null, new Object[]{args}); m.invoke(null, new Object[]{args});
} catch(Throwable e) { } catch(Throwable e) {
System.out.print("EXCEPTION"); TestBase.logError("error", e);
e.printStackTrace();
} }
out.flush(); out.flush();
System.setOut(oldOut); System.setOut(oldOut);
......
...@@ -68,7 +68,7 @@ public class TestStringCache extends TestBase { ...@@ -68,7 +68,7 @@ public class TestStringCache extends TestBase {
try { try {
check(a, b); check(a, b);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); TestBase.logError("error", e);
} }
if(a != null && a == b && a.length()>0) { if(a != null && a == b && a.length()>0) {
throw new Error("a=" + System.identityHashCode(a) + " b=" + System.identityHashCode(b)); throw new Error("a=" + System.identityHashCode(a) + " b=" + System.identityHashCode(b));
...@@ -83,7 +83,7 @@ public class TestStringCache extends TestBase { ...@@ -83,7 +83,7 @@ public class TestStringCache extends TestBase {
try { try {
check(a, b); check(a, b);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); TestBase.logError("error", e);
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论