提交 8f8e77d1 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 e2d3afcb
......@@ -157,7 +157,7 @@ class ResultDiskBuffer {
}
protected void finalize() {
if(!Constants.RUN_FINALIZERS) {
if(!Constants.RUN_FINALIZE) {
return;
}
close();
......
......@@ -161,7 +161,7 @@ public class ResultRemote implements ResultInterface {
if (session == null) {
return;
}
// TODO result sets: no reset possible for larger remote resultsets
// TODO result sets: no reset possible for larger remote result sets
synchronized (session) {
try {
session.traceOperation("RESULT_CLOSE", id);
......@@ -181,7 +181,7 @@ public class ResultRemote implements ResultInterface {
}
// public void finalize() {
// if(!Database.RUN_FINALIZERS) {
// if(!Constants.RUN_FINALIZE) {
// return;
// }
// close();
......
......@@ -53,22 +53,22 @@ public class SHA256 {
public byte[] getHash(byte[] data) {
int bytelen = data.length;
int intlen = ((bytelen + 9 + 63) / 64) * 16;
byte[] bytes = new byte[intlen * 4];
System.arraycopy(data, 0, bytes, 0, bytelen);
bytes[bytelen] = (byte) 0x80;
int[] buff = new int[intlen];
for (int i = 0, j = 0; j < intlen; i += 4, j++) {
int byteLen = data.length;
int intLen = ((byteLen + 9 + 63) / 64) * 16;
byte[] bytes = new byte[intLen * 4];
System.arraycopy(data, 0, bytes, 0, byteLen);
bytes[byteLen] = (byte) 0x80;
int[] buff = new int[intLen];
for (int i = 0, j = 0; j < intLen; i += 4, j++) {
buff[j] = readInt(bytes, i);
}
buff[intlen - 2] = bytelen >>> 29;
buff[intlen - 1] = (bytelen << 3) & 0xffffffff;
buff[intLen - 2] = byteLen >>> 29;
buff[intLen - 1] = (byteLen << 3) & 0xffffffff;
int[] w = new int[64];
int[] hh = new int[] { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
for (int block = 0; block < intlen; block += 16) {
for (int block = 0; block < intLen; block += 16) {
for (int i = 0; i < 16; i++) {
w[i] = buff[block + i];
}
......
......@@ -42,7 +42,7 @@ public class AppServer {
private int port;
private boolean allowOthers;
private boolean ssl;
private HashMap connectionInfos = new HashMap();
private HashMap connInfoMap = new HashMap();
AppServer(String[] args) {
Properties prop = loadProperties();
......@@ -101,16 +101,16 @@ public class AppServer {
}
ConnectionInfo getSetting(String name) {
return (ConnectionInfo)connectionInfos.get(name);
return (ConnectionInfo)connInfoMap.get(name);
}
void updateSetting(ConnectionInfo info) {
connectionInfos.put(info.name, info);
connInfoMap.put(info.name, info);
info.lastAccess = ticker++;
}
void removeSetting(String name) {
connectionInfos.remove(name);
connInfoMap.remove(name);
}
private File getPropertiesFile() {
......@@ -139,7 +139,7 @@ public class AppServer {
synchronized ArrayList getSettings() {
ArrayList settings = new ArrayList();
if(connectionInfos.size() == 0) {
if(connInfoMap.size() == 0) {
Properties prop = loadProperties();
if(prop.size() == 0) {
for(int i=0; i<AppServer.GENERIC.length; i++) {
......@@ -159,7 +159,7 @@ public class AppServer {
}
}
} else {
settings.addAll(connectionInfos.values());
settings.addAll(connInfoMap.values());
}
sortConnectionInfo(settings);
return settings;
......
......@@ -331,6 +331,9 @@ public class AppThread extends WebServerThread {
String ident = ", "+level+", "+(level+1)+", ";
String identNode = ", "+(level+1)+", "+(level+1)+", ";
DbTableOrView[] tables = schema.tables;
if(tables == null) {
return treeIndex;
}
boolean isOracle = schema.contents.isOracle;
boolean showColumnTypes = tables.length < 100;
for(int i=0; i<tables.length; i++) {
......@@ -894,6 +897,7 @@ public class AppThread extends WebServerThread {
ResultSet rs;
long time = System.currentTimeMillis();
boolean metadata = false;
boolean generatedKeys = false;
boolean edit = false;
if(sql.equals("@CANCEL")) {
stat = getAppSession().executingStatement;
......@@ -907,6 +911,9 @@ public class AppThread extends WebServerThread {
} else if(sql.startsWith("@META")) {
metadata = true;
sql = sql.substring("@META".length()).trim();
} else if(sql.startsWith("@GENERATED")) {
generatedKeys = true;
sql = sql.substring("@GENERATED".length()).trim();
} else if(sql.startsWith("@LOOP")) {
metadata = true;
sql = sql.substring("@LOOP".length()).trim();
......@@ -934,16 +941,20 @@ public class AppThread extends WebServerThread {
getAppSession().executingStatement = stat;
boolean isResultSet = stat.execute(sql);
getAppSession().addCommand(sql);
if(!isResultSet) {
buff.append("${text.result.updateCount}: "+stat.getUpdateCount());
time = System.currentTimeMillis() - time;
buff.append("<br>(");
buff.append(time);
buff.append(" ms)");
stat.close();
return buff.toString();
if(generatedKeys) {
rs = stat.getGeneratedKeys();
} else {
if(!isResultSet) {
buff.append("${text.result.updateCount}: "+stat.getUpdateCount());
time = System.currentTimeMillis() - time;
buff.append("<br>(");
buff.append(time);
buff.append(" ms)");
stat.close();
return buff.toString();
}
rs = stat.getResultSet();
}
rs = stat.getResultSet();
}
time = System.currentTimeMillis() - time;
buff.append(getResultSet(sql, rs, metadata, edit, time, allowEdit));
......
......@@ -30,7 +30,7 @@ adminTitle=H2 Console Optionen
helpAction=Aktion
helpAddAnotherRow=F&uuml;gt einen weiteren Datensatz hinzu
helpAddDrivers=Datenbank Treiber hinzuf&uuml;gen
helpAddDriversOnlyJava=Zus&auml;zliche Treiber werden nur von der Java Version unterst&uuml;zt (nicht von der Native Version).
helpAddDriversOnlyJava=Zus&auml;tzliche Treiber werden nur von der Java Version unterst&uuml;tzt (nicht von der Native Version).
helpAddDriversText=Es ist m&ouml;glich zus&auml;tzliche Datenbank-Treiber zu laden, indem die Pfade der Treiber-Dateien in den Umgebungsvariablen H2DRIVERS oder CLASSPATH eingetragen werden. Beispiel (Windows): Um den Datenbank-Treiber mit dem Jar-File C:\\Programs\\hsqldb\\lib\\hsqldb.jar hinzuzuf&uuml;gen, setzen Sie den die Umgebungvariable H2DRIVERS auf C:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=F&uuml;gt einen Datensatz hinzu
helpCommandHistory=Zeigt die Befehls-Chronik
......
......@@ -22,7 +22,7 @@ public interface DataHandler {
String getLobCompressionAlgorithm(int type);
// only tempoarily, until LOB_FILES_IN_DIRECTORIES is enabled
// only temporarily, until LOB_FILES_IN_DIRECTORIES is enabled
int allocateObjectId(boolean needFresh, boolean dataFile);
String createTempFile() throws SQLException;
......
......@@ -9,6 +9,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException;
import java.util.Comparator;
......@@ -177,7 +178,7 @@ public class DiskFile implements CacheWriter {
byte[] b2 = buff.toByteArray();
return b2;
} catch(IOException e) {
// will probably never happend, because only in-memory strutures are used
// will probably never happen, because only in-memory strutures are used
return null;
}
}
......@@ -541,7 +542,7 @@ public class DiskFile implements CacheWriter {
}
// public void finalize() {
// if (!Database.RUN_FINALIZERS) {
// if (!Constants.RUN_FINALIZE) {
// return;
// }
// if (file != null) {
......@@ -652,16 +653,56 @@ public class DiskFile implements CacheWriter {
}
synchronized void writeDirect(Storage storage, int pos, byte[] data, int offset) throws SQLException {
synchronized(this) {
try {
go(pos);
file.write(data, offset, BLOCK_SIZE);
setBlockOwner(storage, pos, 1, true);
} catch (Exception e) {
throw Message.convert(e);
}
try {
go(pos);
file.write(data, offset, BLOCK_SIZE);
setBlockOwner(storage, pos, 1, true);
} catch (Exception e) {
throw Message.convert(e);
}
}
public synchronized int readDirect(int pos, OutputStream out) throws SQLException {
try {
if(pos < 0) {
// read the header
byte[] buffer = new byte[OFFSET];
file.seek(0);
file.readFully(buffer, 0, OFFSET);
out.write(buffer);
return 0;
}
if(pos >= fileBlockCount) {
return -1;
}
int blockSize = DiskFile.BLOCK_SIZE;
byte[] buff = new byte[blockSize];
DataPage s = DataPage.create(database, buff);
database.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, this.fileName, pos, fileBlockCount);
go(pos);
file.readFully(buff, 0, blockSize);
s.reset();
int blockCount = s.readInt();
if(Constants.CHECK && blockCount < 0) {
throw Message.getInternalError();
}
if(blockCount == 0) {
blockCount = 1;
}
int id = s.readInt();
if(Constants.CHECK && id < 0) {
throw Message.getInternalError();
}
s.checkCapacity(blockCount * blockSize);
if(blockCount > 1) {
file.readFully(s.getBytes(), blockSize, blockCount * blockSize - blockSize);
}
out.write(s.getBytes(), 0, blockCount * blockSize);
return pos + blockCount;
} catch (Exception e) {
throw Message.convert(e);
}
}
synchronized void removeRecord(Session session, int pos, Record record, int blockCount) throws SQLException {
if(logChanges) {
......
......@@ -33,7 +33,7 @@ public class FileLock {
public static final int LOCK_NO = 0, LOCK_FILE = 1, LOCK_SOCKET = 2;
// TODO lock: maybe not so secure! what if tread does not have chance to run?
// TODO lock: implement locking method using java 1.4 filelock
// TODO lock: implement locking method using java 1.4 FileLock
private static final String MAGIC = "FileLock";
private static final String FILE = "file", SOCKET = "socket";
private static final int RANDOM_BYTES = 16;
......@@ -68,7 +68,7 @@ public class FileLock {
}
protected void finalize() {
if (!Constants.RUN_FINALIZERS) {
if (!Constants.RUN_FINALIZE) {
return;
}
if(locked) {
......
......@@ -132,7 +132,7 @@ public class FileStoreInputStream extends InputStream {
}
protected void finalize() {
if (!Constants.RUN_FINALIZERS) {
if (!Constants.RUN_FINALIZE) {
return;
}
try {
......
......@@ -19,9 +19,9 @@ import org.h2.util.ObjectArray;
/*
* Header format:
* intfixed logId (<0 means ignore: rolled back already)
* intfixed firstUncommittedLogRecordId (-1 if none)
* intfixed firstUnwrittenLogRecordId (-1 if none)
* intFixed logId (<0 means ignore: rolled back already)
* intFixed firstUncommittedLogRecordId (-1 if none)
* intFixed firstUnwrittenLogRecordId (-1 if none)
*
* Record format:
* int block size
......@@ -58,7 +58,7 @@ public class LogFile {
this.database = log.getDatabase();
this.id = id;
this.fileNamePrefix = fileNamePrefix;
fileName = getFileName(id);
fileName = getFileName();
file = log.getDatabase().openFile(fileName, false);
rowBuff = log.getRowBuffer();
buffer = new byte[BUFFER_SIZE];
......@@ -86,7 +86,7 @@ public class LogFile {
return new LogFile(log, id, fileNamePrefix);
}
private String getFileName(int id) {
public String getFileName() {
return fileNamePrefix + "." + id + Constants.SUFFIX_LOG_FILE;
}
......
......@@ -37,6 +37,7 @@ public class LogSystem {
private boolean flushOnEachCommit;
private ObjectArray inDoubtTransactions;
private boolean disabled;
private int keepFiles;
public LogSystem(Database database, String fileNamePrefix, boolean readOnly) throws SQLException {
this.database = database;
......@@ -101,7 +102,7 @@ public class LogSystem {
for (int i = 0; i < activeLogs.size(); i++) {
LogFile l = (LogFile) activeLogs.get(i);
if (l.getFirstUncommittedPos() == LOG_WRITTEN) {
l.close(deleteOldLogFilesAutomatically);
closeOldFile(l);
activeLogs.remove(i);
i--;
}
......@@ -128,7 +129,7 @@ public class LogSystem {
try {
// if there are any in-doubt transactions (even if they are resolved), can't delete the log files
if (l.getFirstUncommittedPos() == LOG_WRITTEN && !containsInDoubtTransactions()) {
l.close(deleteOldLogFilesAutomatically);
closeOldFile(l);
} else {
l.close(false);
}
......@@ -196,6 +197,10 @@ public class LogSystem {
return fileChanged;
}
}
private void closeOldFile(LogFile l) throws SQLException {
l.close(deleteOldLogFilesAutomatically && keepFiles == 0);
}
private void loadActiveLogFiles() throws SQLException {
String path = FileUtils.getParent(fileNamePrefix);
......@@ -206,7 +211,7 @@ public class LogSystem {
LogFile l = LogFile.openIfLogFile(this, fileNamePrefix, s);
if (l != null) {
if (l.getPos() == LOG_WRITTEN) {
l.close(deleteOldLogFilesAutomatically);
closeOldFile(l);
} else {
activeLogs.add(l);
}
......@@ -361,6 +366,14 @@ public class LogSystem {
currentLog.flush();
}
}
public ObjectArray getActiveLogFiles() {
synchronized(database) {
ObjectArray list = new ObjectArray();
list.addAll(activeLogs);
return list;
}
}
private void writeSummary() throws SQLException {
if (database == null || readOnly || disabled) {
......@@ -423,4 +436,8 @@ public class LogSystem {
currentLog.addSummary(false, null);
}
public synchronized void updateKeepFiles(int incrementDecrement) {
keepFiles += incrementDecrement;
}
}
......@@ -16,8 +16,8 @@ import org.h2.util.MathUtils;
/**
* File format:
* intfixed block size
* intfixed storage id
* intFixed block size
* intFixed storage id
* record data
* byte checksum
* [bytes * fillerLength]
......
......@@ -15,7 +15,7 @@ import org.h2.util.ObjectArray;
public class UndoLog {
private Session session;
private Database database;
// TODO undolog entry: a chain would probably be faster & use less memory than an array
// TODO undo log entry: a chain would probably be faster & use less memory than an array
private ObjectArray records = new ObjectArray();
private FileStore file;
private DataPage rowBuff;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论