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

New experimental page store.

上级 589f38be
...@@ -458,17 +458,26 @@ public class PageStore implements CacheWriter { ...@@ -458,17 +458,26 @@ public class PageStore implements CacheWriter {
* Close the file without writing anything. * Close the file without writing anything.
*/ */
public void close() throws SQLException { public void close() throws SQLException {
Exception closeException = null;
try { try {
trace.debug("close"); trace.debug("close");
if (log != null) { if (log != null) {
log.close(); log.close();
} }
} catch (SQLException e) {
closeException = e;
}
try {
if (file != null) { if (file != null) {
file.close(); file.close();
} }
file = null;
} catch (IOException e) { } catch (IOException e) {
throw Message.convertIOException(e, "close"); closeException = e;
}
log = null;
file = null;
if (closeException != null) {
throw Message.convert(closeException);
} }
} }
...@@ -509,6 +518,7 @@ public class PageStore implements CacheWriter { ...@@ -509,6 +518,7 @@ public class PageStore implements CacheWriter {
trace.debug("updateRecord " + record.toString()); trace.debug("updateRecord " + record.toString());
} }
} }
checkOpen();
database.checkWritingAllowed(); database.checkWritingAllowed();
record.setChanged(true); record.setChanged(true);
int pos = record.getPos(); int pos = record.getPos();
...@@ -518,7 +528,7 @@ public class PageStore implements CacheWriter { ...@@ -518,7 +528,7 @@ public class PageStore implements CacheWriter {
if (old == null) { if (old == null) {
old = readPage(pos); old = readPage(pos);
} }
log.addUndo(record.getPos(), old); log.addUndo(pos, old);
} }
} }
} }
...@@ -768,6 +778,7 @@ public class PageStore implements CacheWriter { ...@@ -768,6 +778,7 @@ public class PageStore implements CacheWriter {
*/ */
public void commit(Session session) throws SQLException { public void commit(Session session) throws SQLException {
synchronized (database) { synchronized (database) {
checkOpen();
log.commit(session.getId()); log.commit(session.getId());
if (log.getSize() > maxLogSize) { if (log.getSize() > maxLogSize) {
checkpoint(); checkpoint();
...@@ -1033,4 +1044,11 @@ public class PageStore implements CacheWriter { ...@@ -1033,4 +1044,11 @@ public class PageStore implements CacheWriter {
return this.recoveryRunning; return this.recoveryRunning;
} }
private void checkOpen() throws SQLException {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
}
}
} }
...@@ -438,7 +438,7 @@ public abstract class TestBase { ...@@ -438,7 +438,7 @@ public abstract class TestBase {
* @param name the database name * @param name the database name
*/ */
protected void deleteDb(String name) throws SQLException { protected void deleteDb(String name) throws SQLException {
DeleteDbFiles.execute(baseDir, name, true); deleteDb(baseDir, name);
} }
/** /**
...@@ -449,6 +449,11 @@ public abstract class TestBase { ...@@ -449,6 +449,11 @@ public abstract class TestBase {
*/ */
protected void deleteDb(String dir, String name) throws SQLException { protected void deleteDb(String dir, String name) throws SQLException {
DeleteDbFiles.execute(dir, name, true); DeleteDbFiles.execute(dir, name, true);
// ArrayList<String> list;
// list = FileLister.getDatabaseFiles(baseDir, name, true);
// if (list.size() > 0) {
// System.out.println("Not deleted: " + list);
// }
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论