提交 18882d36 authored 作者: Thomas Mueller's avatar Thomas Mueller

LOB files were not deleted when running DROP ALL OBJECTS.

上级 7249a6bb
...@@ -30,7 +30,6 @@ public class DropTable extends SchemaCommand { ...@@ -30,7 +30,6 @@ public class DropTable extends SchemaCommand {
private String tableName; private String tableName;
private Table table; private Table table;
private DropTable next; private DropTable next;
private int dropTableId;
private int dropAction = SysProperties.DROP_RESTRICT ? ConstraintReferential.RESTRICT : ConstraintReferential.CASCADE; private int dropAction = SysProperties.DROP_RESTRICT ? ConstraintReferential.RESTRICT : ConstraintReferential.CASCADE;
public DropTable(Session session, Schema schema) { public DropTable(Session session, Schema schema) {
...@@ -68,7 +67,6 @@ public class DropTable extends SchemaCommand { ...@@ -68,7 +67,6 @@ public class DropTable extends SchemaCommand {
throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName); throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName);
} }
} else { } else {
dropTableId = table.getId();
session.getUser().checkRight(table, Right.ALL); session.getUser().checkRight(table, Right.ALL);
if (!table.canDrop()) { if (!table.canDrop()) {
throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName); throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName);
...@@ -100,7 +98,6 @@ public class DropTable extends SchemaCommand { ...@@ -100,7 +98,6 @@ public class DropTable extends SchemaCommand {
table.setModified(); table.setModified();
Database db = session.getDatabase(); Database db = session.getDatabase();
db.removeSchemaObject(session, table); db.removeSchemaObject(session, table);
db.getLobStorage().removeAllForTable(dropTableId);
} }
if (next != null) { if (next != null) {
next.executeDrop(); next.executeDrop();
......
...@@ -81,7 +81,6 @@ public class RegularTable extends TableBase { ...@@ -81,7 +81,6 @@ public class RegularTable extends TableBase {
for (Column col : getColumns()) { for (Column col : getColumns()) {
if (DataType.isLargeObject(col.getType())) { if (DataType.isLargeObject(col.getType())) {
containsLargeObject = true; containsLargeObject = true;
memoryPerRow = Row.MEMORY_CALCULATE;
} }
} }
traceLock = database.getTrace(Trace.LOCK); traceLock = database.getTrace(Trace.LOCK);
...@@ -646,6 +645,9 @@ public class RegularTable extends TableBase { ...@@ -646,6 +645,9 @@ public class RegularTable extends TableBase {
} }
scanIndex.remove(session); scanIndex.remove(session);
database.removeMeta(session, getId()); database.removeMeta(session, getId());
if (containsLargeObject) {
database.getLobStorage().removeAllForTable(getId());
}
scanIndex = null; scanIndex = null;
lockExclusive = null; lockExclusive = null;
lockShared = null; lockShared = null;
......
...@@ -49,6 +49,7 @@ public class TestLob extends TestBase { ...@@ -49,6 +49,7 @@ public class TestLob extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testDropAllObjects();
testDelete(); testDelete();
testTempFilesDeleted(); testTempFilesDeleted();
testAddLobRestart(); testAddLobRestart();
...@@ -82,6 +83,37 @@ public class TestLob extends TestBase { ...@@ -82,6 +83,37 @@ public class TestLob extends TestBase {
FileSystem.getInstance(TEMP_DIR).deleteRecursive(TEMP_DIR, true); FileSystem.getInstance(TEMP_DIR).deleteRecursive(TEMP_DIR, true);
} }
private void testDropAllObjects() throws Exception {
if (SysProperties.LOB_IN_DATABASE || config.memory) {
return;
}
deleteDb("lob");
Connection conn;
Statement stat;
conn = getConnection("lob");
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name clob)");
stat.execute("insert into test values(1, space(10000))");
assertEquals(1, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
stat.execute("drop table test");
assertEquals(0, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
stat.execute("create table test(id int primary key, name clob)");
stat.execute("insert into test values(1, space(10000))");
assertEquals(1, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
stat.execute("drop all objects");
assertEquals(0, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
stat.execute("create table test(id int primary key, name clob)");
stat.execute("insert into test values(1, space(10000))");
assertEquals(1, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
stat.execute("truncate table test");
assertEquals(0, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
conn.close();
}
private void testDelete() throws Exception { private void testDelete() throws Exception {
if (!SysProperties.LOB_IN_DATABASE || config.memory) { if (!SysProperties.LOB_IN_DATABASE || config.memory) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论