提交 31b0c80e authored 作者: Thomas Mueller's avatar Thomas Mueller

When the system property h2.lobInDatabase is set, CREATE TABLE ... AS SELECT…

When the system property h2.lobInDatabase is set, CREATE TABLE ... AS SELECT with a LOB column did not always work.
上级 204d6a62
......@@ -72,7 +72,7 @@ public class LobStorage {
/**
* Initialize the lob storage.
*/
private void init() {
public void init() {
if (init) {
return;
}
......
......@@ -19,6 +19,7 @@ import org.h2.constant.SysProperties;
import org.h2.constraint.Constraint;
import org.h2.constraint.ConstraintReferential;
import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.DbObject;
import org.h2.engine.Session;
import org.h2.index.Cursor;
......@@ -72,6 +73,19 @@ public class RegularTable extends TableBase {
super(data);
nextAnalyze = database.getSettings().analyzeAuto;
this.isHidden = data.isHidden;
for (Column col : getColumns()) {
if (DataType.isLargeObject(col.getType())) {
containsLargeObject = true;
}
}
if (containsLargeObject) {
Database db = data.session.getDatabase();
if (!db.isStarting()) {
// the lob tables are already created
// if the database is starting
db.getLobStorage().init();
}
}
if (data.persistData && database.isPersistent()) {
mainIndex = new PageDataIndex(this, data.id, IndexColumn.wrap(getColumns()), IndexType.createScan(data.persistData), data.create, data.session);
scanIndex = mainIndex;
......@@ -79,11 +93,6 @@ public class RegularTable extends TableBase {
scanIndex = new ScanIndex(this, data.id, IndexColumn.wrap(getColumns()), IndexType.createScan(data.persistData));
}
indexes.add(scanIndex);
for (Column col : getColumns()) {
if (DataType.isLargeObject(col.getType())) {
containsLargeObject = true;
}
}
traceLock = database.getTrace(Trace.LOCK);
}
......
......@@ -49,6 +49,7 @@ public class TestLob extends TestBase {
}
public void test() throws Exception {
testCreateAsSelect();
testDropAllObjects();
testDelete();
testTempFilesDeleted();
......@@ -83,6 +84,16 @@ public class TestLob extends TestBase {
FileSystem.getInstance(TEMP_DIR).deleteRecursive(TEMP_DIR, true);
}
private void testCreateAsSelect() throws Exception {
deleteDb("lob");
Connection conn;
Statement stat;
conn = getConnection("lob");
stat = conn.createStatement();
stat.execute("create table test(id int, data clob) as select 1, space(10000)");
conn.close();
}
private void testDropAllObjects() throws Exception {
if (SysProperties.LOB_IN_DATABASE || config.memory) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论