提交 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 { ...@@ -51,6 +51,9 @@ public class PageBtreeIndex extends PageIndex {
store.addIndex(this); store.addIndex(this);
if (create) { if (create) {
// new index // new index
if (!database.isStarting()) {
checkIndexColumnTypes(columns);
}
rootPageId = store.allocatePage(); rootPageId = store.allocatePage();
needRebuild = true; needRebuild = true;
// TODO currently the head position is stored in the log // TODO currently the head position is stored in the log
...@@ -74,6 +77,15 @@ public class PageBtreeIndex extends PageIndex { ...@@ -74,6 +77,15 @@ public class PageBtreeIndex extends PageIndex {
memoryPerPage = (Constants.MEMORY_PAGE_BTREE + store.getPageSize()) >> 2; 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) { public void add(Session session, Row row) {
if (trace.isDebugEnabled()) { if (trace.isDebugEnabled()) {
trace.debug("{0} add {1}", getName(), row); trace.debug("{0} add {1}", getName(), row);
......
...@@ -53,6 +53,7 @@ public class TestLob extends TestBase { ...@@ -53,6 +53,7 @@ public class TestLob extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testCreateIndexOnLob();
testBlobInputStreamSeek(true); testBlobInputStreamSeek(true);
testBlobInputStreamSeek(false); testBlobInputStreamSeek(false);
testDeadlock(); testDeadlock();
...@@ -97,6 +98,22 @@ public class TestLob extends TestBase { ...@@ -97,6 +98,22 @@ public class TestLob extends TestBase {
IOUtils.deleteRecursive(TEMP_DIR, true); 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 { private void testBlobInputStreamSeek(boolean upgraded) throws Exception {
deleteDb("lob"); deleteDb("lob");
Connection conn; Connection conn;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论