提交 cb4c607a authored 作者: christian.peter.io's avatar christian.peter.io

Drop table did not delete lob files in old file store (not PAGE_STORE).

上级 26ff584f
......@@ -53,6 +53,7 @@ Change Log
</li><li>The database is now closed after an out of memory exception, because
the database could get corrupt otherwise.
</li><li>Better error message if both AUTO_SERVER and SERIALIZED parameters are set to TRUE.
</li><li>Drop table did not delete lob files in old file store (not PAGE_STORE).
</li></ul>
<h2>Version 1.2.124 (2009-11-20)</h2>
......
......@@ -15,6 +15,7 @@ import org.h2.engine.Session;
import org.h2.message.Message;
import org.h2.schema.Schema;
import org.h2.table.Table;
import org.h2.value.ValueLob;
/**
* This class represents the statement
......@@ -26,6 +27,7 @@ public class DropTable extends SchemaCommand {
private String tableName;
private Table table;
private DropTable next;
private int dropTableId;
public DropTable(Session session, Schema schema) {
super(session, schema);
......@@ -62,6 +64,7 @@ public class DropTable extends SchemaCommand {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName);
}
} else {
dropTableId = table.getId();
session.getUser().checkRight(table, Right.ALL);
if (!table.canDrop()) {
throw Message.getSQLException(ErrorCode.CANNOT_DROP_TABLE_1, tableName);
......@@ -77,10 +80,12 @@ public class DropTable extends SchemaCommand {
// need to get the table again, because it may be dropped already
// meanwhile (dependent object, or same object)
table = getSchema().findTableOrView(session, tableName);
if (table != null) {
table.setModified();
Database db = session.getDatabase();
db.removeSchemaObject(session, table);
ValueLob.removeAllForTable(db, dropTableId);
}
if (next != null) {
next.executeDrop();
......@@ -94,4 +99,4 @@ public class DropTable extends SchemaCommand {
return 0;
}
}
}
\ No newline at end of file
......@@ -49,6 +49,8 @@ public class TestCases extends TestBase {
if (config.memory || config.logMode == 0) {
return;
}
testDeleteAndDropTableWithLobs(true);
testDeleteAndDropTableWithLobs(false);
testEmptyBtreeIndex();
testReservedKeywordReconnect();
testSpecialSQL();
......@@ -907,4 +909,31 @@ public class TestCases extends TestBase {
conn.close();
}
}
private void testDeleteAndDropTableWithLobs(boolean useDrop) throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(id int, content BLOB)");
stat.execute("set MAX_LENGTH_INPLACE_LOB 1");
PreparedStatement prepared = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?)");
byte[] blobContent = "BLOB_CONTENT".getBytes();
prepared.setInt(1, 1);
prepared.setBytes(2, blobContent);
prepared.execute();
if (useDrop) {
stat.execute("DROP TABLE TEST");
} else {
stat.execute("DELETE FROM TEST");
}
conn.close();
File[] files = new File(baseDir + "/cases.lobs.db").listFiles();
if (files != null && files.length > 0) {
fail("Lob file was not deleted");
}
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论