提交 22010076 authored 作者: Thomas Mueller's avatar Thomas Mueller

With query literals disabled, auto-analyze of a table with CLOB or BLOB did not work.

上级 65532d86
......@@ -18,6 +18,7 @@ import org.h2.table.Table;
import org.h2.util.StatementBuilder;
import org.h2.value.Value;
import org.h2.value.ValueInt;
import org.h2.value.ValueNull;
/**
* This class represents the statement
......@@ -91,7 +92,7 @@ public class Analyze extends DefineCommand {
if (type == Value.BLOB || type == Value.CLOB) {
// can not index LOB columns, so calculating
// the selectivity is not required
buff.append("MAX(100)");
buff.append("MAX(NULL)");
} else {
buff.append("SELECTIVITY(").append(col.getSQL()).append(')');
}
......@@ -110,8 +111,11 @@ public class Analyze extends DefineCommand {
ResultInterface result = command.query(0);
result.next();
for (int j = 0; j < columns.length; j++) {
int selectivity = result.currentRow()[j].getInt();
columns[j].setSelectivity(selectivity);
Value v = result.currentRow()[j];
if (v != ValueNull.INSTANCE) {
int selectivity = v.getInt();
columns[j].setSelectivity(selectivity);
}
}
if (manual) {
db.updateMeta(session, table);
......
......@@ -167,10 +167,10 @@ public class TestOptimizations extends TestBase {
assertEquals(1, rs.getInt(2));
rs.next();
assertEquals("CL", rs.getString(1));
assertEquals(100, rs.getInt(2));
assertEquals(50, rs.getInt(2));
rs.next();
assertEquals("BL", rs.getString(1));
assertEquals(100, rs.getInt(2));
assertEquals(50, rs.getInt(2));
stat.execute("drop table test");
conn.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论