提交 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 {
public Table getRefTable() {
return table;
}
public String getDropSQL() {
return null;
}
}
......@@ -56,6 +56,10 @@ public class Comment extends DbObject {
return "type" + type;
}
}
public String getDropSQL() {
return null;
}
public String getCreateSQL() {
StringBuffer buff = new StringBuffer();
......
......@@ -27,7 +27,7 @@ package org.h2.engine;
* ant codeswitch_jdk14
*
* - 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
* - No " Message.getInternalError" (must be "throw Message.getInternalError")
* - No TODO in the docs
......@@ -66,8 +66,8 @@ package org.h2.engine;
*/
public class Constants {
public static final int BUILD_ID = 44;
private static final String BUILD = "2007-03-04";
public static final int BUILD_ID = 45;
private static final String BUILD = "2007-03-20";
public static final int VERSION_MAJOR = 1;
public static final int VERSION_MINOR = 0;
......@@ -106,6 +106,7 @@ public class Constants {
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_LOG_FILE = ".log.db";
public static final String SUFFIX_INDEX_FILE = ".index.db";
......
......@@ -45,6 +45,7 @@ import org.h2.tools.DeleteDbFiles;
import org.h2.util.BitField;
import org.h2.util.ByteUtils;
import org.h2.util.CacheLRU;
import org.h2.util.ClassUtils;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
import org.h2.util.MemoryFile;
......@@ -291,16 +292,10 @@ public class Database implements DataHandler {
}
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)) {
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 {
store.init();
} catch(SQLException e) {
......@@ -417,6 +412,9 @@ public class Database implements DataHandler {
} else {
traceSystem = new TraceSystem(databaseName+Constants.SUFFIX_TRACE_FILE);
}
if(cipher != null) {
traceSystem.setManualEnabling(false);
}
traceSystem.setLevelFile(traceLevelFile);
traceSystem.setLevelSystemOut(traceLevelSystemOut);
traceSystem.getTrace(Trace.DATABASE).info("opening " + databaseName + " (build "+Constants.BUILD_ID+")");
......@@ -1007,7 +1005,8 @@ public class Database implements DataHandler {
public String createTempFile() throws SQLException {
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) {
throw Message.convert(e);
}
......@@ -1220,7 +1219,7 @@ public class Database implements DataHandler {
}
public Class loadClass(String className) throws ClassNotFoundException {
return Class.forName(className);
return ClassUtils.loadClass(className);
}
public void setEventListener(String className) throws SQLException {
......
......@@ -108,6 +108,8 @@ public abstract class DbObject {
public abstract String getCreateSQLForCopy(Table table, String quotedName);
public abstract String getCreateSQL();
public abstract String getDropSQL();
public abstract int getType();
public abstract void removeChildrenAndResources(Session session) throws SQLException;
public abstract void checkRename() throws SQLException;
......
......@@ -105,6 +105,10 @@ public class FunctionAlias extends DbObject {
throw Message.getInternalError();
}
public String getDropSQL() {
return "DROP ALIAS IF EXISTS " + getSQL();
}
public String getCreateSQL() {
StringBuffer buff = new StringBuffer();
buff.append("CREATE ALIAS ");
......
......@@ -69,6 +69,10 @@ public class Right extends DbObject {
return grantee;
}
public String getDropSQL() {
return null;
}
public String getCreateSQLForCopy(Table table, String quotedName) {
StringBuffer buff = new StringBuffer();
buff.append("GRANT ");
......
......@@ -24,6 +24,10 @@ public class Role extends RightOwner {
throw Message.getInternalError();
}
public String getDropSQL() {
return null;
}
public String getCreateSQL() {
if(system) {
return null;
......
......@@ -26,7 +26,6 @@ import org.h2.store.LogSystem;
import org.h2.store.UndoLog;
import org.h2.store.UndoLogRecord;
import org.h2.table.Table;
import org.h2.table.TableData;
import org.h2.util.ObjectArray;
import org.h2.value.Value;
import org.h2.value.ValueLong;
......@@ -88,8 +87,8 @@ public class Session implements SessionInterface {
}
}
public void addLocalTempTable(TableData table) throws SQLException {
cleanTempTables();
public void addLocalTempTable(Table table) throws SQLException {
cleanTempTables(false);
if(localTempTables == null) {
localTempTables = new HashMap();
}
......@@ -195,7 +194,8 @@ public class Session implements SessionInterface {
}
if(undoLog.size() > 0) {
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) {
// 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 {
if(locks.size() > 0 || needCommit) {
logSystem.commit(this);
}
cleanTempTables();
cleanTempTables(false);
unlockAll();
}
......@@ -252,6 +252,7 @@ public class Session implements SessionInterface {
public void close() throws SQLException {
if(database != null) {
try {
cleanTempTables(true);
database.removeSession(this);
} finally {
database = null;
......@@ -295,13 +296,13 @@ public class Session implements SessionInterface {
locks.clear();
savepoints = null;
}
private void cleanTempTables() throws SQLException {
private void cleanTempTables(boolean closeSession) throws SQLException {
if(localTempTables != null && localTempTables.size()>0) {
ObjectArray list = new ObjectArray(localTempTables.values());
for(int i=0; i<list.size(); i++) {
TableData table = (TableData) list.get(i);
if(table.isOnCommitDrop()) {
Table table = (Table) list.get(i);
if(closeSession || table.isOnCommitDrop()) {
table.setModified();
localTempTables.remove(table.getName());
table.removeChildrenAndResources(this);
......
......@@ -178,7 +178,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
if(traceLevelFile != null) {
int level = Integer.parseInt(traceLevelFile);
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.setLevelFile(level);
}
......@@ -323,7 +323,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
public String createTempFile() throws SQLException {
try {
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true);
return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, false);
} catch (IOException e) {
throw Message.convert(e);
}
......@@ -367,6 +367,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
} else {
store = FileStore.open(this, name, magic, cipher, fileEncryptionKey, 0);
}
store.setCheckedWriting(false);
try {
store.init();
} catch(SQLException e) {
......
......@@ -38,6 +38,10 @@ public class Setting extends DbObject {
throw Message.getInternalError();
}
public String getDropSQL() {
return null;
}
public String getCreateSQL() {
StringBuffer buff = new StringBuffer();
buff.append("SET ");
......
......@@ -58,6 +58,10 @@ public class User extends RightOwner {
return getCreateSQL(true, false);
}
public String getDropSQL() {
return null;
}
public void checkRight(Table table, int rightMask) throws SQLException {
if(rightMask != Right.SELECT && !systemUser) {
database.checkWritingAllowed();
......
......@@ -22,6 +22,10 @@ public class UserDataType extends DbObject {
public String getCreateSQLForCopy(Table table, String quotedName) {
throw Message.getInternalError();
}
public String getDropSQL() {
return "DROP DOMAIN IF EXISTS " + getSQL();
}
public String getCreateSQL() {
StringBuffer buff = new StringBuffer();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论