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

Using a different exception constant name for closed databases.

上级 66554db3
......@@ -1398,11 +1398,12 @@ public class ErrorCode {
public static final int DATABASE_IS_READ_ONLY = 90097;
/**
* The error with code <code>90098</code> is thrown when the
* self-destruction counter has reached zero. This counter is only used for
* recovery testing, and not set in normal operation.
* The error with code <code>90098</code> is thrown when the database has
* been closed, for example because the system ran out of memory or because
* the self-destruction counter has reached zero. This counter is only used
* for recovery testing, and not set in normal operation.
*/
public static final int SIMULATED_POWER_OFF = 90098;
public static final int DATABASE_IS_CLOSED = 90098;
/**
* The error with code <code>90099</code> is thrown when an error occurred
......
......@@ -141,14 +141,14 @@ public class LogFile {
private int getBlock() throws SQLException {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
return (int) (file.getFilePointer() / BLOCK_SIZE);
}
private void writeBuffer(DataPage buff, Record rec) throws SQLException {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
int size = MathUtils.roundUp(buff.length() + DataPage.LENGTH_FILLER, BLOCK_SIZE);
int blockCount = size / BLOCK_SIZE;
......@@ -421,7 +421,7 @@ public class LogFile {
void flush() throws SQLException {
if (bufferPos > 0) {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
file.write(buffer, 0, bufferPos);
pos = getBlock();
......
......@@ -553,7 +553,7 @@ public class DiskFile implements CacheWriter {
Record getRecord(Session session, int pos, RecordReader reader, int storageId) throws SQLException {
synchronized (database) {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
Record record = (Record) cache.get(pos);
if (record != null) {
......@@ -604,7 +604,7 @@ public class DiskFile implements CacheWriter {
reuseSpace();
synchronized (database) {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
blockCount = getPage(blockCount + BLOCKS_PER_PAGE - 1) * BLOCKS_PER_PAGE;
int lastPage = getPage(fileBlockCount);
......
......@@ -130,12 +130,6 @@ public class PageStore implements CacheWriter {
*/
public static final int PAGE_SIZE_MAX = 32768;
/**
* The default page size.
*/
public static final int PAGE_SIZE_DEFAULT = 2 * 1024;
// public static final int PAGE_SIZE_DEFAULT = 64;
private static final int PAGE_ID_FREE_LIST_ROOT = 3;
private static final int PAGE_ID_META_ROOT = 4;
......@@ -277,7 +271,7 @@ public class PageStore implements CacheWriter {
}
private void openNew() throws SQLException {
setPageSize(PAGE_SIZE_DEFAULT);
setPageSize(SysProperties.PAGE_SIZE);
freeListPagesPerList = PageFreeList.getPagesAddressed(pageSize);
file = database.openFile(fileName, accessMode, false);
recoveryRunning = true;
......@@ -1467,7 +1461,7 @@ public class PageStore implements CacheWriter {
private void checkOpen() throws SQLException {
if (file == null) {
throw Message.getSQLException(ErrorCode.SIMULATED_POWER_OFF);
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论