提交 162e190d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use DataType.isLargeObject() and isStringType() in more places

上级 4dac32b2
......@@ -17,6 +17,7 @@ import org.h2.table.Column;
import org.h2.table.Table;
import org.h2.table.TableType;
import org.h2.util.StatementBuilder;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueInt;
import org.h2.value.ValueNull;
......@@ -104,8 +105,7 @@ public class Analyze extends DefineCommand {
StatementBuilder buff = new StatementBuilder("SELECT ");
for (Column col : columns) {
buff.appendExceptFirst(", ");
int type = col.getType();
if (type == Value.BLOB || type == Value.CLOB) {
if (DataType.isLargeObject(col.getType())) {
// can not index LOB columns, so calculating
// the selectivity is not required
buff.append("MAX(NULL)");
......
......@@ -50,6 +50,7 @@ import org.h2.util.ColumnNamerConfiguration;
import org.h2.util.CurrentTimestamp;
import org.h2.util.SmallLRUCache;
import org.h2.util.Utils;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueArray;
import org.h2.value.ValueLong;
......@@ -1701,7 +1702,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
@Override
public void addTemporaryLob(Value v) {
if (v.getType() != Value.CLOB && v.getType() != Value.BLOB) {
if (!DataType.isLargeObject(v.getType())) {
return;
}
if (v.getTableId() == LobStorageFrontend.TABLE_RESULT
......
......@@ -15,6 +15,7 @@ import org.h2.message.DbException;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
import org.h2.value.CompareMode;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueBoolean;
import org.h2.value.ValueNull;
......@@ -198,9 +199,7 @@ public class CompareLike extends Condition {
// can't use an index
return;
}
int dataType = l.getColumn().getType();
if (dataType != Value.STRING && dataType != Value.STRING_IGNORECASE &&
dataType != Value.STRING_FIXED) {
if (!DataType.isStringType(l.getColumn().getType())) {
// column is not a varchar - can't use the index
return;
}
......
......@@ -23,6 +23,7 @@ import org.h2.table.Table;
import org.h2.table.TableFilter;
import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueNull;
......@@ -72,8 +73,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
*/
protected static void checkIndexColumnTypes(IndexColumn[] columns) {
for (IndexColumn c : columns) {
int type = c.column.getType();
if (type == Value.CLOB || type == Value.BLOB) {
if (DataType.isLargeObject(c.column.getType())) {
throw DbException.getUnsupportedException(
"Index on BLOB or CLOB column: " + c.column.getCreateSQL());
}
......
......@@ -23,6 +23,7 @@ import org.h2.table.Column;
import org.h2.table.IndexColumn;
import org.h2.table.Table;
import org.h2.util.TempFileDeleter;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueNull;
......@@ -118,7 +119,7 @@ public class ResultTempTable implements ResultExternal {
for (int i = 0; i < expressions.length; i++) {
int type = expressions[i].getType();
Column col = new Column(COLUMN_NAME + i, type);
if (type == Value.CLOB || type == Value.BLOB) {
if (DataType.isLargeObject(type)) {
containsLob = true;
}
data.columns.add(col);
......
......@@ -13,6 +13,7 @@ import org.h2.engine.Session;
import org.h2.store.Data;
import org.h2.store.FileStore;
import org.h2.util.Utils;
import org.h2.value.DataType;
import org.h2.value.Value;
/**
......@@ -63,7 +64,7 @@ public class RowList {
buff.writeByte((byte) 0);
} else {
buff.writeByte((byte) 1);
if (v.getType() == Value.CLOB || v.getType() == Value.BLOB) {
if (DataType.isLargeObject(v.getType())) {
// need to keep a reference to temporary lobs,
// otherwise the temp file is deleted
if (v.getSmall() == null && v.getTableId() == 0) {
......
......@@ -37,6 +37,7 @@ import org.h2.store.LobStorageInterface;
import org.h2.util.IOUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.SmallMap;
import org.h2.value.DataType;
import org.h2.value.Transfer;
import org.h2.value.Value;
import org.h2.value.ValueLobDb;
......@@ -572,7 +573,7 @@ public class TcpServerThread implements Runnable {
}
private void writeValue(Value v) throws IOException {
if (v.getType() == Value.CLOB || v.getType() == Value.BLOB) {
if (DataType.isLargeObject(v.getType())) {
if (v instanceof ValueLobDb) {
ValueLobDb lob = (ValueLobDb) v;
if (lob.isStored()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论