提交 9ac5a876 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 4445abd7
...@@ -43,7 +43,7 @@ public class ConnectionInfo { ...@@ -43,7 +43,7 @@ public class ConnectionInfo {
String[] connectionTime = new String[]{ String[] connectionTime = new String[]{
"PASSWORD", "USER", "STORAGE", "FILE_LOCK", "CIPHER", "DB_CLOSE_ON_EXIT", "PASSWORD", "USER", "STORAGE", "FILE_LOCK", "CIPHER", "DB_CLOSE_ON_EXIT",
"IGNORE_UNKNOWN_SETTINGS", "IFEXISTS", "RECOVER", "CREATE", "CACHE_TYPE", "IGNORE_UNKNOWN_SETTINGS", "IFEXISTS", "RECOVER", "CREATE", "CACHE_TYPE",
"WRITE_MODE_LOG", "WRITE_MODE_DATA" "ACCESS_MODE_LOG", "ACCESS_MODE_DATA"
}; };
for(int i=0; i<connectionTime.length; i++) { for(int i=0; i<connectionTime.length; i++) {
String key = connectionTime[i]; String key = connectionTime[i];
......
...@@ -67,8 +67,8 @@ package org.h2.engine; ...@@ -67,8 +67,8 @@ package org.h2.engine;
*/ */
public class Constants { public class Constants {
public static final int BUILD_ID = 46; public static final int BUILD_ID = 47;
private static final String BUILD = "2007-04-29"; private static final String BUILD = "2007-06-13";
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;
...@@ -244,6 +244,7 @@ public class Constants { ...@@ -244,6 +244,7 @@ public class Constants {
public static final int OBJECT_CACHE_SIZE = getIntSetting("h2.objectCacheSize", 1024); public static final int OBJECT_CACHE_SIZE = getIntSetting("h2.objectCacheSize", 1024);
public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096); public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096);
public static final String CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/"); public static final String CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/");
public static int MAX_FILE_RETRY = Math.max(1, getIntSetting("h2.maxFileRetry", 16));
public static boolean getBooleanSetting(String name, boolean defaultValue) { public static boolean getBooleanSetting(String name, boolean defaultValue) {
String s = System.getProperty(name); String s = System.getProperty(name);
......
...@@ -135,7 +135,7 @@ public class Database implements DataHandler { ...@@ -135,7 +135,7 @@ public class Database implements DataHandler {
private String cacheType; private String cacheType;
private boolean indexSummaryValid = true; private boolean indexSummaryValid = true;
private Object lobSyncObject = new Object(); private Object lobSyncObject = new Object();
private String writeModeLog, writeModeData; private String accessModeLog, accessModeData;
public static void setInitialPowerOffCount(int count) { public static void setInitialPowerOffCount(int count) {
initialPowerOffCount = count; initialPowerOffCount = count;
...@@ -174,7 +174,7 @@ public class Database implements DataHandler { ...@@ -174,7 +174,7 @@ public class Database implements DataHandler {
} }
throw Message.getSQLException(Message.FILE_VERSION_ERROR_1, fileName); throw Message.getSQLException(Message.FILE_VERSION_ERROR_1, fileName);
} catch(IOException e) { } catch(IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, fileName);
} }
} }
...@@ -313,11 +313,11 @@ public class Database implements DataHandler { ...@@ -313,11 +313,11 @@ public class Database implements DataHandler {
} }
private void openFileData() throws SQLException { private void openFileData() throws SQLException {
fileData = new DiskFile(this, databaseName+Constants.SUFFIX_DATA_FILE, writeModeData, true, true, Constants.DEFAULT_CACHE_SIZE); fileData = new DiskFile(this, databaseName+Constants.SUFFIX_DATA_FILE, accessModeData, true, true, Constants.DEFAULT_CACHE_SIZE);
} }
private void openFileIndex() throws SQLException { private void openFileIndex() throws SQLException {
fileIndex = new DiskFile(this, databaseName+Constants.SUFFIX_INDEX_FILE, "rw", false, logIndexChanges, Constants.DEFAULT_CACHE_SIZE_INDEX); fileIndex = new DiskFile(this, databaseName+Constants.SUFFIX_INDEX_FILE, accessModeData, false, logIndexChanges, Constants.DEFAULT_CACHE_SIZE_INDEX);
} }
public DataPage getDataPage() { public DataPage getDataPage() {
...@@ -349,8 +349,8 @@ public class Database implements DataHandler { ...@@ -349,8 +349,8 @@ public class Database implements DataHandler {
this.databaseShortName = parseDatabaseShortName(); this.databaseShortName = parseDatabaseShortName();
this.cipher = cipher; this.cipher = cipher;
String lockMethodName = ci.removeProperty("FILE_LOCK", null); String lockMethodName = ci.removeProperty("FILE_LOCK", null);
this.writeModeLog = ci.removeProperty("WRITE_MODE_LOG", "rw").toLowerCase(); this.accessModeLog = ci.removeProperty("ACCESS_MODE_LOG", "rw").toLowerCase();
this.writeModeData = ci.removeProperty("WRITE_MODE_DATA", "rw").toLowerCase(); this.accessModeData = ci.removeProperty("ACCESS_MODE_DATA", "rw").toLowerCase();
this.fileLockMethod = FileLock.getFileLockMethod(lockMethodName); this.fileLockMethod = FileLock.getFileLockMethod(lockMethodName);
this.textStorage = ci.getTextStorage(); this.textStorage = ci.getTextStorage();
this.databaseURL = ci.getURL(); this.databaseURL = ci.getURL();
...@@ -426,7 +426,7 @@ public class Database implements DataHandler { ...@@ -426,7 +426,7 @@ public class Database implements DataHandler {
lock.lock(databaseName+Constants.SUFFIX_LOCK_FILE, fileLockMethod == FileLock.LOCK_SOCKET); lock.lock(databaseName+Constants.SUFFIX_LOCK_FILE, fileLockMethod == FileLock.LOCK_SOCKET);
} }
deleteOldTempFiles(); deleteOldTempFiles();
log = new LogSystem(this, databaseName, readOnly); log = new LogSystem(this, databaseName, readOnly, accessModeLog);
openFileData(); openFileData();
openFileIndex(); openFileIndex();
if(!readOnly) { if(!readOnly) {
...@@ -449,7 +449,7 @@ public class Database implements DataHandler { ...@@ -449,7 +449,7 @@ public class Database implements DataHandler {
writer = WriterThread.create(this, writeDelay); writer = WriterThread.create(this, writeDelay);
} else { } else {
traceSystem = new TraceSystem(null); traceSystem = new TraceSystem(null);
log = new LogSystem(null, null, false); log = new LogSystem(null, null, false, null);
} }
systemUser = new User(this, 0, Constants.DBA_NAME, true); systemUser = new User(this, 0, Constants.DBA_NAME, true);
mainSchema = new Schema(this, 0, Constants.SCHEMA_MAIN, systemUser, true); mainSchema = new Schema(this, 0, Constants.SCHEMA_MAIN, systemUser, true);
...@@ -1011,7 +1011,7 @@ public class Database implements DataHandler { ...@@ -1011,7 +1011,7 @@ public class Database implements DataHandler {
boolean inTempDir = readOnly; boolean inTempDir = readOnly;
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, inTempDir); return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, inTempDir);
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, databaseName);
} }
} }
...@@ -1490,8 +1490,4 @@ public class Database implements DataHandler { ...@@ -1490,8 +1490,4 @@ public class Database implements DataHandler {
return lobSyncObject; return lobSyncObject;
} }
public String getWriteModeLog() {
return writeModeLog;
}
} }
...@@ -325,7 +325,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -325,7 +325,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
try { try {
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, false); return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, false);
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, databaseName);
} }
} }
......
...@@ -242,7 +242,7 @@ public class Message { ...@@ -242,7 +242,7 @@ public class Message {
public static final int IO_EXCEPTION_1 = 90028; public static final int IO_EXCEPTION_1 = 90028;
public static final int NOT_ON_UPDATABLE_ROW = 90029; public static final int NOT_ON_UPDATABLE_ROW = 90029;
public static final int FILE_CORRUPTED_1 = 90030; public static final int FILE_CORRUPTED_1 = 90030;
public static final int IO_EXCEPTION_2 = 90031;
public static final int USER_NOT_FOUND_1 = 90032; public static final int USER_NOT_FOUND_1 = 90032;
public static final int USER_ALREADY_EXISTS_1 = 90033; public static final int USER_ALREADY_EXISTS_1 = 90033;
public static final int LOG_FILE_ERROR_1 = 90034; public static final int LOG_FILE_ERROR_1 = 90034;
...@@ -369,6 +369,14 @@ public class Message { ...@@ -369,6 +369,14 @@ public class Message {
} }
return Message.getSQLException(Message.GENERAL_ERROR_1, new String[]{e.toString()}, e); return Message.getSQLException(Message.GENERAL_ERROR_1, new String[]{e.toString()}, e);
} }
public static SQLException convertIOException(IOException e, String message) {
if(message == null) {
return Message.getSQLException(Message.IO_EXCEPTION_1, new String[]{e.toString()}, e);
} else {
return Message.getSQLException(Message.IO_EXCEPTION_2, new String[]{e.toString(), message}, e);
}
}
public static Error getInternalError() { public static Error getInternalError() {
return getInternalError("unexpected code path"); return getInternalError("unexpected code path");
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
42000=Syntax error in SQL statement {0} 42000=Syntax error in SQL statement {0}
42001=Syntax error in SQL statement {0}; expected {1} 42001=Syntax error in SQL statement {0}; expected {1}
42S01=Table {0} already exists 42S01=Table {0} already exists
42S02=Table {0} not found. Possible reasons: typo; the table is in another database or schema; case mismatch (use double quotes) 42S02=Table {0} not found.
42S11=Index {0} already exists 42S11=Index {0} already exists
42S12=Index {0} not found 42S12=Index {0} not found
42S21=Duplicate column name {0} 42S21=Duplicate column name {0}
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
90017=Attempt to define a second primary key 90017=Attempt to define a second primary key
90018=The connection was not closed by the application and is garbage collected 90018=The connection was not closed by the application and is garbage collected
90019=Cannot drop the current user 90019=Cannot drop the current user
90020=Database may be already in use: {0}. Possible solution: use the server mode 90020=Database may be already in use: {0}. Possible solutions: close all other connection(s); use the server mode
90021=Data conversion error converting {0} 90021=Data conversion error converting {0}
90022=Function {0} not found 90022=Function {0} not found
90023=Column {0} must not be nullable 90023=Column {0} must not be nullable
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
90028=IO Exception: {0} 90028=IO Exception: {0}
90029=Currently not on an updatable row 90029=Currently not on an updatable row
90030=File corrupted while reading record: {0}. Possible solution: use the recovery tool 90030=File corrupted while reading record: {0}. Possible solution: use the recovery tool
90031=IO Exception: {0}; {1}
90032=User {0} not found 90032=User {0} not found
90033=User {0} already exists 90033=User {0} already exists
90034=Log file error: {0} 90034=Log file error: {0}
......
...@@ -120,7 +120,7 @@ public class ResultRemote implements ResultInterface { ...@@ -120,7 +120,7 @@ public class ResultRemote implements ResultInterface {
session.traceOperation("RESULT_RESET", id); session.traceOperation("RESULT_RESET", id);
transfer.writeInt(SessionRemote.RESULT_RESET).writeInt(id).flush(); transfer.writeInt(SessionRemote.RESULT_RESET).writeInt(id).flush();
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, null);
} }
} }
} }
...@@ -236,7 +236,7 @@ public class ResultRemote implements ResultInterface { ...@@ -236,7 +236,7 @@ public class ResultRemote implements ResultInterface {
return null; return null;
} }
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, null);
} }
} }
} }
......
...@@ -117,8 +117,8 @@ Initial Developer: H2 Group ...@@ -117,8 +117,8 @@ Initial Developer: H2 Group
</table> </table>
</form> </form>
<p> <p>
<form name="shutdown" method="post" action="/adminShutdown.do?jsessionid=${sessionId}"> <form name="shutdown" method="post" action="/adminShutdown.do?jsessionid=${sessionId}">
<input type="submit" class="button" value="${text.adminShutdown}" /> <input type="submit" class="button" value="${text.adminShutdown}" />
</form> </form>
</p> </p>
</body></html> </body></html>
\ No newline at end of file
...@@ -119,16 +119,12 @@ public class DiskFile implements CacheWriter { ...@@ -119,16 +119,12 @@ public class DiskFile implements CacheWriter {
} }
private void create() throws SQLException { private void create() throws SQLException {
try { file = database.openFile(fileName, mode, false);
file = database.openFile(fileName, mode, false); DataPage header = DataPage.create(database, OFFSET);
DataPage header = DataPage.create(database, OFFSET); file.seek(FileStore.HEADER_LENGTH);
file.seek(FileStore.HEADER_LENGTH); header.fill(OFFSET);
header.fill(OFFSET); header.updateChecksum();
header.updateChecksum(); file.write(header.getBytes(), 0, OFFSET);
file.write(header.getBytes(), 0, OFFSET);
} catch (Exception e) {
throw Message.convert(e);
}
} }
private void freeUnusedPages() throws SQLException { private void freeUnusedPages() throws SQLException {
...@@ -275,43 +271,39 @@ public class DiskFile implements CacheWriter { ...@@ -275,43 +271,39 @@ public class DiskFile implements CacheWriter {
s.setRecordCount(0); s.setRecordCount(0);
} }
} }
try { int blockHeaderLen = Math.max(Constants.FILE_BLOCK_SIZE, 2 * rowBuff.getIntLen());
int blockHeaderLen = Math.max(Constants.FILE_BLOCK_SIZE, 2 * rowBuff.getIntLen()); byte[] buff = new byte[blockHeaderLen];
byte[] buff = new byte[blockHeaderLen]; DataPage s = DataPage.create(database, buff);
DataPage s = DataPage.create(database, buff); long time = 0;
long time = 0; for (int i = 0; i < fileBlockCount;) {
for (int i = 0; i < fileBlockCount;) { long t2 = System.currentTimeMillis();
long t2 = System.currentTimeMillis(); if(t2 > time + 10) {
if(t2 > time + 10) { time = t2;
time = t2; database.setProgress(DatabaseEventListener.STATE_SCAN_FILE, this.fileName, i, fileBlockCount);
database.setProgress(DatabaseEventListener.STATE_SCAN_FILE, this.fileName, i, fileBlockCount); }
} go(i);
go(i); file.readFully(buff, 0, blockHeaderLen);
file.readFully(buff, 0, blockHeaderLen); s.reset();
s.reset(); int blockCount = s.readInt();
int blockCount = s.readInt(); if(Constants.CHECK && blockCount < 0) {
if(Constants.CHECK && blockCount < 0) { throw Message.getInternalError();
}
if(blockCount == 0) {
setUnused(i, 1);
i++;
} else {
int id = s.readInt();
if(Constants.CHECK && id < 0) {
throw Message.getInternalError(); throw Message.getInternalError();
} }
if(blockCount == 0) { Storage storage = database.getStorage(id, this);
setUnused(i, 1); setBlockOwner(storage, i, blockCount, true);
i++; storage.incrementRecordCount();
} else { i += blockCount;
int id = s.readInt();
if(Constants.CHECK && id < 0) {
throw Message.getInternalError();
}
Storage storage = database.getStorage(id, this);
setBlockOwner(storage, i, blockCount, true);
storage.incrementRecordCount();
i += blockCount;
}
} }
database.setProgress(DatabaseEventListener.STATE_SCAN_FILE, this.fileName, fileBlockCount, fileBlockCount);
init = true;
} catch (Exception e) {
throw Message.convert(e);
} }
database.setProgress(DatabaseEventListener.STATE_SCAN_FILE, this.fileName, fileBlockCount, fileBlockCount);
init = true;
} }
synchronized void flush() throws SQLException { synchronized void flush() throws SQLException {
...@@ -565,8 +557,8 @@ public class DiskFile implements CacheWriter { ...@@ -565,8 +557,8 @@ public class DiskFile implements CacheWriter {
cache.clear(); cache.clear();
file.close(); file.close();
FileUtils.delete(fileName); FileUtils.delete(fileName);
} catch (Exception e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, fileName);
} finally { } finally {
file = null; file = null;
fileName = null; fileName = null;
...@@ -590,22 +582,18 @@ public class DiskFile implements CacheWriter { ...@@ -590,22 +582,18 @@ public class DiskFile implements CacheWriter {
writeCount++; writeCount++;
Record record = (Record) obj; Record record = (Record) obj;
synchronized(this) { synchronized(this) {
try { int blockCount = record.getBlockCount();
int blockCount = record.getBlockCount(); record.prepareWrite();
record.prepareWrite(); go(record.getPos());
go(record.getPos()); DataPage buff = rowBuff;
DataPage buff = rowBuff; buff.reset();
buff.reset(); buff.checkCapacity(blockCount * BLOCK_SIZE);
buff.checkCapacity(blockCount * BLOCK_SIZE); buff.writeInt(blockCount);
buff.writeInt(blockCount); buff.writeInt(record.getStorageId());
buff.writeInt(record.getStorageId()); record.write(buff);
record.write(buff); buff.fill(blockCount * BLOCK_SIZE);
buff.fill(blockCount * BLOCK_SIZE); buff.updateChecksum();
buff.updateChecksum(); file.write(buff.getBytes(), 0, buff.length());
file.write(buff.getBytes(), 0, buff.length());
} catch (Exception e) {
throw Message.convert(e);
}
} }
record.setChanged(false); record.setChanged(false);
} }
...@@ -618,54 +606,42 @@ public class DiskFile implements CacheWriter { ...@@ -618,54 +606,42 @@ public class DiskFile implements CacheWriter {
} }
synchronized void updateRecord(Session session, Record record) throws SQLException { synchronized void updateRecord(Session session, Record record) throws SQLException {
try { record.setChanged(true);
record.setChanged(true); int pos = record.getPos();
int pos = record.getPos(); Record old = (Record) cache.update(pos, record);
Record old = (Record) cache.update(pos, record); if(Constants.CHECK) {
if(Constants.CHECK) { if(old != null) {
if(old != null) { if(old!=record) {
if(old!=record) { database.checkPowerOff();
database.checkPowerOff(); throw Message.getInternalError("old != record old="+old+" new="+record);
throw Message.getInternalError("old != record old="+old+" new="+record); }
} int blockCount = record.getBlockCount();
int blockCount = record.getBlockCount(); for(int i=0; i<blockCount; i++) {
for(int i=0; i<blockCount; i++) { if(deleted.get(i + pos)) {
if(deleted.get(i + pos)) { throw Message.getInternalError("update marked as deleted: " + (i+pos));
throw Message.getInternalError("update marked as deleted: " + (i+pos));
}
} }
} }
} }
if(logChanges) { }
log.add(session, this, record); if(logChanges) {
} log.add(session, this, record);
} catch (Exception e) {
throw Message.convert(e);
} }
} }
synchronized void writeDirectDeleted(int recordId, int blockCount) throws SQLException { synchronized void writeDirectDeleted(int recordId, int blockCount) throws SQLException {
synchronized(this) { synchronized(this) {
try { go(recordId);
go(recordId); for(int i=0; i<blockCount; i++) {
for(int i=0; i<blockCount; i++) { file.write(freeBlock.getBytes(), 0, freeBlock.length());
file.write(freeBlock.getBytes(), 0, freeBlock.length());
}
free(recordId, blockCount);
} catch (Exception e) {
throw Message.convert(e);
} }
free(recordId, blockCount);
} }
} }
synchronized void writeDirect(Storage storage, int pos, byte[] data, int offset) throws SQLException { synchronized void writeDirect(Storage storage, int pos, byte[] data, int offset) throws SQLException {
try { go(pos);
go(pos); file.write(data, offset, BLOCK_SIZE);
file.write(data, offset, BLOCK_SIZE); setBlockOwner(storage, pos, 1, true);
setBlockOwner(storage, pos, 1, true);
} catch (Exception e) {
throw Message.convert(e);
}
} }
public synchronized int copyDirect(int pos, OutputStream out) throws SQLException { public synchronized int copyDirect(int pos, OutputStream out) throws SQLException {
...@@ -710,8 +686,8 @@ public class DiskFile implements CacheWriter { ...@@ -710,8 +686,8 @@ public class DiskFile implements CacheWriter {
} }
out.write(s.getBytes(), 0, blockCount * blockSize); out.write(s.getBytes(), 0, blockCount * blockSize);
return pos + blockCount; return pos + blockCount;
} catch (Exception e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, fileName);
} }
} }
......
...@@ -157,7 +157,9 @@ public class FileLock { ...@@ -157,7 +157,9 @@ public class FileLock {
private void lockFile() throws SQLException { private void lockFile() throws SQLException {
method = FILE; method = FILE;
properties = new Properties(); properties = new Properties();
String random = ByteUtils.convertBytesToString(RandomUtils.getSecureBytes(RANDOM_BYTES)); byte[] bytes = RandomUtils.getSecureBytes(RANDOM_BYTES);
System.out.println("lockFile 2b" + fileName);
String random = ByteUtils.convertBytesToString(bytes);
properties.setProperty("id", Long.toHexString(System.currentTimeMillis())+random); properties.setProperty("id", Long.toHexString(System.currentTimeMillis())+random);
if (!FileUtils.createNewFile(fileName)) { if (!FileUtils.createNewFile(fileName)) {
waitUntilOld(); waitUntilOld();
......
...@@ -69,7 +69,7 @@ public class FileStore { ...@@ -69,7 +69,7 @@ public class FileStore {
} }
fileLength = file.length(); fileLength = file.length();
} catch(IOException e) { } catch(IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, "name: " + name +" mode: " + mode);
} }
} }
...@@ -177,7 +177,7 @@ public class FileStore { ...@@ -177,7 +177,7 @@ public class FileStore {
try { try {
file.readFully(b, off, len); file.readFully(b, off, len);
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, name);
} }
filePos += len; filePos += len;
} }
...@@ -192,7 +192,7 @@ public class FileStore { ...@@ -192,7 +192,7 @@ public class FileStore {
filePos = pos; filePos = pos;
} }
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, name);
} }
} }
...@@ -216,10 +216,10 @@ public class FileStore { ...@@ -216,10 +216,10 @@ public class FileStore {
try { try {
file.write(b, off, len); file.write(b, off, len);
} catch (IOException e2) { } catch (IOException e2) {
throw Message.convert(e2); throw Message.convertIOException(e2, name);
} }
} else { } else {
throw Message.convert(e); throw Message.convertIOException(e, name);
} }
} }
filePos += len; filePos += len;
...@@ -263,10 +263,10 @@ public class FileStore { ...@@ -263,10 +263,10 @@ public class FileStore {
try { try {
FileUtils.setLength(file, newLength); FileUtils.setLength(file, newLength);
} catch (IOException e2) { } catch (IOException e2) {
throw Message.convert(e2); throw Message.convertIOException(e2, name);
} }
} else { } else {
throw Message.convert(e); throw Message.convertIOException(e, name);
} }
} }
} }
...@@ -288,7 +288,7 @@ public class FileStore { ...@@ -288,7 +288,7 @@ public class FileStore {
} }
return len; return len;
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, name);
} }
} }
...@@ -299,7 +299,7 @@ public class FileStore { ...@@ -299,7 +299,7 @@ public class FileStore {
throw Message.getInternalError(); throw Message.getInternalError();
} }
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, name);
} }
} }
return filePos; return filePos;
......
...@@ -32,7 +32,7 @@ public class FileStoreInputStream extends InputStream { ...@@ -32,7 +32,7 @@ public class FileStoreInputStream extends InputStream {
fillBuffer(); fillBuffer();
} }
} catch(IOException e) { } catch(IOException e) {
throw Message.convert(e); throw Message.convertIOException(e, store.name);
} }
} }
......
...@@ -59,7 +59,7 @@ public class LogFile { ...@@ -59,7 +59,7 @@ public class LogFile {
this.id = id; this.id = id;
this.fileNamePrefix = fileNamePrefix; this.fileNamePrefix = fileNamePrefix;
fileName = getFileName(); fileName = getFileName();
file = log.getDatabase().openFile(fileName, database.getWriteModeLog(), false); file = log.getDatabase().openFile(fileName, log.getAccessMode(), false);
rowBuff = log.getRowBuffer(); rowBuff = log.getRowBuffer();
buffer = new byte[BUFFER_SIZE]; buffer = new byte[BUFFER_SIZE];
unwritten = new ObjectArray(); unwritten = new ObjectArray();
...@@ -366,7 +366,7 @@ public class LogFile { ...@@ -366,7 +366,7 @@ public class LogFile {
} }
} catch (IOException e) { } catch (IOException e) {
if(closeException == null) { if(closeException == null) {
closeException = Message.convert(e); closeException = Message.convertIOException(e, fileName);
} }
} }
file = null; file = null;
......
...@@ -39,10 +39,12 @@ public class LogSystem { ...@@ -39,10 +39,12 @@ public class LogSystem {
private boolean disabled; private boolean disabled;
private int keepFiles; private int keepFiles;
private boolean closed; private boolean closed;
private String accessMode;
public LogSystem(Database database, String fileNamePrefix, boolean readOnly) throws SQLException { public LogSystem(Database database, String fileNamePrefix, boolean readOnly, String accessMode) throws SQLException {
this.database = database; this.database = database;
this.readOnly = readOnly; this.readOnly = readOnly;
this.accessMode = accessMode;
if (database == null || readOnly) { if (database == null || readOnly) {
return; return;
} }
...@@ -465,4 +467,8 @@ public class LogSystem { ...@@ -465,4 +467,8 @@ public class LogSystem {
keepFiles += incrementDecrement; keepFiles += incrementDecrement;
} }
String getAccessMode() {
return accessMode;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论