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

--no commit message

--no commit message
上级 b9e6c06e
...@@ -53,5 +53,9 @@ public abstract class Constraint extends SchemaObject { ...@@ -53,5 +53,9 @@ public abstract class Constraint extends SchemaObject {
public Table getRefTable() { public Table getRefTable() {
return table; return table;
} }
public String getDropSQL() {
return null;
}
} }
...@@ -56,6 +56,10 @@ public class Comment extends DbObject { ...@@ -56,6 +56,10 @@ public class Comment extends DbObject {
return "type" + type; return "type" + type;
} }
} }
public String getDropSQL() {
return null;
}
public String getCreateSQL() { public String getCreateSQL() {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
......
...@@ -27,7 +27,7 @@ package org.h2.engine; ...@@ -27,7 +27,7 @@ package org.h2.engine;
* ant codeswitch_jdk14 * ant codeswitch_jdk14
* *
* - Change FAQ (next release planned, known bugs) * - Change FAQ (next release planned, known bugs)
* - Check version, change build number in Constants.java and build.xml * - Check version, change build number in Constants.java and ant-build.properties
* - Check code coverage * - Check code coverage
* - No " Message.getInternalError" (must be "throw Message.getInternalError") * - No " Message.getInternalError" (must be "throw Message.getInternalError")
* - No TODO in the docs * - No TODO in the docs
...@@ -66,8 +66,8 @@ package org.h2.engine; ...@@ -66,8 +66,8 @@ package org.h2.engine;
*/ */
public class Constants { public class Constants {
public static final int BUILD_ID = 44; public static final int BUILD_ID = 45;
private static final String BUILD = "2007-03-04"; private static final String BUILD = "2007-03-20";
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;
...@@ -106,6 +106,7 @@ public class Constants { ...@@ -106,6 +106,7 @@ public class Constants {
public static final int DEFAULT_CACHE_SIZE_LINEAR_INDEX = 1 << 8; public static final int DEFAULT_CACHE_SIZE_LINEAR_INDEX = 1 << 8;
public static final String SUFFIX_DB_FILE = ".db";
public static final String SUFFIX_DATA_FILE = ".data.db"; public static final String SUFFIX_DATA_FILE = ".data.db";
public static final String SUFFIX_LOG_FILE = ".log.db"; public static final String SUFFIX_LOG_FILE = ".log.db";
public static final String SUFFIX_INDEX_FILE = ".index.db"; public static final String SUFFIX_INDEX_FILE = ".index.db";
......
...@@ -45,6 +45,7 @@ import org.h2.tools.DeleteDbFiles; ...@@ -45,6 +45,7 @@ import org.h2.tools.DeleteDbFiles;
import org.h2.util.BitField; import org.h2.util.BitField;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.CacheLRU; import org.h2.util.CacheLRU;
import org.h2.util.ClassUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.MemoryFile; import org.h2.util.MemoryFile;
...@@ -291,16 +292,10 @@ public class Database implements DataHandler { ...@@ -291,16 +292,10 @@ public class Database implements DataHandler {
} }
public FileStore openFile(String name, boolean mustExist) throws SQLException { public FileStore openFile(String name, boolean mustExist) throws SQLException {
return openFile(name, false, mustExist);
}
public FileStore openFile(String name, boolean notEncrypted, boolean mustExist) throws SQLException {
String c = notEncrypted ? null : cipher;
byte[] h = notEncrypted ? null : filePasswordHash;
if(mustExist && !FileUtils.exists(name)) { if(mustExist && !FileUtils.exists(name)) {
throw Message.getSQLException(Message.FILE_CORRUPTED_1, name); throw Message.getSQLException(Message.FILE_CORRUPTED_1, name);
} }
FileStore store = FileStore.open(this, name, getMagic(), c, h); FileStore store = FileStore.open(this, name, getMagic(), cipher, filePasswordHash);
try { try {
store.init(); store.init();
} catch(SQLException e) { } catch(SQLException e) {
...@@ -417,6 +412,9 @@ public class Database implements DataHandler { ...@@ -417,6 +412,9 @@ public class Database implements DataHandler {
} else { } else {
traceSystem = new TraceSystem(databaseName+Constants.SUFFIX_TRACE_FILE); traceSystem = new TraceSystem(databaseName+Constants.SUFFIX_TRACE_FILE);
} }
if(cipher != null) {
traceSystem.setManualEnabling(false);
}
traceSystem.setLevelFile(traceLevelFile); traceSystem.setLevelFile(traceLevelFile);
traceSystem.setLevelSystemOut(traceLevelSystemOut); traceSystem.setLevelSystemOut(traceLevelSystemOut);
traceSystem.getTrace(Trace.DATABASE).info("opening " + databaseName + " (build "+Constants.BUILD_ID+")"); traceSystem.getTrace(Trace.DATABASE).info("opening " + databaseName + " (build "+Constants.BUILD_ID+")");
...@@ -1007,7 +1005,8 @@ public class Database implements DataHandler { ...@@ -1007,7 +1005,8 @@ public class Database implements DataHandler {
public String createTempFile() throws SQLException { public String createTempFile() throws SQLException {
try { try {
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true); boolean inTempDir = readOnly;
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, inTempDir);
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convert(e);
} }
...@@ -1220,7 +1219,7 @@ public class Database implements DataHandler { ...@@ -1220,7 +1219,7 @@ public class Database implements DataHandler {
} }
public Class loadClass(String className) throws ClassNotFoundException { public Class loadClass(String className) throws ClassNotFoundException {
return Class.forName(className); return ClassUtils.loadClass(className);
} }
public void setEventListener(String className) throws SQLException { public void setEventListener(String className) throws SQLException {
......
...@@ -108,6 +108,8 @@ public abstract class DbObject { ...@@ -108,6 +108,8 @@ public abstract class DbObject {
public abstract String getCreateSQLForCopy(Table table, String quotedName); public abstract String getCreateSQLForCopy(Table table, String quotedName);
public abstract String getCreateSQL(); public abstract String getCreateSQL();
public abstract String getDropSQL();
public abstract int getType(); public abstract int getType();
public abstract void removeChildrenAndResources(Session session) throws SQLException; public abstract void removeChildrenAndResources(Session session) throws SQLException;
public abstract void checkRename() throws SQLException; public abstract void checkRename() throws SQLException;
......
...@@ -105,6 +105,10 @@ public class FunctionAlias extends DbObject { ...@@ -105,6 +105,10 @@ public class FunctionAlias extends DbObject {
throw Message.getInternalError(); throw Message.getInternalError();
} }
public String getDropSQL() {
return "DROP ALIAS IF EXISTS " + getSQL();
}
public String getCreateSQL() { public String getCreateSQL() {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
buff.append("CREATE ALIAS "); buff.append("CREATE ALIAS ");
......
...@@ -69,6 +69,10 @@ public class Right extends DbObject { ...@@ -69,6 +69,10 @@ public class Right extends DbObject {
return grantee; return grantee;
} }
public String getDropSQL() {
return null;
}
public String getCreateSQLForCopy(Table table, String quotedName) { public String getCreateSQLForCopy(Table table, String quotedName) {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
buff.append("GRANT "); buff.append("GRANT ");
......
...@@ -24,6 +24,10 @@ public class Role extends RightOwner { ...@@ -24,6 +24,10 @@ public class Role extends RightOwner {
throw Message.getInternalError(); throw Message.getInternalError();
} }
public String getDropSQL() {
return null;
}
public String getCreateSQL() { public String getCreateSQL() {
if(system) { if(system) {
return null; return null;
......
...@@ -26,7 +26,6 @@ import org.h2.store.LogSystem; ...@@ -26,7 +26,6 @@ import org.h2.store.LogSystem;
import org.h2.store.UndoLog; import org.h2.store.UndoLog;
import org.h2.store.UndoLogRecord; import org.h2.store.UndoLogRecord;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableData;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
...@@ -88,8 +87,8 @@ public class Session implements SessionInterface { ...@@ -88,8 +87,8 @@ public class Session implements SessionInterface {
} }
} }
public void addLocalTempTable(TableData table) throws SQLException { public void addLocalTempTable(Table table) throws SQLException {
cleanTempTables(); cleanTempTables(false);
if(localTempTables == null) { if(localTempTables == null) {
localTempTables = new HashMap(); localTempTables = new HashMap();
} }
...@@ -195,7 +194,8 @@ public class Session implements SessionInterface { ...@@ -195,7 +194,8 @@ public class Session implements SessionInterface {
} }
if(undoLog.size() > 0) { if(undoLog.size() > 0) {
undoLog.clear(); undoLog.clear();
cleanTempTables(); // do not clean the temp tables if the last command was a create/drop
cleanTempTables(false);
} }
if(unlinkSet != null && unlinkSet.size() > 0) { if(unlinkSet != null && unlinkSet.size() > 0) {
// need to flush the log file, because we can't unlink lobs if the commit record is not written // need to flush the log file, because we can't unlink lobs if the commit record is not written
...@@ -219,7 +219,7 @@ public class Session implements SessionInterface { ...@@ -219,7 +219,7 @@ public class Session implements SessionInterface {
if(locks.size() > 0 || needCommit) { if(locks.size() > 0 || needCommit) {
logSystem.commit(this); logSystem.commit(this);
} }
cleanTempTables(); cleanTempTables(false);
unlockAll(); unlockAll();
} }
...@@ -252,6 +252,7 @@ public class Session implements SessionInterface { ...@@ -252,6 +252,7 @@ public class Session implements SessionInterface {
public void close() throws SQLException { public void close() throws SQLException {
if(database != null) { if(database != null) {
try { try {
cleanTempTables(true);
database.removeSession(this); database.removeSession(this);
} finally { } finally {
database = null; database = null;
...@@ -295,13 +296,13 @@ public class Session implements SessionInterface { ...@@ -295,13 +296,13 @@ public class Session implements SessionInterface {
locks.clear(); locks.clear();
savepoints = null; savepoints = null;
} }
private void cleanTempTables() throws SQLException { private void cleanTempTables(boolean closeSession) throws SQLException {
if(localTempTables != null && localTempTables.size()>0) { if(localTempTables != null && localTempTables.size()>0) {
ObjectArray list = new ObjectArray(localTempTables.values()); ObjectArray list = new ObjectArray(localTempTables.values());
for(int i=0; i<list.size(); i++) { for(int i=0; i<list.size(); i++) {
TableData table = (TableData) list.get(i); Table table = (Table) list.get(i);
if(table.isOnCommitDrop()) { if(closeSession || table.isOnCommitDrop()) {
table.setModified(); table.setModified();
localTempTables.remove(table.getName()); localTempTables.remove(table.getName());
table.removeChildrenAndResources(this); table.removeChildrenAndResources(this);
......
...@@ -178,7 +178,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -178,7 +178,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
if(traceLevelFile != null) { if(traceLevelFile != null) {
int level = Integer.parseInt(traceLevelFile); int level = Integer.parseInt(traceLevelFile);
String prefix = getTraceFilePrefix(databaseName); String prefix = getTraceFilePrefix(databaseName);
String file = FileUtils.createTempFile(prefix, Constants.SUFFIX_TRACE_FILE, false); String file = FileUtils.createTempFile(prefix, Constants.SUFFIX_TRACE_FILE, false, false);
traceSystem.setFileName(file); traceSystem.setFileName(file);
traceSystem.setLevelFile(level); traceSystem.setLevelFile(level);
} }
...@@ -323,7 +323,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -323,7 +323,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
public String createTempFile() throws SQLException { public String createTempFile() throws SQLException {
try { try {
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true); return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, false);
} catch (IOException e) { } catch (IOException e) {
throw Message.convert(e); throw Message.convert(e);
} }
...@@ -367,6 +367,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -367,6 +367,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
} else { } else {
store = FileStore.open(this, name, magic, cipher, fileEncryptionKey, 0); store = FileStore.open(this, name, magic, cipher, fileEncryptionKey, 0);
} }
store.setCheckedWriting(false);
try { try {
store.init(); store.init();
} catch(SQLException e) { } catch(SQLException e) {
......
...@@ -38,6 +38,10 @@ public class Setting extends DbObject { ...@@ -38,6 +38,10 @@ public class Setting extends DbObject {
throw Message.getInternalError(); throw Message.getInternalError();
} }
public String getDropSQL() {
return null;
}
public String getCreateSQL() { public String getCreateSQL() {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
buff.append("SET "); buff.append("SET ");
......
...@@ -58,6 +58,10 @@ public class User extends RightOwner { ...@@ -58,6 +58,10 @@ public class User extends RightOwner {
return getCreateSQL(true, false); return getCreateSQL(true, false);
} }
public String getDropSQL() {
return null;
}
public void checkRight(Table table, int rightMask) throws SQLException { public void checkRight(Table table, int rightMask) throws SQLException {
if(rightMask != Right.SELECT && !systemUser) { if(rightMask != Right.SELECT && !systemUser) {
database.checkWritingAllowed(); database.checkWritingAllowed();
......
...@@ -22,6 +22,10 @@ public class UserDataType extends DbObject { ...@@ -22,6 +22,10 @@ public class UserDataType extends DbObject {
public String getCreateSQLForCopy(Table table, String quotedName) { public String getCreateSQLForCopy(Table table, String quotedName) {
throw Message.getInternalError(); throw Message.getInternalError();
} }
public String getDropSQL() {
return "DROP DOMAIN IF EXISTS " + getSQL();
}
public String getCreateSQL() { public String getCreateSQL() {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论