提交 86cb1379 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 e5e6830b
...@@ -35,6 +35,8 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -35,6 +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 / TODO</h3><ul> <h3>Version 1.0 / TODO</h3><ul>
<li>Fixed a problem where data that was in the log file did not end up in the database (recovery failure) a crash, if an index was deleted previously.
<li>SCRIPT NODATA now writes the row count for each table (this simplifies comparing databases).
<li>Selecting a column using the syntax schemaName.tableName.columName did not work in all cases. <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. <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). However dates before year 1 are not formatted correctly (this is a Java problem).
......
...@@ -194,7 +194,12 @@ public class Script extends ScriptBase { ...@@ -194,7 +194,12 @@ public class Script extends ScriptBase {
} }
String tableType = table.getTableType(); String tableType = table.getTableType();
add(sql, false); add(sql, false);
if(data && Table.TABLE.equals(tableType)) { if(Table.TABLE.equals(tableType)) {
if(table.canGetRowCount()) {
String rowcount = "-- " + table.getRowCount() + " = SELECT COUNT(*) FROM " + table.getSQL();
add(rowcount, false);
}
if(data) {
PlanItem plan = table.getBestPlanItem(session, null); PlanItem plan = table.getBestPlanItem(session, null);
Index index = plan.getIndex(); Index index = plan.getIndex();
Cursor cursor = index.find(session, null, null); Cursor cursor = index.find(session, null, null);
...@@ -234,6 +239,7 @@ public class Script extends ScriptBase { ...@@ -234,6 +239,7 @@ public class Script extends ScriptBase {
add(s, true); add(s, true);
} }
} }
}
ObjectArray indexes = table.getIndexes(); ObjectArray indexes = table.getIndexes();
for(int j=0; indexes != null && j<indexes.size(); j++) { for(int j=0; indexes != null && j<indexes.size(); j++) {
Index index = (Index) indexes.get(j); Index index = (Index) indexes.get(j);
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
*/ */
package org.h2.command.dml; package org.h2.command.dml;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -127,13 +130,15 @@ public class TransactionCommand extends Prepared { ...@@ -127,13 +130,15 @@ public class TransactionCommand extends Prepared {
return 0; return 0;
} }
private void backupTo(String fileName) { private void backupTo(String fileName) throws SQLException {
// ZipOutputStream out = new ZipOutputStream("test.zip"); // int todoAddSpecialSQLStatement;
// out.putNextEntry(arg0) // FileOutputStream fileout = new FileOutputStream("test.zip");
// ZipOutputStream out = new ZipOutputStream(fileout);
// out.putNextEntry(new ZipEntry("test.data.db"));
// DiskFile file = session.getDatabase().getDataFile(); // DiskFile file = session.getDatabase().getDataFile();
//// session.getDatabase().getLog().incStopDeleteFiles(true); // session.getDatabase().getLog().incStopDeleteFiles(true);
// // TODO Auto-generated method stub // TODO Auto-generated method stub
//// session.getDatabase().getLog().setStopDeleteFiles(false); // session.getDatabase().getLog().setStopDeleteFiles(false);
// //
} }
......
...@@ -48,8 +48,6 @@ package org.h2.engine; ...@@ -48,8 +48,6 @@ package org.h2.engine;
* - TestSystemExit * - TestSystemExit
* - Test with hibernate * - Test with hibernate
* - Scan for viruses * - Scan for viruses
*
* - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!) * - newsletter: prepare, send (always send to BCC!!)
* - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html * - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
* *
...@@ -57,8 +55,8 @@ package org.h2.engine; ...@@ -57,8 +55,8 @@ package org.h2.engine;
*/ */
public class Constants { public class Constants {
public static final int BUILD_ID = 36; public static final int BUILD_ID = 38;
private static final String BUILD = "2007-01-02"; private static final String BUILD = "2007-01-10";
public static final int VERSION_MAJOR = 1; public static final int VERSION_MAJOR = 1;
public static final int VERSION_MINOR = 0; public static final int VERSION_MINOR = 0;
...@@ -204,7 +202,7 @@ public class Constants { ...@@ -204,7 +202,7 @@ public class Constants {
public static final String SCRIPT_SQL = "script.sql"; public static final String SCRIPT_SQL = "script.sql";
// for testing only // for testing only
public static int CACHE_MIN_RECORDS = 16; public static final int CACHE_MIN_RECORDS = 16;
public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5); public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5);
......
...@@ -9,7 +9,6 @@ import java.util.HashMap; ...@@ -9,7 +9,6 @@ import java.util.HashMap;
import org.h2.command.Parser; import org.h2.command.Parser;
import org.h2.command.dml.Select; import org.h2.command.dml.Select;
import org.h2.engine.Constants;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
...@@ -21,7 +20,6 @@ import org.h2.table.Table; ...@@ -21,7 +20,6 @@ import org.h2.table.Table;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.value.Value; import org.h2.value.Value;
/** /**
* @author Thomas * @author Thomas
*/ */
...@@ -60,8 +58,7 @@ public class ExpressionColumn extends Expression { ...@@ -60,8 +58,7 @@ public class ExpressionColumn extends Expression {
if(tableAlias != null) { if(tableAlias != null) {
sql = Parser.quoteIdentifier(tableAlias) + "." + sql; sql = Parser.quoteIdentifier(tableAlias) + "." + sql;
} }
if(schemaName != null && !schemaName.equals(Constants.SCHEMA_MAIN)) { if(schemaName != null) {
int todoTempSolution;
sql = Parser.quoteIdentifier(schemaName) + "." + sql; sql = Parser.quoteIdentifier(schemaName) + "." + sql;
} }
return sql; return sql;
......
...@@ -84,9 +84,10 @@ public class BtreeIndex extends Index implements RecordReader { ...@@ -84,9 +84,10 @@ public class BtreeIndex extends Index implements RecordReader {
private void setChanged(Session session) throws SQLException { private void setChanged(Session session) throws SQLException {
if(head != null && !database.getLogIndexChanges()) { if(head != null && !database.getLogIndexChanges()) {
// maybe there was a checkpoint, need to invalidate the summary in this case too
database.invalidateIndexSummary();
if(head.getConsistent()) { if(head.getConsistent()) {
deletePage(session, head); deletePage(session, head);
database.invalidateIndexSummary();
head.setConsistent(false); head.setConsistent(false);
flushHead(session); flushHead(session);
} }
......
...@@ -196,7 +196,7 @@ public class DiskFile implements CacheWriter { ...@@ -196,7 +196,7 @@ public class DiskFile implements CacheWriter {
ObjectArray list = database.getAllStorages(); ObjectArray list = database.getAllStorages();
for(int i=0; i<list.size(); i++) { for(int i=0; i<list.size(); i++) {
Storage s = (Storage)list.get(i); Storage s = (Storage)list.get(i);
if(s.getDiskFile() == this) { if(s != null && s.getDiskFile() == this) {
database.removeStorage(s.getId(), this); database.removeStorage(s.getId(), this);
} }
} }
......
...@@ -717,7 +717,7 @@ public class Recover implements DataHandler { ...@@ -717,7 +717,7 @@ public class Recover implements DataHandler {
MetaRecord m = (MetaRecord) schema.get(i); MetaRecord m = (MetaRecord) schema.get(i);
writer.println(m.getSQL() + ";"); writer.println(m.getSQL() + ";");
} }
for(Iterator it = tableMap.keySet().iterator(); it.hasNext(); ) { for(Iterator it = tableMap.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Entry) it.next(); Map.Entry entry = (Entry) it.next();
Integer objectId = (Integer) entry.getKey(); Integer objectId = (Integer) entry.getKey();
String name = (String) entry.getValue(); String name = (String) entry.getValue();
......
/*
* 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.util; package org.h2.util;
import java.sql.Connection; import java.sql.Connection;
......
...@@ -147,7 +147,7 @@ public class TestCases extends TestBase { ...@@ -147,7 +147,7 @@ public class TestCases extends TestBase {
for(int i=0; i<1000; i++) { for(int i=0; i<1000; i++) {
stat.execute("INSERT INTO TEST() VALUES()"); stat.execute("INSERT INTO TEST() VALUES()");
} }
final boolean[] stopped = new boolean[1]; final SQLException[] stopped = new SQLException[1];
Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
public void run() { public void run() {
try { try {
...@@ -157,9 +157,9 @@ public class TestCases extends TestBase { ...@@ -157,9 +157,9 @@ public class TestCases extends TestBase {
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
TestBase.logError("query was too quick; result: " + rs.getInt(1) + " time:" + time, null); TestBase.logError("query was too quick; result: " + rs.getInt(1) + " time:" + time, null);
} catch(SQLException e) { } catch(SQLException e) {
stopped[0] = e;
// ok // ok
} }
stopped[0] = true;
} }
}); });
t.start(); t.start();
...@@ -167,8 +167,10 @@ public class TestCases extends TestBase { ...@@ -167,8 +167,10 @@ public class TestCases extends TestBase {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
conn.close(); conn.close();
t.join(5000); t.join(5000);
if(!stopped[0]) { if(stopped[0] == null) {
error("query still running"); error("query still running");
} else {
checkNotGeneralException(stopped[0]);
} }
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
if(time > 5000) { if(time > 5000) {
......
...@@ -18,6 +18,7 @@ import org.h2.jdbc.JdbcConnection; ...@@ -18,6 +18,7 @@ import org.h2.jdbc.JdbcConnection;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.FileBase; import org.h2.tools.FileBase;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.JdbcUtils;
public class TestPowerOff extends TestBase { public class TestPowerOff extends TestBase {
...@@ -36,6 +37,7 @@ public class TestPowerOff extends TestBase { ...@@ -36,6 +37,7 @@ public class TestPowerOff extends TestBase {
dir = "inmemory:"; dir = "inmemory:";
} }
url = dir + "/" + dbName + ";file_lock=no"; url = dir + "/" + dbName + ";file_lock=no";
testSummaryCrash();
testCrash(); testCrash();
testShutdown(); testShutdown();
testNoIndexFile(); testNoIndexFile();
...@@ -43,6 +45,50 @@ public class TestPowerOff extends TestBase { ...@@ -43,6 +45,50 @@ public class TestPowerOff extends TestBase {
testPersistentTables(); testPersistentTables();
} }
private void testSummaryCrash() throws Exception {
if(config.networked) {
return;
}
deleteDb(dir, dbName);
Connection conn = getConnection(url);
Statement stat = conn.createStatement();
for(int i=0; i<10; i++) {
stat.execute("CREATE TABLE TEST" + i + "(ID INT PRIMARY KEY, NAME VARCHAR)");
for(int j=0; j<10; j++) {
stat.execute("INSERT INTO TEST" + i + " VALUES("+j+", 'Hello')");
}
}
for(int i=0; i<10; i+=2) {
stat.execute("DROP TABLE TEST" + i);
}
stat.execute("SET WRITE_DELAY 0");
stat.execute("CHECKPOINT");
for(int j=0; j<10; j++) {
stat.execute("INSERT INTO TEST1 VALUES("+(10+j)+", 'World')");
}
stat.execute("SHUTDOWN IMMEDIATELY");
JdbcUtils.closeSilently(conn);
conn = getConnection(url);
stat = conn.createStatement();
for(int i=1; i<10; i+=2) {
ResultSet rs = stat.executeQuery("SELECT * FROM TEST" + i + " ORDER BY ID");
for(int j=0; j<10; j++) {
rs.next();
check(rs.getInt(1), j);
check(rs.getString(2), "Hello");
}
if(i == 1) {
for(int j=0; j<10; j++) {
rs.next();
check(rs.getInt(1), j + 10);
check(rs.getString(2), "World");
}
}
checkFalse(rs.next());
}
conn.close();
}
private void testCrash() throws Exception { private void testCrash() throws Exception {
if(config.networked) { if(config.networked) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论