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