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

--no commit message

--no commit message
上级 e2d3afcb
...@@ -157,7 +157,7 @@ class ResultDiskBuffer { ...@@ -157,7 +157,7 @@ class ResultDiskBuffer {
} }
protected void finalize() { protected void finalize() {
if(!Constants.RUN_FINALIZERS) { if(!Constants.RUN_FINALIZE) {
return; return;
} }
close(); close();
......
...@@ -161,7 +161,7 @@ public class ResultRemote implements ResultInterface { ...@@ -161,7 +161,7 @@ public class ResultRemote implements ResultInterface {
if (session == null) { if (session == null) {
return; return;
} }
// TODO result sets: no reset possible for larger remote resultsets // TODO result sets: no reset possible for larger remote result sets
synchronized (session) { synchronized (session) {
try { try {
session.traceOperation("RESULT_CLOSE", id); session.traceOperation("RESULT_CLOSE", id);
...@@ -181,7 +181,7 @@ public class ResultRemote implements ResultInterface { ...@@ -181,7 +181,7 @@ public class ResultRemote implements ResultInterface {
} }
// public void finalize() { // public void finalize() {
// if(!Database.RUN_FINALIZERS) { // if(!Constants.RUN_FINALIZE) {
// return; // return;
// } // }
// close(); // close();
......
...@@ -53,22 +53,22 @@ public class SHA256 { ...@@ -53,22 +53,22 @@ public class SHA256 {
public byte[] getHash(byte[] data) { public byte[] getHash(byte[] data) {
int bytelen = data.length; int byteLen = data.length;
int intlen = ((bytelen + 9 + 63) / 64) * 16; int intLen = ((byteLen + 9 + 63) / 64) * 16;
byte[] bytes = new byte[intlen * 4]; byte[] bytes = new byte[intLen * 4];
System.arraycopy(data, 0, bytes, 0, bytelen); System.arraycopy(data, 0, bytes, 0, byteLen);
bytes[bytelen] = (byte) 0x80; bytes[byteLen] = (byte) 0x80;
int[] buff = new int[intlen]; int[] buff = new int[intLen];
for (int i = 0, j = 0; j < intlen; i += 4, j++) { for (int i = 0, j = 0; j < intLen; i += 4, j++) {
buff[j] = readInt(bytes, i); buff[j] = readInt(bytes, i);
} }
buff[intlen - 2] = bytelen >>> 29; buff[intLen - 2] = byteLen >>> 29;
buff[intlen - 1] = (bytelen << 3) & 0xffffffff; buff[intLen - 1] = (byteLen << 3) & 0xffffffff;
int[] w = new int[64]; int[] w = new int[64];
int[] hh = new int[] { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, int[] hh = new int[] { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; 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++) { for (int i = 0; i < 16; i++) {
w[i] = buff[block + i]; w[i] = buff[block + i];
} }
......
...@@ -42,7 +42,7 @@ public class AppServer { ...@@ -42,7 +42,7 @@ public class AppServer {
private int port; private int port;
private boolean allowOthers; private boolean allowOthers;
private boolean ssl; private boolean ssl;
private HashMap connectionInfos = new HashMap(); private HashMap connInfoMap = new HashMap();
AppServer(String[] args) { AppServer(String[] args) {
Properties prop = loadProperties(); Properties prop = loadProperties();
...@@ -101,16 +101,16 @@ public class AppServer { ...@@ -101,16 +101,16 @@ public class AppServer {
} }
ConnectionInfo getSetting(String name) { ConnectionInfo getSetting(String name) {
return (ConnectionInfo)connectionInfos.get(name); return (ConnectionInfo)connInfoMap.get(name);
} }
void updateSetting(ConnectionInfo info) { void updateSetting(ConnectionInfo info) {
connectionInfos.put(info.name, info); connInfoMap.put(info.name, info);
info.lastAccess = ticker++; info.lastAccess = ticker++;
} }
void removeSetting(String name) { void removeSetting(String name) {
connectionInfos.remove(name); connInfoMap.remove(name);
} }
private File getPropertiesFile() { private File getPropertiesFile() {
...@@ -139,7 +139,7 @@ public class AppServer { ...@@ -139,7 +139,7 @@ public class AppServer {
synchronized ArrayList getSettings() { synchronized ArrayList getSettings() {
ArrayList settings = new ArrayList(); ArrayList settings = new ArrayList();
if(connectionInfos.size() == 0) { if(connInfoMap.size() == 0) {
Properties prop = loadProperties(); Properties prop = loadProperties();
if(prop.size() == 0) { if(prop.size() == 0) {
for(int i=0; i<AppServer.GENERIC.length; i++) { for(int i=0; i<AppServer.GENERIC.length; i++) {
...@@ -159,7 +159,7 @@ public class AppServer { ...@@ -159,7 +159,7 @@ public class AppServer {
} }
} }
} else { } else {
settings.addAll(connectionInfos.values()); settings.addAll(connInfoMap.values());
} }
sortConnectionInfo(settings); sortConnectionInfo(settings);
return settings; return settings;
......
...@@ -331,6 +331,9 @@ public class AppThread extends WebServerThread { ...@@ -331,6 +331,9 @@ public class AppThread extends WebServerThread {
String ident = ", "+level+", "+(level+1)+", "; String ident = ", "+level+", "+(level+1)+", ";
String identNode = ", "+(level+1)+", "+(level+1)+", "; String identNode = ", "+(level+1)+", "+(level+1)+", ";
DbTableOrView[] tables = schema.tables; DbTableOrView[] tables = schema.tables;
if(tables == null) {
return treeIndex;
}
boolean isOracle = schema.contents.isOracle; boolean isOracle = schema.contents.isOracle;
boolean showColumnTypes = tables.length < 100; boolean showColumnTypes = tables.length < 100;
for(int i=0; i<tables.length; i++) { for(int i=0; i<tables.length; i++) {
...@@ -894,6 +897,7 @@ public class AppThread extends WebServerThread { ...@@ -894,6 +897,7 @@ public class AppThread extends WebServerThread {
ResultSet rs; ResultSet rs;
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
boolean metadata = false; boolean metadata = false;
boolean generatedKeys = false;
boolean edit = false; boolean edit = false;
if(sql.equals("@CANCEL")) { if(sql.equals("@CANCEL")) {
stat = getAppSession().executingStatement; stat = getAppSession().executingStatement;
...@@ -907,6 +911,9 @@ public class AppThread extends WebServerThread { ...@@ -907,6 +911,9 @@ public class AppThread extends WebServerThread {
} else if(sql.startsWith("@META")) { } else if(sql.startsWith("@META")) {
metadata = true; metadata = true;
sql = sql.substring("@META".length()).trim(); sql = sql.substring("@META".length()).trim();
} else if(sql.startsWith("@GENERATED")) {
generatedKeys = true;
sql = sql.substring("@GENERATED".length()).trim();
} else if(sql.startsWith("@LOOP")) { } else if(sql.startsWith("@LOOP")) {
metadata = true; metadata = true;
sql = sql.substring("@LOOP".length()).trim(); sql = sql.substring("@LOOP".length()).trim();
...@@ -934,6 +941,9 @@ public class AppThread extends WebServerThread { ...@@ -934,6 +941,9 @@ public class AppThread extends WebServerThread {
getAppSession().executingStatement = stat; getAppSession().executingStatement = stat;
boolean isResultSet = stat.execute(sql); boolean isResultSet = stat.execute(sql);
getAppSession().addCommand(sql); getAppSession().addCommand(sql);
if(generatedKeys) {
rs = stat.getGeneratedKeys();
} else {
if(!isResultSet) { if(!isResultSet) {
buff.append("${text.result.updateCount}: "+stat.getUpdateCount()); buff.append("${text.result.updateCount}: "+stat.getUpdateCount());
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
...@@ -945,6 +955,7 @@ public class AppThread extends WebServerThread { ...@@ -945,6 +955,7 @@ public class AppThread extends WebServerThread {
} }
rs = stat.getResultSet(); rs = stat.getResultSet();
} }
}
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
buff.append(getResultSet(sql, rs, metadata, edit, time, allowEdit)); buff.append(getResultSet(sql, rs, metadata, edit, time, allowEdit));
if(!edit) { if(!edit) {
......
...@@ -30,7 +30,7 @@ adminTitle=H2 Console Optionen ...@@ -30,7 +30,7 @@ adminTitle=H2 Console Optionen
helpAction=Aktion helpAction=Aktion
helpAddAnotherRow=F&uuml;gt einen weiteren Datensatz hinzu helpAddAnotherRow=F&uuml;gt einen weiteren Datensatz hinzu
helpAddDrivers=Datenbank Treiber hinzuf&uuml;gen 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. 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 helpAddRow=F&uuml;gt einen Datensatz hinzu
helpCommandHistory=Zeigt die Befehls-Chronik helpCommandHistory=Zeigt die Befehls-Chronik
......
...@@ -22,7 +22,7 @@ public interface DataHandler { ...@@ -22,7 +22,7 @@ public interface DataHandler {
String getLobCompressionAlgorithm(int type); 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); int allocateObjectId(boolean needFresh, boolean dataFile);
String createTempFile() throws SQLException; String createTempFile() throws SQLException;
......
...@@ -9,6 +9,7 @@ import java.io.ByteArrayOutputStream; ...@@ -9,6 +9,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Comparator; import java.util.Comparator;
...@@ -177,7 +178,7 @@ public class DiskFile implements CacheWriter { ...@@ -177,7 +178,7 @@ public class DiskFile implements CacheWriter {
byte[] b2 = buff.toByteArray(); byte[] b2 = buff.toByteArray();
return b2; return b2;
} catch(IOException e) { } 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; return null;
} }
} }
...@@ -541,7 +542,7 @@ public class DiskFile implements CacheWriter { ...@@ -541,7 +542,7 @@ public class DiskFile implements CacheWriter {
} }
// public void finalize() { // public void finalize() {
// if (!Database.RUN_FINALIZERS) { // if (!Constants.RUN_FINALIZE) {
// return; // return;
// } // }
// if (file != null) { // if (file != null) {
...@@ -652,7 +653,6 @@ public class DiskFile implements CacheWriter { ...@@ -652,7 +653,6 @@ public class DiskFile implements CacheWriter {
} }
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 {
synchronized(this) {
try { try {
go(pos); go(pos);
file.write(data, offset, BLOCK_SIZE); file.write(data, offset, BLOCK_SIZE);
...@@ -661,6 +661,47 @@ public class DiskFile implements CacheWriter { ...@@ -661,6 +661,47 @@ public class DiskFile implements CacheWriter {
throw Message.convert(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 { synchronized void removeRecord(Session session, int pos, Record record, int blockCount) throws SQLException {
......
...@@ -33,7 +33,7 @@ public class FileLock { ...@@ -33,7 +33,7 @@ public class FileLock {
public static final int LOCK_NO = 0, LOCK_FILE = 1, LOCK_SOCKET = 2; 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: 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 MAGIC = "FileLock";
private static final String FILE = "file", SOCKET = "socket"; private static final String FILE = "file", SOCKET = "socket";
private static final int RANDOM_BYTES = 16; private static final int RANDOM_BYTES = 16;
...@@ -68,7 +68,7 @@ public class FileLock { ...@@ -68,7 +68,7 @@ public class FileLock {
} }
protected void finalize() { protected void finalize() {
if (!Constants.RUN_FINALIZERS) { if (!Constants.RUN_FINALIZE) {
return; return;
} }
if(locked) { if(locked) {
......
...@@ -132,7 +132,7 @@ public class FileStoreInputStream extends InputStream { ...@@ -132,7 +132,7 @@ public class FileStoreInputStream extends InputStream {
} }
protected void finalize() { protected void finalize() {
if (!Constants.RUN_FINALIZERS) { if (!Constants.RUN_FINALIZE) {
return; return;
} }
try { try {
......
...@@ -19,9 +19,9 @@ import org.h2.util.ObjectArray; ...@@ -19,9 +19,9 @@ import org.h2.util.ObjectArray;
/* /*
* Header format: * Header format:
* intfixed logId (<0 means ignore: rolled back already) * intFixed logId (<0 means ignore: rolled back already)
* intfixed firstUncommittedLogRecordId (-1 if none) * intFixed firstUncommittedLogRecordId (-1 if none)
* intfixed firstUnwrittenLogRecordId (-1 if none) * intFixed firstUnwrittenLogRecordId (-1 if none)
* *
* Record format: * Record format:
* int block size * int block size
...@@ -58,7 +58,7 @@ public class LogFile { ...@@ -58,7 +58,7 @@ public class LogFile {
this.database = log.getDatabase(); this.database = log.getDatabase();
this.id = id; this.id = id;
this.fileNamePrefix = fileNamePrefix; this.fileNamePrefix = fileNamePrefix;
fileName = getFileName(id); fileName = getFileName();
file = log.getDatabase().openFile(fileName, false); file = log.getDatabase().openFile(fileName, false);
rowBuff = log.getRowBuffer(); rowBuff = log.getRowBuffer();
buffer = new byte[BUFFER_SIZE]; buffer = new byte[BUFFER_SIZE];
...@@ -86,7 +86,7 @@ public class LogFile { ...@@ -86,7 +86,7 @@ public class LogFile {
return new LogFile(log, id, fileNamePrefix); return new LogFile(log, id, fileNamePrefix);
} }
private String getFileName(int id) { public String getFileName() {
return fileNamePrefix + "." + id + Constants.SUFFIX_LOG_FILE; return fileNamePrefix + "." + id + Constants.SUFFIX_LOG_FILE;
} }
......
...@@ -37,6 +37,7 @@ public class LogSystem { ...@@ -37,6 +37,7 @@ public class LogSystem {
private boolean flushOnEachCommit; private boolean flushOnEachCommit;
private ObjectArray inDoubtTransactions; private ObjectArray inDoubtTransactions;
private boolean disabled; private boolean disabled;
private int keepFiles;
public LogSystem(Database database, String fileNamePrefix, boolean readOnly) throws SQLException { public LogSystem(Database database, String fileNamePrefix, boolean readOnly) throws SQLException {
this.database = database; this.database = database;
...@@ -101,7 +102,7 @@ public class LogSystem { ...@@ -101,7 +102,7 @@ public class LogSystem {
for (int i = 0; i < activeLogs.size(); i++) { for (int i = 0; i < activeLogs.size(); i++) {
LogFile l = (LogFile) activeLogs.get(i); LogFile l = (LogFile) activeLogs.get(i);
if (l.getFirstUncommittedPos() == LOG_WRITTEN) { if (l.getFirstUncommittedPos() == LOG_WRITTEN) {
l.close(deleteOldLogFilesAutomatically); closeOldFile(l);
activeLogs.remove(i); activeLogs.remove(i);
i--; i--;
} }
...@@ -128,7 +129,7 @@ public class LogSystem { ...@@ -128,7 +129,7 @@ public class LogSystem {
try { try {
// if there are any in-doubt transactions (even if they are resolved), can't delete the log files // if there are any in-doubt transactions (even if they are resolved), can't delete the log files
if (l.getFirstUncommittedPos() == LOG_WRITTEN && !containsInDoubtTransactions()) { if (l.getFirstUncommittedPos() == LOG_WRITTEN && !containsInDoubtTransactions()) {
l.close(deleteOldLogFilesAutomatically); closeOldFile(l);
} else { } else {
l.close(false); l.close(false);
} }
...@@ -197,6 +198,10 @@ public class LogSystem { ...@@ -197,6 +198,10 @@ public class LogSystem {
} }
} }
private void closeOldFile(LogFile l) throws SQLException {
l.close(deleteOldLogFilesAutomatically && keepFiles == 0);
}
private void loadActiveLogFiles() throws SQLException { private void loadActiveLogFiles() throws SQLException {
String path = FileUtils.getParent(fileNamePrefix); String path = FileUtils.getParent(fileNamePrefix);
String[] list = FileUtils.listFiles(path); String[] list = FileUtils.listFiles(path);
...@@ -206,7 +211,7 @@ public class LogSystem { ...@@ -206,7 +211,7 @@ public class LogSystem {
LogFile l = LogFile.openIfLogFile(this, fileNamePrefix, s); LogFile l = LogFile.openIfLogFile(this, fileNamePrefix, s);
if (l != null) { if (l != null) {
if (l.getPos() == LOG_WRITTEN) { if (l.getPos() == LOG_WRITTEN) {
l.close(deleteOldLogFilesAutomatically); closeOldFile(l);
} else { } else {
activeLogs.add(l); activeLogs.add(l);
} }
...@@ -362,6 +367,14 @@ public class LogSystem { ...@@ -362,6 +367,14 @@ public class LogSystem {
} }
} }
public ObjectArray getActiveLogFiles() {
synchronized(database) {
ObjectArray list = new ObjectArray();
list.addAll(activeLogs);
return list;
}
}
private void writeSummary() throws SQLException { private void writeSummary() throws SQLException {
if (database == null || readOnly || disabled) { if (database == null || readOnly || disabled) {
return; return;
...@@ -423,4 +436,8 @@ public class LogSystem { ...@@ -423,4 +436,8 @@ public class LogSystem {
currentLog.addSummary(false, null); currentLog.addSummary(false, null);
} }
public synchronized void updateKeepFiles(int incrementDecrement) {
keepFiles += incrementDecrement;
}
} }
...@@ -16,8 +16,8 @@ import org.h2.util.MathUtils; ...@@ -16,8 +16,8 @@ import org.h2.util.MathUtils;
/** /**
* File format: * File format:
* intfixed block size * intFixed block size
* intfixed storage id * intFixed storage id
* record data * record data
* byte checksum * byte checksum
* [bytes * fillerLength] * [bytes * fillerLength]
......
...@@ -15,7 +15,7 @@ import org.h2.util.ObjectArray; ...@@ -15,7 +15,7 @@ import org.h2.util.ObjectArray;
public class UndoLog { public class UndoLog {
private Session session; private Session session;
private Database database; 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 ObjectArray records = new ObjectArray();
private FileStore file; private FileStore file;
private DataPage rowBuff; private DataPage rowBuff;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论