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

--no commit message

--no commit message
上级 476b0169
......@@ -35,6 +35,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3>
<h3>Version 1.0 / TODO</h3><ul>
<li>Selecting a column using the syntax schemaName.tableName.columName did not work in all cases.
<li>Can now parse timestamps with timezone information (Z or +/-hh:mm) and dates before year 1.
However dates before year 1 are not formatted correctly (this is a Java problem).
<li>When stopping the TCP server from an application and immediately afterwards staring it again
......
......@@ -11,23 +11,24 @@ package org.h2.engine;
* - System.out > trace messages
*
* Release checklist
* - Run FindBugs
* - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - ant jarClient, check jar file size
* - try compiling with JDK 1.3, 1.4, 1.5 and 1.6
* - Compiling with JDK 1.3, 1.4, 1.5 and 1.6
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* - change FAQ (next release planned, known bugs)
* - check version, change build number in Constants.java and build.xml
* - check code coverage
* - Change FAQ (next release planned, known bugs)
* - Check version, change build number in Constants.java and build.xml
* - Check code coverage
* - No " Message.getInternalError" (must be "throw Message.getInternalError")
* - No TODO in the docs
* - Run regression test with JDK 1.4 and 1.5
* - Change version(s) in performance.html; use latest versions of other databases
* - Run 'ant benchmark' (with JDK 1.4 currently)
* - copy the benchmark results and update the performance page and diagram
* - Copy the benchmark results and update the performance page and diagram
* (remove rows 2*open/close, 2*executed statement)
*
* - documentation: if there are new files, add them to MergeDocs
* - documentation: check if all javadoc files are in the index
* - Documentation: if there are new files, add them to MergeDocs
* - Documentation: check if all javadoc files are in the index
* - ant docs
* - PDF (15 min)
* - footer
......@@ -35,18 +36,18 @@ package org.h2.engine;
* - tables (optimal size)
* - orphan control, page breaks
* - table of contents
* - switch off auto-build
* - Switch off auto-build
* - ant all
* - make sure odbc files are the
* - make sure the pdf file is there
* - make sure the build files are removed
* - Make sure odbc files are the
* - Make sure the pdf file is there
* - Make sure the build files are removed
* - ant zip
* - windows installer (nsis)
* - test
* - test the windows service
* - Windows installer (nsis)
* - Test
* - Test the windows service
* - TestSystemExit
* - test with hibernate
* - scan for viruses
* - Test with hibernate
* - Scan for viruses
*
* - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!)
......@@ -185,7 +186,7 @@ public class Constants {
public static final int ALLOW_LITERALS_ALL = 2;
public static final int DEFAULT_ALLOW_LITERALS = ALLOW_LITERALS_ALL;
public static boolean AUTO_CONVERT_LOB_TO_FILES = true;
public static final boolean AUTO_CONVERT_LOB_TO_FILES = true;
public static final boolean ALLOW_EMTPY_BTREE_PAGES = true;
public static final String CONN_URL_INTERNAL = "jdbc:default:connection";
public static final String CONN_URL_COLUMNLIST = "jdbc:columnlist:connection";
......@@ -205,28 +206,28 @@ public class Constants {
// for testing only
public static int CACHE_MIN_RECORDS = 16;
public static int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5);
public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5);
public static boolean CHECK = getBooleanSetting("h2.check", true);
public static boolean CHECK2 = getBooleanSetting("h2.check2", false);
public static final boolean CHECK2 = getBooleanSetting("h2.check2", false);
// TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
public static boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", false);
public static int LOB_FILES_PER_DIRECTORY = getIntSetting("h2.lobFilesPerDirectory", 256);
public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", false);
public static final int LOB_FILES_PER_DIRECTORY = getIntSetting("h2.lobFilesPerDirectory", 256);
public static boolean MULTI_THREADED_KERNEL = getBooleanSetting("h2.multiThreadedKernel", false);
public static boolean RUN_FINALIZERS = getBooleanSetting("h2.runFinalizers", true);
public static boolean OPTIMIZE_MIN_MAX = getBooleanSetting("h2.optimizeMinMax", true);
public static boolean OPTIMIZE_IN = getBooleanSetting("h2.optimizeIn", true);
public static int REDO_BUFFER_SIZE = getIntSetting("h2.redoBufferSize", 256 * 1024);
public static boolean RECOMPILE_ALWAYS = getBooleanSetting("h2.recompileAlways", false);
public static boolean OPTIMIZE_SUBQUERY_CACHE = getBooleanSetting("h2.optimizeSubqueryCache", true);
public static boolean OVERFLOW_EXCEPTIONS = getBooleanSetting("h2.overflowExceptions", true);
public static boolean LOG_ALL_ERRORS = getBooleanSetting("h2.logAllErrors", false);
public static String LOG_ALL_ERRORS_FILE = getStringSetting("h2.logAllErrorsFile", "h2errors.txt");
public static int SERVER_CACHED_OBJECTS = getIntSetting("h2.serverCachedObjects", 64);
public static final boolean OPTIMIZE_MIN_MAX = getBooleanSetting("h2.optimizeMinMax", true);
public static final boolean OPTIMIZE_IN = getBooleanSetting("h2.optimizeIn", true);
public static final int REDO_BUFFER_SIZE = getIntSetting("h2.redoBufferSize", 256 * 1024);
public static final boolean RECOMPILE_ALWAYS = getBooleanSetting("h2.recompileAlways", false);
public static final boolean OPTIMIZE_SUBQUERY_CACHE = getBooleanSetting("h2.optimizeSubqueryCache", true);
public static final boolean OVERFLOW_EXCEPTIONS = getBooleanSetting("h2.overflowExceptions", true);
public static final boolean LOG_ALL_ERRORS = getBooleanSetting("h2.logAllErrors", false);
public static final String LOG_ALL_ERRORS_FILE = getStringSetting("h2.logAllErrorsFile", "h2errors.txt");
public static final int SERVER_CACHED_OBJECTS = getIntSetting("h2.serverCachedObjects", 64);
public static final int SERVER_SMALL_RESULTSET_SIZE = getIntSetting("h2.serverSmallResultSetSize", 100);
public static final int EMERGENCY_SPACE_INITIAL = getIntSetting("h2.emergencySpaceInitial", 1 * 1024 * 1024);
public static final int EMERGENCY_SPACE_MIN = getIntSetting("h2.emergencySpaceMin", 128 * 1024);
......
......@@ -1314,7 +1314,7 @@ public class Database implements DataHandler {
return lockMode;
}
public void setCloseDelay(int value) {
public synchronized void setCloseDelay(int value) {
this.closeDelay = value;
}
......@@ -1416,7 +1416,7 @@ public class Database implements DataHandler {
return ignoreCase;
}
public void setDeleteFilesOnDisconnect(boolean b) {
public synchronized void setDeleteFilesOnDisconnect(boolean b) {
this.deleteFilesOnDisconnect = b;
}
......
......@@ -9,6 +9,7 @@ import java.util.HashMap;
import org.h2.command.Parser;
import org.h2.command.dml.Select;
import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.message.Message;
......@@ -44,6 +45,7 @@ public class ExpressionColumn extends Expression {
public ExpressionColumn(Database database, Select select, String schemaName, String tableAlias, String columnName) {
this.database = database;
this.select = select;
this.schemaName = schemaName;
this.tableAlias = tableAlias;
this.columnName = columnName;
}
......@@ -58,7 +60,8 @@ public class ExpressionColumn extends Expression {
if(tableAlias != null) {
sql = Parser.quoteIdentifier(tableAlias) + "." + sql;
}
if(schemaName != null) {
if(schemaName != null && !schemaName.equals(Constants.SCHEMA_MAIN)) {
int todoTempSolution;
sql = Parser.quoteIdentifier(schemaName) + "." + sql;
}
return sql;
......
......@@ -38,7 +38,7 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
private static final long serialVersionUID = 1288136338451857771L;
private transient JdbcDataSourceFactory factory;
private transient JdbcDataSourceFactory factory = new JdbcDataSourceFactory();
private transient PrintWriter logWriter;
private int timeout;
private String user;
......@@ -46,7 +46,6 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
private String url;
public JdbcDataSource() {
this.factory = new JdbcDataSourceFactory();
int id = getNextId(TraceObject.DATASOURCE);
setTrace(factory.getTrace(), TraceObject.DATASOURCE, id);
}
......
......@@ -109,7 +109,7 @@ public class Sequence extends SchemaObject {
// nothing to do
}
public long getCurrentValue() {
public synchronized long getCurrentValue() {
return value - increment;
}
......
......@@ -18,6 +18,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.h2.command.Parser;
import org.h2.engine.Constants;
......@@ -303,13 +305,14 @@ public class Recover implements DataHandler {
FileStore store = null;
int size = 0;
String n = fileName + (lobCompression ? ".comp" : "") + ".txt";
InputStream in = null;
try {
out = new FileOutputStream(n);
textStorage = Database.isTextStorage(fileName, false);
byte[] magic = Database.getMagic(textStorage);
store = FileStore.open(null, fileName, magic);
store.init();
InputStream in = new BufferedInputStream(new FileStoreInputStream(store, this, lobCompression));
in = new BufferedInputStream(new FileStoreInputStream(store, this, lobCompression));
byte[] buffer = new byte[Constants.IO_BUFFER_SIZE];
while(true) {
int l = in.read(buffer);
......@@ -326,6 +329,7 @@ public class Recover implements DataHandler {
}
} finally {
IOUtils.closeSilently(out);
IOUtils.closeSilently(in);
closeSilently(store);
}
if(size == 0) {
......@@ -714,8 +718,9 @@ public class Recover implements DataHandler {
writer.println(m.getSQL() + ";");
}
for(Iterator it = tableMap.keySet().iterator(); it.hasNext(); ) {
Integer objectId = (Integer) it.next();
String name = (String) tableMap.get(objectId);
Map.Entry entry = (Entry) it.next();
Integer objectId = (Integer) entry.getKey();
String name = (String) entry.getValue();
writer.println("INSERT INTO " + name +" SELECT * FROM O_" + objectId + ";");
}
for(Iterator it = objectIdSet.iterator(); it.hasNext(); ) {
......
......@@ -21,6 +21,7 @@ import java.util.Iterator;
import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.util.JdbcUtils;
import org.h2.util.ScriptReader;
import org.h2.util.StringUtils;
......@@ -215,18 +216,19 @@ public class RunScript {
}
private static void executeRunscript(String url, String user, String password, String fileName, String options) throws SQLException {
Connection conn = null;
Statement stat = null;
try {
org.h2.Driver.load();
Connection conn = DriverManager.getConnection(url, user, password);
Statement stat = conn.createStatement();
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement();
String sql = "RUNSCRIPT FROM '" + fileName + "' " + options;
try {
stat.execute(sql);
} finally {
conn.close();
}
stat.execute(sql);
} catch (Exception e) {
throw Message.convert(e);
} finally {
JdbcUtils.closeSilently(stat);
JdbcUtils.closeSilently(conn);
}
}
......
......@@ -17,6 +17,7 @@ import org.h2.server.Service;
import org.h2.server.TcpServer;
import org.h2.server.ftp.FtpServer;
import org.h2.server.web.WebServer;
import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils;
import org.h2.util.StartBrowser;
......@@ -230,9 +231,11 @@ public class Server implements Runnable {
throw Message.convert(e);
}
for(int i=0; i<2; i++) {
Connection conn = null;
PreparedStatement prep = null;
try {
Connection conn = DriverManager.getConnection("jdbc:h2:" + url + "/" + db, "sa", password);
PreparedStatement prep = conn.prepareStatement("CALL STOP_SERVER(?, ?, ?)");
conn = DriverManager.getConnection("jdbc:h2:" + url + "/" + db, "sa", password);
prep = conn.prepareStatement("CALL STOP_SERVER(?, ?, ?)");
prep.setInt(1, port);
prep.setString(2, password);
prep.setInt(3, force ? TcpServer.SHUTDOWN_FORCE : TcpServer.SHUTDOWN_NORMAL);
......@@ -244,18 +247,15 @@ public class Server implements Runnable {
} else {
throw e;
}
} finally {
try {
conn.close();
} catch(SQLException e) {
// ignore
}
}
break;
} catch(SQLException e) {
if(i == 1) {
throw e;
}
} finally {
JdbcUtils.closeSilently(prep);
JdbcUtils.closeSilently(conn);
}
}
}
......@@ -338,7 +338,8 @@ public class Server implements Runnable {
private static void wait(int i) {
try {
// sleep at most 4096 ms
Thread.sleep(i * i);
long sleep = (long)i * (long)i;
Thread.sleep(sleep);
} catch (InterruptedException e) {
// ignore
}
......
......@@ -48,7 +48,7 @@ public class ByteUtils {
public static byte[] convertStringToBytes(String s) throws SQLException {
int len = s.length();
if (len < 0 || len % 2 == 1) {
if (len % 2 != 0) {
throw Message.getSQLException(Message.HEX_STRING_ODD_1, s);
}
len /= 2;
......
......@@ -233,7 +233,8 @@ public class FileUtils {
}
try {
// sleep at most 256 ms
Thread.sleep(i * i);
long sleep = (long)i * (long)i;
Thread.sleep(sleep);
} catch (InterruptedException e) {
// ignore
}
......
package org.h2.util;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
......@@ -26,4 +27,14 @@ public class JdbcUtils {
}
}
public static void closeSilently(ResultSet rs) {
if(rs != null) {
try {
rs.close();
} catch(SQLException e) {
// ignore
}
}
}
}
......@@ -286,7 +286,7 @@ public abstract class TestBase {
for(int i=0; i<a.length(); i++) {
String s = a.substring(0, i);
if(!b.startsWith(s)) {
s = s.substring(0, i) + "<*>" + s.substring(i);
a = a.substring(0, i) + "<*>" + a.substring(i);
break;
}
}
......
......@@ -16,8 +16,8 @@ public class BenchA implements Bench {
private Database db;
private int branches;
private int tellers = branches * 20;
private int accounts = branches * 100;
private int tellers;
private int accounts;
private int size;
private static final String FILLER = "abcdefghijklmnopqrstuvwxyz";
......
......@@ -371,7 +371,7 @@ public class BenchCThread {
rs.next();
rs.getString(1); // c_first
rs.getString(2); // c_middle
c_last = rs.getString(3);
rs.getString(3); // c_last
rs.getString(4); // c_street_1
rs.getString(5); // c_street_2
rs.getString(6); // c_city
......@@ -499,7 +499,7 @@ public class BenchCThread {
rs.getBigDecimal(1); // c_balance
rs.getString(2); // c_first
rs.getString(3); // c_middle
c_last = rs.getString(4);
rs.getString(4); // c_last
rs.close();
}
prep = prepare("SELECT MAX(O_ID) "
......
......@@ -20,6 +20,7 @@ import java.util.StringTokenizer;
import org.h2.test.TestBase;
import org.h2.tools.Server;
import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils;
class Database {
......@@ -129,7 +130,13 @@ class Database {
Connection conn = DriverManager.getConnection(url, user, password);
if(url.startsWith("jdbc:derby:")) {
// Derby: use higher cache size
conn.createStatement().execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize', '8192')");
Statement stat = null;
try {
stat = conn.createStatement();
stat.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize', '8192')");
} finally {
JdbcUtils.closeSilently(stat);
}
}
return conn;
}
......
......@@ -10,10 +10,13 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Properties;
import org.h2.test.TestBase;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
public class TestPerformance {
......@@ -29,13 +32,20 @@ public class TestPerformance {
}
private void openResults(boolean init) throws Exception {
Connection conn = getResultConnection();
if(init) {
conn.createStatement().execute("DROP TABLE IF EXISTS RESULTS");
Connection conn = null;
Statement stat = null;
try {
conn = getResultConnection();
stat = conn.createStatement();
if(init) {
stat.execute("DROP TABLE IF EXISTS RESULTS");
}
stat.execute("CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+ "UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)");
} finally {
JdbcUtils.closeSilently(stat);
JdbcUtils.closeSilently(conn);
}
conn.createStatement().execute("CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+ "UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)");
conn.close();
}
private void test(String[] args) throws Exception {
......@@ -84,42 +94,53 @@ public class TestPerformance {
return;
}
ArrayList results = ((Database)dbs.get(0)).getResults();
Connection conn = getResultConnection();
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO RESULTS(TESTID, TEST, UNIT, DBID, DB, RESULT) VALUES(?, ?, ?, ?, ?, ?)");
for(int i=0; i<results.size(); i++) {
Object[] res = (Object[])results.get(i);
prep.setInt(1, i);
prep.setString(2, res[0].toString());
prep.setString(3, res[1].toString());
for(int j=0; j<dbs.size(); j++) {
Database db = (Database)dbs.get(j);
prep.setInt(4, db.getId());
prep.setString(5, db.getName());
ArrayList r = db.getResults();
Object[] v = (Object[])r.get(i);
prep.setString(6, v[2].toString());
prep.execute();
Connection conn = null;
PreparedStatement prep = null;
Statement stat = null;
PrintWriter writer = null;
try {
conn = getResultConnection();
stat = conn.createStatement();
prep = conn.prepareStatement(
"INSERT INTO RESULTS(TESTID, TEST, UNIT, DBID, DB, RESULT) VALUES(?, ?, ?, ?, ?, ?)");
for(int i=0; i<results.size(); i++) {
Object[] res = (Object[])results.get(i);
prep.setInt(1, i);
prep.setString(2, res[0].toString());
prep.setString(3, res[1].toString());
for(int j=0; j<dbs.size(); j++) {
Database db = (Database)dbs.get(j);
prep.setInt(4, db.getId());
prep.setString(5, db.getName());
ArrayList r = db.getResults();
Object[] v = (Object[])r.get(i);
prep.setString(6, v[2].toString());
prep.execute();
}
}
writer = new PrintWriter(new FileWriter(out));
ResultSet rs = stat.executeQuery(
"CALL '<table><tr><th>Test Case</th><th>Unit</th>' "
+"|| SELECT GROUP_CONCAT('<th>' || DB || '</th>' ORDER BY DBID SEPARATOR '') FROM "
+"(SELECT DISTINCT DBID, DB FROM RESULTS)"
+"|| '</tr>' || CHAR(10) "
+"|| SELECT GROUP_CONCAT('<tr><td>' || TEST || '</td><td>' || UNIT || '</td>' || ( "
+"SELECT GROUP_CONCAT('<td>' || RESULT || '</td>' ORDER BY DBID SEPARATOR '') FROM RESULTS R2 WHERE "
+"R2.TESTID = R1.TESTID) || '</tr>' ORDER BY TESTID SEPARATOR CHAR(10)) FROM "
+"(SELECT DISTINCT TESTID, TEST, UNIT FROM RESULTS) R1"
+"|| '</table>'"
);
rs.next();
String result = rs.getString(1);
writer.println(result);
} finally {
JdbcUtils.closeSilently(prep);
JdbcUtils.closeSilently(stat);
JdbcUtils.closeSilently(conn);
IOUtils.closeSilently(writer);
}
PrintWriter writer = new PrintWriter(new FileWriter(out));
ResultSet rs = conn.createStatement().executeQuery(
"CALL '<table><tr><th>Test Case</th><th>Unit</th>' "
+"|| SELECT GROUP_CONCAT('<th>' || DB || '</th>' ORDER BY DBID SEPARATOR '') FROM "
+"(SELECT DISTINCT DBID, DB FROM RESULTS)"
+"|| '</tr>' || CHAR(10) "
+"|| SELECT GROUP_CONCAT('<tr><td>' || TEST || '</td><td>' || UNIT || '</td>' || ( "
+"SELECT GROUP_CONCAT('<td>' || RESULT || '</td>' ORDER BY DBID SEPARATOR '') FROM RESULTS R2 WHERE "
+"R2.TESTID = R1.TESTID) || '</tr>' ORDER BY TESTID SEPARATOR CHAR(10)) FROM "
+"(SELECT DISTINCT TESTID, TEST, UNIT FROM RESULTS) R1"
+"|| '</table>'"
);
rs.next();
String result = rs.getString(1);
writer.println(result);
conn.close();
// ResultSet rsDbs = conn.createStatement().executeQuery("SELECT DB RESULTS GROUP BY DBID, DB ORDER BY DBID");
// while(rsDbs.next()) {
// writer.println("<th>" + rsDbs.getString(1) + "</th>");
......@@ -154,7 +175,6 @@ public class TestPerformance {
// }
// writer.println("</table>");
writer.close();
System.out.println("Test finished");
System.exit(0);
}
......
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.cases;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.h2.tools.Csv;
public class TestCloseAtShutdown extends Thread {
Connection conn;
TestCloseAtShutdown() {
Csv csv = null;
csv.setFieldSeparatorWrite(";");
}
public void run() {
try {
Thread.sleep(100);
} catch(Exception e) {
// ignore
}
System.out.println("hook app");
try {
conn.getAutoCommit();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
Class.forName("org.h2.Driver");
TestCloseAtShutdown closer = new TestCloseAtShutdown();
Runtime.getRuntime().addShutdownHook(closer);
Connection conn = DriverManager.getConnection("jdbc:h2:test2;TRACE_LEVEL_FILE=3;DB_CLOSE_ON_EXIT=FALSE", "sa", "sa");
closer.conn = conn;
conn.getAutoCommit();
}
}
......@@ -87,6 +87,7 @@ public class Coverage {
c.processAll();
c.data.close();
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -154,8 +155,6 @@ public class Coverage {
}
File f = new File(name);
File fnew = new File(name + ".new");
String key = name;
key = key.replace('\\', '.');
try {
writer = new BufferedWriter(new FileWriter(fnew));
Reader r = new BufferedReader(new FileReader(f));
......
......@@ -9,6 +9,8 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.LineNumberReader;
import org.h2.util.IOUtils;
/**
* The class used at runtime to measure the code usage and performance.
*/
......@@ -16,8 +18,8 @@ public class Profile extends Thread {
public static final boolean LIST_UNVISITED = true;
public static final boolean FAST = false;
public static final boolean TRACE = false;
public static final Profile main = new Profile();
public static int current;
public static Profile main = new Profile();
private BufferedWriter trace;
public int[] count;
public int[] time;
......@@ -74,11 +76,12 @@ public class Profile extends Thread {
}
Profile() {
FileReader reader = null;
try {
LineNumberReader r = new LineNumberReader(new FileReader(
"profile.txt"));
reader = new FileReader("profile.txt");
LineNumberReader r = new LineNumberReader(reader);
while (r.readLine() != null) {
// nothing
// nothing - just count lines
}
maxIndex = r.getLineNumber();
count = new int[maxIndex];
......@@ -88,6 +91,8 @@ public class Profile extends Thread {
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
} finally {
IOUtils.closeSilently(reader);
}
}
......@@ -115,28 +120,36 @@ public class Profile extends Thread {
printLine('=');
print("NOT COVERED");
printLine('-');
LineNumberReader r = new LineNumberReader(new FileReader("profile.txt"));
BufferedWriter writer = new BufferedWriter(new FileWriter("notcovered.txt"));
int unvisited = 0;
int unvisitedthrow = 0;
for (int i = 0; i < maxIndex; i++) {
String line = r.readLine();
if (count[i] == 0) {
if (!line.endsWith("throw")) {
writer.write(line + "\r\n");
if(LIST_UNVISITED) {
print(line+"\r\n");
FileReader reader = null;
FileWriter fwriter = null;
try {
reader = new FileReader("profile.txt");
LineNumberReader r = new LineNumberReader(reader);
fwriter = new FileWriter("notcovered.txt");
BufferedWriter writer = new BufferedWriter(fwriter);
int unvisited = 0;
int unvisitedthrow = 0;
for (int i = 0; i < maxIndex; i++) {
String line = r.readLine();
if (count[i] == 0) {
if (!line.endsWith("throw")) {
writer.write(line + "\r\n");
if(LIST_UNVISITED) {
print(line+"\r\n");
}
unvisited++;
} else {
unvisitedthrow++;
}
unvisited++;
} else {
unvisitedthrow++;
}
}
int percent = (100 * unvisited / maxIndex);
print("Not covered: " + percent + " % " + " (" + unvisited + " of "
+ maxIndex + "; throw=" + unvisitedthrow + ")");
} finally {
IOUtils.closeSilently(fwriter);
IOUtils.closeSilently(reader);
}
writer.close();
int percent = (100 * unvisited / maxIndex);
print("Not covered: " + percent + " % " + " (" + unvisited + " of "
+ maxIndex + "; throw=" + unvisitedthrow + ")");
}
void listTop(String title, int[] list, int max) throws Exception {
......@@ -171,23 +184,29 @@ public class Profile extends Thread {
list[bigIndex] = -(big + 1);
index[i] = bigIndex;
}
LineNumberReader r = new LineNumberReader(new FileReader("profile.txt"));
for (int i = 0; i < maxIndex; i++) {
String line = r.readLine();
int k = list[i];
if (k < 0) {
k = -(k + 1);
list[i] = k;
for (int j = 0; j < max; j++) {
if (index[j] == i) {
int percent = (100 * k / total);
text[j] = k + " " + percent + "%: " + line;
FileReader reader = null;
try {
reader = new FileReader("profile.txt");
LineNumberReader r = new LineNumberReader(reader);
for (int i = 0; i < maxIndex; i++) {
String line = r.readLine();
int k = list[i];
if (k < 0) {
k = -(k + 1);
list[i] = k;
for (int j = 0; j < max; j++) {
if (index[j] == i) {
int percent = (100 * k / total);
text[j] = k + " " + percent + "%: " + line;
}
}
}
}
}
for (int i = 0; i < max; i++) {
print(text[i]);
for (int i = 0; i < max; i++) {
print(text[i]);
}
} finally {
IOUtils.closeSilently(reader);
}
}
......
......@@ -1725,15 +1725,13 @@ select "PUBLIC".test."ID" from test;
> --
> rows: 0
select "PUBLIC"."TEST"."ID" from test;
select public."TEST"."ID" from test;
> ID
> --
> rows: 0
select "public"."TEST"."ID" from test;
> ID
> --
> rows: 0
> exception
drop table test;
> ok
......
create schema a;
create table a.test(id int);
insert into a.test values(1);
create schema b;
create table b.test(id int);
insert into b.test values(2);
select a.test.id + b.test.id from a.test, b.test;
> 3;
drop schema a;
drop schema b;
select date '+0011-01-01';
> 0011-01-01;
select date'-0010-01-01';
......
......@@ -18,6 +18,7 @@ import org.h2.bnf.Bnf;
import org.h2.server.web.PageParser;
import org.h2.tools.indexer.Indexer;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils;
public class GenerateDoc {
......@@ -80,22 +81,27 @@ public class GenerateDoc {
}
void map(String key, String sql) throws Exception {
ResultSet rs = conn.createStatement().executeQuery(sql);
ArrayList list = new ArrayList();
while(rs.next()) {
HashMap map = new HashMap();
ResultSetMetaData meta = rs.getMetaData();
for(int i=0; i<meta.getColumnCount(); i++) {
String k = StringUtils.toLowerEnglish(meta.getColumnLabel(i+1));
String value = rs.getString(i+1);
map.put(k, PageParser.escapeHtml(value));
ResultSet rs = null;
try {
rs = conn.createStatement().executeQuery(sql);
ArrayList list = new ArrayList();
while(rs.next()) {
HashMap map = new HashMap();
ResultSetMetaData meta = rs.getMetaData();
for(int i=0; i<meta.getColumnCount(); i++) {
String k = StringUtils.toLowerEnglish(meta.getColumnLabel(i+1));
String value = rs.getString(i+1);
map.put(k, PageParser.escapeHtml(value));
}
String topic = rs.getString("TOPIC");
String syntax = rs.getString("SYNTAX");
syntax = bnf.getSyntax(topic, syntax);
map.put("syntax", PageParser.escapeHtml(syntax));
list.add(map);
}
String topic = rs.getString("TOPIC");
String syntax = rs.getString("SYNTAX");
syntax = bnf.getSyntax(topic, syntax);
map.put("syntax", PageParser.escapeHtml(syntax));
list.add(map);
session.put(key, list);
} finally {
JdbcUtils.closeSilently(rs);
}
session.put(key, list);
}
}
......@@ -168,7 +168,7 @@ public class Indexer {
return;
}
if(!noIndex.contains(fileName)) {
page = new Page(pages.size(), fileName, name);
page = new Page(pages.size(), fileName);
pages.add(page);
readPage(file);
}
......
......@@ -8,16 +8,14 @@ package org.h2.tools.indexer;
public class Page {
int id;
String fileName;
String name;
String title;
// TODO page.totalWeight is currently not used
int totalWeight;
int relations;
Page(int id, String fileName, String name) {
Page(int id, String fileName) {
this.id = id;
this.fileName = fileName;
this.name = name;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论