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

--no commit message

--no commit message
上级 550fd0a1
......@@ -268,6 +268,9 @@ Features
</tr><tr>
<td><a href="http://sql-workbench.net">SQL Workbench/J</a></td>
<td>Free DBMS-independent SQL Tool.</td>
</tr><tr>
<td><a href="http://www.streamcruncher.com">StreamCruncher</a></td>
<td>Event (Stream) Processing Kernel.</td>
</tr>
</table>
......
......@@ -596,7 +596,7 @@ public class Database implements DataHandler {
if(storages.size() > id) {
storage = (Storage) storages.get(id);
if(storage != null) {
if(Constants.CHECK && storage != null && storage.getDiskFile() != file) {
if(Constants.CHECK && storage.getDiskFile() != file) {
throw Message.getInternalError();
}
}
......
......@@ -43,10 +43,10 @@ public class DiskFile implements CacheWriter {
private Database database;
private String fileName;
private FileStore file;
private BitField used = new BitField();
private BitField deleted = new BitField();
private BitField used;
private BitField deleted;
private int fileBlockCount;
private IntArray pageOwners = new IntArray();
private IntArray pageOwners;
private Cache cache;
private LogSystem log;
private DataPage rowBuff;
......@@ -55,11 +55,12 @@ public class DiskFile implements CacheWriter {
private boolean logChanges;
private int recordOverhead;
private boolean init, initAlreadyTried;
private ObjectArray redoBuffer = new ObjectArray();
private ObjectArray redoBuffer;
private int redoBufferSize;
private int readCount, writeCount;
public DiskFile(Database database, String fileName, boolean dataFile, boolean logChanges, int cacheSize) throws SQLException {
reset();
this.database = database;
this.log = database.getLog();
this.fileName = fileName;
......@@ -92,6 +93,13 @@ public class DiskFile implements CacheWriter {
throw e;
}
}
private void reset() {
used = new BitField();
deleted = new BitField();
pageOwners = new IntArray();
redoBuffer = new ObjectArray();
}
private void setBlockCount(int count) {
fileBlockCount = count;
......@@ -183,6 +191,13 @@ public class DiskFile implements CacheWriter {
public synchronized void initFromSummary(byte[] summary) {
if(summary == null || summary.length==0) {
ObjectArray list = database.getAllStorages();
for(int i=0; i<list.size(); i++) {
Storage s = (Storage)list.get(i);
database.removeStorage(s.getId(), this);
}
reset();
initAlreadyTried = false;
init = false;
return;
}
......
......@@ -375,20 +375,17 @@ public class Recover implements DataHandler {
s.reset();
}
blocks = s.readInt();
if(blocks < 0) {
writer.println("// [" + pos+"] blocks: " + blocks);
} else if(blocks==0) {
writer.println("// [" + pos+"] blocks: 0 (end)");
if(blocks<=0) {
writer.println("// [" + pos+"] blocks: "+blocks+" (end)");
break;
} else {
char type = (char)s.readByte();
int sessionId = s.readInt();
writer.println("// type: " + type + " session: " + sessionId);
if(type == 'P') {
String transaction = s.readString();
writer.println("// transaction: " + transaction);
writer.println("// prepared session:"+sessionId+" tx: " + transaction);
} else if(type == 'C') {
writer.println("// commit");
break;
writer.println("// commit session:" + sessionId);
} else {
int storageId = s.readInt();
int recordId = s.readInt();
......@@ -404,21 +401,21 @@ public class Recover implements DataHandler {
if(sumLength > 0) {
s.read(summary, 0, sumLength);
}
writer.println("// fileType: " + fileType + " sumLength: " + sumLength);
writer.println("// summary session:"+sessionId+" fileType: " + fileType + " sumLength: " + sumLength);
dumpSummary(writer, summary);
break;
}
case 'T':
writer.println("// storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
writer.println("// truncate session:"+sessionId+" storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
break;
case 'I':
writer.println("// storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
writer.println("// insert session:"+sessionId+" storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
break;
case 'D':
writer.println("// storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
writer.println("// delete session:"+sessionId+" storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
break;
default:
writer.println("// storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
writer.println("// type?:"+type+" session:"+sessionId+" storage: " + storageId + " recordId: " + recordId + " blockCount: "+blockCount);
break;
}
}
......@@ -434,7 +431,7 @@ public class Recover implements DataHandler {
private void dumpSummary(PrintWriter writer, byte[] summary) throws SQLException {
if(summary == null || summary.length==0) {
writer.println("// summary is empty");
writer.println("// summary is empty");
return;
}
try {
......@@ -445,7 +442,10 @@ public class Recover implements DataHandler {
}
int len = in.readInt();
for(int i=0; i<len; i++) {
in.readInt();
int storageId = in.readInt();
if(storageId != -1) {
writer.println("// pos:"+(i*DiskFile.BLOCKS_PER_PAGE)+" storage:" + storageId);
}
}
while(true) {
int s = in.readInt();
......@@ -525,7 +525,7 @@ public class Recover implements DataHandler {
} else {
pageOwners[page] = storageId;
}
writer.println("// [" + block + "] p:"+page+" c:"+blockCount+" s:"+storageId);
writer.println("// [" + block + "] page:"+page+" blocks:"+blockCount+" storage:"+storageId);
}
} catch(Throwable e) {
writeError(writer, e);
......
......@@ -90,19 +90,26 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
TestAll test = new TestAll();
test.printSystem();
// code coverage
//max / hibernate
// Sorry, a typo by me. I don't specify any database name and then when
// I call getTables I get a catalog name that I pass on to getColumns and
// here getColumns does not return anything unless I null out the return
// catalog name.
// java.lang.Error: query was too quick; result: 0
// at org.h2.test.db.TestCases$1.run(TestCases.java:156)
// at java.lang.Thread.run(Thread.java:595)
//java.lang.Error: query was too quick; result: 0
// at org.h2.test.db.TestCases$1.run(TestCases.java:156)
// at java.lang.Thread.run(Thread.java:595)
//java.lang.Exception: closing took 1266
// at org.h2.test.TestBase.error(TestBase.java:206)
// at org.h2.test.db.TestCases.testDisconnect(TestCases.java:173)
// at org.h2.test.db.TestCases.test(TestCases.java:25)
// at org.h2.test.TestBase.runTest(TestBase.java:55)
// at org.h2.test.TestAll.testDatabase(TestAll.java:414)
// at org.h2.test.TestAll.testAll(TestAll.java:377)
// at org.h2.test.TestAll.testEverything(TestAll.java:273)
// at org.h2.test.TestAll.main(TestAll.java:196)
// Check if new Hibernate dialect for H2 is ok
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-2300
// open JPA test - submit patch
// ant mavenUploadLocal
// d:\data\h2test\openjpa\openjpa-persistence-jdbc\src\test\resources\META-INF\persistence.xml
// <!-- <property name="openjpa.ConnectionProperties"
// value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
......@@ -117,11 +124,9 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
// Test and document JDK 1.6 QueryObjectFactory
// submit hibernate dialect
// clean build path (remove hibernate librarires)
// test with PostgreSQL Version 8.2
// create table testoe(id int primary key, name varchar(255))
// create user oe identified by merlin
......
......@@ -48,7 +48,7 @@ public class TestCrashAPI extends TestBase {
private long callCount;
private String DIR = "synth";
private void deleteDb(int seed) {
private void deleteDb() {
try {
deleteDb(BASE_DIR + "/" + DIR, null);
} catch(Exception e) {
......@@ -59,13 +59,16 @@ public class TestCrashAPI extends TestBase {
private Connection getConnection(int seed, boolean delete) throws Exception {
openCount++;
if(delete) {
deleteDb(seed);
deleteDb();
}
// can not use FILE_LOCK=NO, otherwise something could be written into the database in the finalizer
String add = ""; // ";STORAGE=TEXT";
// int testing;
// if(openCount>=10) {
// add = ";STORAGE=TEXT";
// if(openCount>=24) {
// System.exit(1);
// }
// add = ";LOG=2";
// System.out.println("now open " + openCount);
// add += ";TRACE_LEVEL_FILE=3";
......@@ -73,6 +76,7 @@ public class TestCrashAPI extends TestBase {
// }
String url = getURL(DIR + "/crashapi" + seed, true) + add;
Connection conn = null;
// System.gc();
conn = DriverManager.getConnection(url, "sa", "");
......@@ -114,7 +118,7 @@ public class TestCrashAPI extends TestBase {
private void testOne(int seed) throws Exception {
printTime("TestCrashAPI " + seed);
callCount = 0;
openCount=0;
random = new RandomGen(null);
random.setSeed(seed);
......@@ -371,10 +375,10 @@ public class TestCrashAPI extends TestBase {
}
public void test() throws Exception {
for(int i=0; i<Integer.MAX_VALUE; i++) {
while(true) {
int seed = RandomUtils.nextInt(Integer.MAX_VALUE);
testCase(seed);
deleteDb(seed);
deleteDb();
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论