提交 495e6613 authored 作者: Thomas Mueller's avatar Thomas Mueller

It is now longer allowed to create an index on a CLOB or BLOB column.

上级 ff83c364
......@@ -51,6 +51,9 @@ public class PageBtreeIndex extends PageIndex {
store.addIndex(this);
if (create) {
// new index
if (!database.isStarting()) {
checkIndexColumnTypes(columns);
}
rootPageId = store.allocatePage();
needRebuild = true;
// TODO currently the head position is stored in the log
......@@ -74,6 +77,15 @@ public class PageBtreeIndex extends PageIndex {
memoryPerPage = (Constants.MEMORY_PAGE_BTREE + store.getPageSize()) >> 2;
}
private void checkIndexColumnTypes(IndexColumn[] columns) {
for (IndexColumn c : columns) {
int type = c.column.getType();
if (type == Value.CLOB || type == Value.BLOB) {
throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, "Index on BLOB or CLOB column: " + c.column.getCreateSQL());
}
}
}
public void add(Session session, Row row) {
if (trace.isDebugEnabled()) {
trace.debug("{0} add {1}", getName(), row);
......
......@@ -53,6 +53,7 @@ public class TestLob extends TestBase {
}
public void test() throws Exception {
testCreateIndexOnLob();
testBlobInputStreamSeek(true);
testBlobInputStreamSeek(false);
testDeadlock();
......@@ -97,6 +98,22 @@ public class TestLob extends TestBase {
IOUtils.deleteRecursive(TEMP_DIR, true);
}
private void testCreateIndexOnLob() throws Exception {
deleteDb("lob");
Connection conn;
conn = getConnection("lob");
Statement stat = conn.createStatement();
stat.execute("create table test(id int, name clob)");
try {
stat.execute("create index idx_n on test(name)");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.FEATURE_NOT_SUPPORTED_1, e.getErrorCode());
}
stat.execute("drop table test");
conn.close();
}
private void testBlobInputStreamSeek(boolean upgraded) throws Exception {
deleteDb("lob");
Connection conn;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论