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

New experimental LOB storage.

上级 1df42bbd
......@@ -62,7 +62,7 @@ public class DropDatabase extends DefineCommand {
}
}
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);
}
}
......@@ -75,6 +75,9 @@ public class DropDatabase extends DefineCommand {
list.addAll(db.getAllSchemaObjects(DbObject.TRIGGER));
list.addAll(db.getAllSchemaObjects(DbObject.CONSTANT));
for (SchemaObject obj : list) {
if (obj.isHidden()) {
continue;
}
db.removeSchemaObject(session, obj);
}
for (User user : db.getAllUsers()) {
......
......@@ -174,4 +174,8 @@ public abstract class Constraint extends SchemaObjectBase implements Comparable<
return thisType - otherType;
}
public boolean isHidden() {
return table.isHidden();
}
}
......@@ -2034,7 +2034,8 @@ public class Database implements DataHandler {
public Table getFirstUserTable() {
for (Table table : getAllTablesAndViews(false)) {
if (table.getCreateSQL() != null) {
if (SysProperties.LOB_IN_DATABASE && table.getSchema() == infoSchema) {
if (table.isHidden()) {
// LOB tables
continue;
}
return table;
......
......@@ -371,4 +371,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
throw DbException.getUnsupportedException(toString());
}
public boolean isHidden() {
return table.isHidden();
}
}
......@@ -320,4 +320,8 @@ public class MultiVersionIndex implements Index {
return base.getRow(session, key);
}
public boolean isHidden() {
return base.isHidden();
}
}
......@@ -19,4 +19,13 @@ public interface SchemaObject extends DbObject {
* @return the schema
*/
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
return schema.getSQL() + "." + super.getSQL();
}
public boolean isHidden() {
return false;
}
}
......@@ -69,7 +69,6 @@ public class LobStorage {
if (conn == null) {
return;
}
int todoDatabaseGetFirstUserTable;
try {
Statement stat = conn.createStatement();
// stat.execute("SET UNDO_LOG 0");
......@@ -101,8 +100,18 @@ public class LobStorage {
public void removeAllForTable(int tableId) {
if (SysProperties.LOB_IN_DATABASE) {
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
// (compatibility)
}
ValueLob.removeAllForTable(handler, tableId);
}
......@@ -455,4 +464,18 @@ public class LobStorage {
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 {
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() {
return isHidden;
}
......
......@@ -137,17 +137,25 @@ public class ValueLob2 extends Value {
}
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) {
int todo;
if (small == null) {
if (tabId != tableId) {
if (tableId != LobStorage.TABLE_ID_SESSION_VARIABLE) {
throw DbException.throwInternalError();
}
lobStorage.setTable(lobId, tabId);
this.tableId = tabId;
}
}
return this;
}
private int getNewObjectId(DataHandler h) {
return 0;
}
/**
* Get the current table id of this lob.
*
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论