提交 48f2bac3 authored 作者: Noel Grandin's avatar Noel Grandin

support custom datatypes in PageStore engin

上级 61d61b28
...@@ -18,7 +18,6 @@ import java.sql.ResultSetMetaData; ...@@ -18,7 +18,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Arrays; import java.util.Arrays;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
...@@ -26,6 +25,7 @@ import org.h2.message.DbException; ...@@ -26,6 +25,7 @@ import org.h2.message.DbException;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.Bits; import org.h2.util.Bits;
import org.h2.util.DateTimeUtils; import org.h2.util.DateTimeUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.DataType; import org.h2.value.DataType;
...@@ -90,6 +90,7 @@ public class Data { ...@@ -90,6 +90,7 @@ public class Data {
private static final int LOCAL_TIME = 132; private static final int LOCAL_TIME = 132;
private static final int LOCAL_DATE = 133; private static final int LOCAL_DATE = 133;
private static final int LOCAL_TIMESTAMP = 134; private static final int LOCAL_TIMESTAMP = 134;
private static final byte CUSTOM_DATA_TYPE = (byte)135;
private static final long MILLIS_PER_MINUTE = 1000 * 60; private static final long MILLIS_PER_MINUTE = 1000 * 60;
...@@ -694,6 +695,14 @@ public class Data { ...@@ -694,6 +695,14 @@ public class Data {
break; break;
} }
default: default:
if (JdbcUtils.customDataTypesHandler != null) {
byte[] b = v.getBytesNoCopy();
writeByte(CUSTOM_DATA_TYPE);
writeVarInt(type);
writeVarInt(b.length);
write(b, 0, b.length);
break;
}
DbException.throwInternalError("type=" + v.getType()); DbException.throwInternalError("type=" + v.getType());
} }
if (SysProperties.CHECK2) { if (SysProperties.CHECK2) {
...@@ -878,6 +887,18 @@ public class Data { ...@@ -878,6 +887,18 @@ public class Data {
} }
return ValueResultSet.get(rs); return ValueResultSet.get(rs);
} }
case CUSTOM_DATA_TYPE: {
if (JdbcUtils.customDataTypesHandler != null) {
int customType = readVarInt();
int len = readVarInt();
byte[] b = Utils.newBytes(len);
read(b, 0, len);
return JdbcUtils.customDataTypesHandler.convert(
ValueBytes.getNoCopy(b), customType);
}
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1,
"No CustomDataTypesHandler has been set up");
}
default: default:
if (type >= INT_0_15 && type < INT_0_15 + 16) { if (type >= INT_0_15 && type < INT_0_15 + 16) {
return ValueInt.get(type - INT_0_15); return ValueInt.get(type - INT_0_15);
...@@ -1126,6 +1147,11 @@ public class Data { ...@@ -1126,6 +1147,11 @@ public class Data {
return len; return len;
} }
default: default:
if (JdbcUtils.customDataTypesHandler != null) {
byte[] b = v.getBytesNoCopy();
return 1 + getVarIntLen(v.getType())
+ getVarIntLen(b.length) + b.length;
}
throw DbException.throwInternalError("type=" + v.getType()); throw DbException.throwInternalError("type=" + v.getType());
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论