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

New experimental LOB storage.

上级 1df42bbd
...@@ -62,7 +62,7 @@ public class DropDatabase extends DefineCommand { ...@@ -62,7 +62,7 @@ public class DropDatabase extends DefineCommand {
} }
} }
for (Table t : tables) { for (Table t : tables) {
if (t.getName() != null && Table.TABLE.equals(t.getTableType())) { if (t.getName() != null && Table.TABLE.equals(t.getTableType()) && !t.isHidden()) {
db.removeSchemaObject(session, t); db.removeSchemaObject(session, t);
} }
} }
...@@ -75,6 +75,9 @@ public class DropDatabase extends DefineCommand { ...@@ -75,6 +75,9 @@ public class DropDatabase extends DefineCommand {
list.addAll(db.getAllSchemaObjects(DbObject.TRIGGER)); list.addAll(db.getAllSchemaObjects(DbObject.TRIGGER));
list.addAll(db.getAllSchemaObjects(DbObject.CONSTANT)); list.addAll(db.getAllSchemaObjects(DbObject.CONSTANT));
for (SchemaObject obj : list) { for (SchemaObject obj : list) {
if (obj.isHidden()) {
continue;
}
db.removeSchemaObject(session, obj); db.removeSchemaObject(session, obj);
} }
for (User user : db.getAllUsers()) { for (User user : db.getAllUsers()) {
......
...@@ -174,4 +174,8 @@ public abstract class Constraint extends SchemaObjectBase implements Comparable< ...@@ -174,4 +174,8 @@ public abstract class Constraint extends SchemaObjectBase implements Comparable<
return thisType - otherType; return thisType - otherType;
} }
public boolean isHidden() {
return table.isHidden();
}
} }
...@@ -2034,7 +2034,8 @@ public class Database implements DataHandler { ...@@ -2034,7 +2034,8 @@ public class Database implements DataHandler {
public Table getFirstUserTable() { public Table getFirstUserTable() {
for (Table table : getAllTablesAndViews(false)) { for (Table table : getAllTablesAndViews(false)) {
if (table.getCreateSQL() != null) { if (table.getCreateSQL() != null) {
if (SysProperties.LOB_IN_DATABASE && table.getSchema() == infoSchema) { if (table.isHidden()) {
// LOB tables
continue; continue;
} }
return table; return table;
......
...@@ -371,4 +371,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -371,4 +371,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
throw DbException.getUnsupportedException(toString()); throw DbException.getUnsupportedException(toString());
} }
public boolean isHidden() {
return table.isHidden();
}
} }
...@@ -320,4 +320,8 @@ public class MultiVersionIndex implements Index { ...@@ -320,4 +320,8 @@ public class MultiVersionIndex implements Index {
return base.getRow(session, key); return base.getRow(session, key);
} }
public boolean isHidden() {
return base.isHidden();
}
} }
...@@ -19,4 +19,13 @@ public interface SchemaObject extends DbObject { ...@@ -19,4 +19,13 @@ public interface SchemaObject extends DbObject {
* @return the schema * @return the schema
*/ */
Schema getSchema(); Schema getSchema();
/**
* Check whether this is a hidden object that doesn't appear in the meta
* data and in the script, and is not dropped on DROP ALL OBJECTS.
*
* @return true if it is hidden
*/
boolean isHidden();
} }
...@@ -36,4 +36,8 @@ public abstract class SchemaObjectBase extends DbObjectBase implements SchemaObj ...@@ -36,4 +36,8 @@ public abstract class SchemaObjectBase extends DbObjectBase implements SchemaObj
return schema.getSQL() + "." + super.getSQL(); return schema.getSQL() + "." + super.getSQL();
} }
public boolean isHidden() {
return false;
}
} }
...@@ -69,7 +69,6 @@ public class LobStorage { ...@@ -69,7 +69,6 @@ public class LobStorage {
if (conn == null) { if (conn == null) {
return; return;
} }
int todoDatabaseGetFirstUserTable;
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
// stat.execute("SET UNDO_LOG 0"); // stat.execute("SET UNDO_LOG 0");
...@@ -101,8 +100,18 @@ public class LobStorage { ...@@ -101,8 +100,18 @@ public class LobStorage {
public void removeAllForTable(int tableId) { public void removeAllForTable(int tableId) {
if (SysProperties.LOB_IN_DATABASE) { if (SysProperties.LOB_IN_DATABASE) {
init(); init();
int todo; try {
PreparedStatement prep = prepare("SELECT ID FROM " + LOBS + " WHERE TABLE=?");
prep.setInt(1, tableId);
ResultSet rs = prep.executeQuery();
while (rs.next()) {
deleteLob(rs.getLong(1));
}
} catch (SQLException e) {
throw DbException.convert(e);
}
// remove both lobs in the database as well as in the file system // remove both lobs in the database as well as in the file system
// (compatibility)
} }
ValueLob.removeAllForTable(handler, tableId); ValueLob.removeAllForTable(handler, tableId);
} }
...@@ -455,4 +464,18 @@ public class LobStorage { ...@@ -455,4 +464,18 @@ public class LobStorage {
return ValueLob.createClob(reader, maxLength, handler); return ValueLob.createClob(reader, maxLength, handler);
} }
public void setTable(long lobId, int table) {
try {
PreparedStatement prep = prepare("UPDATE " + LOBS + " SET TABLE = ? WHERE ID = ?");
prep.setInt(1, table);
prep.setLong(2, lobId);
int updateCount = prep.executeUpdate();
if (updateCount != 1) {
throw DbException.throwInternalError("count: " + updateCount);
}
} catch (SQLException e) {
throw DbException.convert(e);
}
}
} }
...@@ -972,12 +972,6 @@ public abstract class Table extends SchemaObjectBase { ...@@ -972,12 +972,6 @@ public abstract class Table extends SchemaObjectBase {
return column.convert(v); return column.convert(v);
} }
/**
* Check whether this is a hidden table that doesn't appear in the meta
* data and in the script.
*
* @return true if it is hidden
*/
public boolean isHidden() { public boolean isHidden() {
return isHidden; return isHidden;
} }
......
...@@ -137,15 +137,23 @@ public class ValueLob2 extends Value { ...@@ -137,15 +137,23 @@ public class ValueLob2 extends Value {
} }
public void unlink() { public void unlink() {
if (small == null && tableId != LobStorage.TABLE_ID_SESSION_VARIABLE) {
lobStorage.setTable(lobId, LobStorage.TABLE_ID_SESSION_VARIABLE);
tableId = LobStorage.TABLE_ID_SESSION_VARIABLE;
}
} }
public Value link(DataHandler h, int tabId) { public Value link(DataHandler h, int tabId) {
int todo; if (small == null) {
return this; if (tabId != tableId) {
if (tableId != LobStorage.TABLE_ID_SESSION_VARIABLE) {
throw DbException.throwInternalError();
} }
lobStorage.setTable(lobId, tabId);
private int getNewObjectId(DataHandler h) { this.tableId = tabId;
return 0; }
}
return this;
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论