提交 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.
<h3>Version 1.0 (Current)</h3>
<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>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).
......
......@@ -194,44 +194,50 @@ public class Script extends ScriptBase {
}
String tableType = table.getTableType();
add(sql, false);
if(data && Table.TABLE.equals(tableType)) {
PlanItem plan = table.getBestPlanItem(session, null);
Index index = plan.getIndex();
Cursor cursor = index.find(session, null, null);
Column[] columns = table.getColumns();
String ins = "INSERT INTO " + table.getSQL() + "(";
for(int j=0; j<columns.length; j++) {
if(j>0) {
ins += ", ";
}
ins += Parser.quoteIdentifier(columns[j].getName());
if(Table.TABLE.equals(tableType)) {
if(table.canGetRowCount()) {
String rowcount = "-- " + table.getRowCount() + " = SELECT COUNT(*) FROM " + table.getSQL();
add(rowcount, false);
}
ins += ") VALUES(";
while(cursor.next()) {
Row row = cursor.get();
String s = ins;
for(int j=0; j<row.getColumnCount(); j++) {
if(data) {
PlanItem plan = table.getBestPlanItem(session, null);
Index index = plan.getIndex();
Cursor cursor = index.find(session, null, null);
Column[] columns = table.getColumns();
String ins = "INSERT INTO " + table.getSQL() + "(";
for(int j=0; j<columns.length; j++) {
if(j>0) {
s += ", ";
ins += ", ";
}
Value v = row.getValue(j);
if(v.getPrecision() > lobBlockSize) {
int id;
if(v.getType() == Value.CLOB) {
id = writeLobStream((ValueLob)v);
s += "SYSTEM_COMBINE_CLOB("+id+")";
} else if(v.getType() == Value.BLOB) {
id = writeLobStream((ValueLob)v);
s += "SYSTEM_COMBINE_BLOB("+id+")";
ins += Parser.quoteIdentifier(columns[j].getName());
}
ins += ") VALUES(";
while(cursor.next()) {
Row row = cursor.get();
String s = ins;
for(int j=0; j<row.getColumnCount(); j++) {
if(j>0) {
s += ", ";
}
Value v = row.getValue(j);
if(v.getPrecision() > lobBlockSize) {
int id;
if(v.getType() == Value.CLOB) {
id = writeLobStream((ValueLob)v);
s += "SYSTEM_COMBINE_CLOB("+id+")";
} else if(v.getType() == Value.BLOB) {
id = writeLobStream((ValueLob)v);
s += "SYSTEM_COMBINE_BLOB("+id+")";
} else {
s += v.getSQL();
}
} else {
s += v.getSQL();
}
} else {
s += v.getSQL();
}
s += ")";
add(s, true);
}
s += ")";
add(s, true);
}
}
ObjectArray indexes = table.getIndexes();
......
......@@ -4,7 +4,10 @@
*/
package org.h2.command.dml;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.SQLException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
......@@ -127,13 +130,15 @@ public class TransactionCommand extends Prepared {
return 0;
}
private void backupTo(String fileName) {
// ZipOutputStream out = new ZipOutputStream("test.zip");
// out.putNextEntry(arg0)
private void backupTo(String fileName) throws SQLException {
// int todoAddSpecialSQLStatement;
// FileOutputStream fileout = new FileOutputStream("test.zip");
// ZipOutputStream out = new ZipOutputStream(fileout);
// out.putNextEntry(new ZipEntry("test.data.db"));
// DiskFile file = session.getDatabase().getDataFile();
//// session.getDatabase().getLog().incStopDeleteFiles(true);
// // TODO Auto-generated method stub
//// session.getDatabase().getLog().setStopDeleteFiles(false);
// session.getDatabase().getLog().incStopDeleteFiles(true);
// TODO Auto-generated method stub
// session.getDatabase().getLog().setStopDeleteFiles(false);
//
}
......
......@@ -48,17 +48,15 @@ package org.h2.engine;
* - TestSystemExit
* - Test with hibernate
* - Scan for viruses
*
* - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!)
* - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
*
*
* @author Thomas
*/
public class Constants {
public static final int BUILD_ID = 36;
private static final String BUILD = "2007-01-02";
public static final int BUILD_ID = 38;
private static final String BUILD = "2007-01-10";
public static final int VERSION_MAJOR = 1;
public static final int VERSION_MINOR = 0;
......@@ -204,7 +202,7 @@ public class Constants {
public static final String SCRIPT_SQL = "script.sql";
// 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);
......
......@@ -9,7 +9,6 @@ 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;
......@@ -21,7 +20,6 @@ import org.h2.table.Table;
import org.h2.table.TableFilter;
import org.h2.value.Value;
/**
* @author Thomas
*/
......@@ -60,8 +58,7 @@ public class ExpressionColumn extends Expression {
if(tableAlias != null) {
sql = Parser.quoteIdentifier(tableAlias) + "." + sql;
}
if(schemaName != null && !schemaName.equals(Constants.SCHEMA_MAIN)) {
int todoTempSolution;
if(schemaName != null) {
sql = Parser.quoteIdentifier(schemaName) + "." + sql;
}
return sql;
......
......@@ -84,9 +84,10 @@ public class BtreeIndex extends Index implements RecordReader {
private void setChanged(Session session) throws SQLException {
if(head != null && !database.getLogIndexChanges()) {
// maybe there was a checkpoint, need to invalidate the summary in this case too
database.invalidateIndexSummary();
if(head.getConsistent()) {
deletePage(session, head);
database.invalidateIndexSummary();
head.setConsistent(false);
flushHead(session);
}
......
......@@ -196,7 +196,7 @@ public class DiskFile implements CacheWriter {
ObjectArray list = database.getAllStorages();
for(int i=0; i<list.size(); i++) {
Storage s = (Storage)list.get(i);
if(s.getDiskFile() == this) {
if(s != null && s.getDiskFile() == this) {
database.removeStorage(s.getId(), this);
}
}
......
......@@ -717,7 +717,7 @@ public class Recover implements DataHandler {
MetaRecord m = (MetaRecord) schema.get(i);
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();
Integer objectId = (Integer) entry.getKey();
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;
import java.sql.Connection;
......
......@@ -147,7 +147,7 @@ public class TestCases extends TestBase {
for(int i=0; i<1000; i++) {
stat.execute("INSERT INTO TEST() VALUES()");
}
final boolean[] stopped = new boolean[1];
final SQLException[] stopped = new SQLException[1];
Thread t = new Thread(new Runnable() {
public void run() {
try {
......@@ -157,9 +157,9 @@ public class TestCases extends TestBase {
time = System.currentTimeMillis() - time;
TestBase.logError("query was too quick; result: " + rs.getInt(1) + " time:" + time, null);
} catch(SQLException e) {
stopped[0] = e;
// ok
}
stopped[0] = true;
}
});
t.start();
......@@ -167,8 +167,10 @@ public class TestCases extends TestBase {
long time = System.currentTimeMillis();
conn.close();
t.join(5000);
if(!stopped[0]) {
if(stopped[0] == null) {
error("query still running");
} else {
checkNotGeneralException(stopped[0]);
}
time = System.currentTimeMillis() - time;
if(time > 5000) {
......
......@@ -18,6 +18,7 @@ import org.h2.jdbc.JdbcConnection;
import org.h2.test.TestBase;
import org.h2.tools.FileBase;
import org.h2.util.FileUtils;
import org.h2.util.JdbcUtils;
public class TestPowerOff extends TestBase {
......@@ -36,6 +37,7 @@ public class TestPowerOff extends TestBase {
dir = "inmemory:";
}
url = dir + "/" + dbName + ";file_lock=no";
testSummaryCrash();
testCrash();
testShutdown();
testNoIndexFile();
......@@ -43,6 +45,50 @@ public class TestPowerOff extends TestBase {
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 {
if(config.networked) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论