Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c3f92764
提交
c3f92764
authored
8月 14, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add storage format for INTERVAL data type
上级
513b5621
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
107 行增加
和
0 行删除
+107
-0
ValueDataType.java
h2/src/main/org/h2/mvstore/db/ValueDataType.java
+33
-0
Data.java
h2/src/main/org/h2/store/Data.java
+52
-0
ValueInterval.java
h2/src/main/org/h2/value/ValueInterval.java
+20
-0
interval.sql
h2/src/test/org/h2/test/scripts/datatypes/interval.sql
+2
-0
没有找到文件。
h2/src/main/org/h2/mvstore/db/ValueDataType.java
浏览文件 @
c3f92764
...
@@ -13,6 +13,7 @@ import java.sql.ResultSetMetaData;
...
@@ -13,6 +13,7 @@ import java.sql.ResultSetMetaData;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.IntervalQualifier
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Mode
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -38,6 +39,7 @@ import org.h2.value.ValueDouble;
...
@@ -38,6 +39,7 @@ import org.h2.value.ValueDouble;
import
org.h2.value.ValueFloat
;
import
org.h2.value.ValueFloat
;
import
org.h2.value.ValueGeometry
;
import
org.h2.value.ValueGeometry
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInterval
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueLobDb
;
import
org.h2.value.ValueLobDb
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueLong
;
...
@@ -440,6 +442,32 @@ public class ValueDataType implements DataType {
...
@@ -440,6 +442,32 @@ public class ValueDataType implements DataType {
put
(
b
);
put
(
b
);
break
;
break
;
}
}
case
Value
.
INTERVAL_YEAR
:
case
Value
.
INTERVAL_MONTH
:
case
Value
.
INTERVAL_DAY
:
case
Value
.
INTERVAL_HOUR
:
case
Value
.
INTERVAL_MINUTE
:
{
ValueInterval
interval
=
(
ValueInterval
)
v
;
buff
.
put
((
byte
)
Value
.
INTERVAL_YEAR
).
put
((
byte
)
(
type
-
Value
.
INTERVAL_YEAR
)).
putVarLong
(
interval
.
getLeading
());
break
;
}
case
Value
.
INTERVAL_SECOND
:
case
Value
.
INTERVAL_YEAR_TO_MONTH
:
case
Value
.
INTERVAL_DAY_TO_HOUR
:
case
Value
.
INTERVAL_DAY_TO_MINUTE
:
case
Value
.
INTERVAL_DAY_TO_SECOND
:
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
{
ValueInterval
interval
=
(
ValueInterval
)
v
;
buff
.
put
((
byte
)
Value
.
INTERVAL_YEAR
).
put
((
byte
)
(
type
-
Value
.
INTERVAL_YEAR
)).
putVarLong
(
interval
.
getLeading
()).
putVarLong
(
interval
.
getRemaining
());
break
;
}
default
:
default
:
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
byte
[]
b
=
v
.
getBytesNoCopy
();
byte
[]
b
=
v
.
getBytesNoCopy
();
...
@@ -543,6 +571,11 @@ public class ValueDataType implements DataType {
...
@@ -543,6 +571,11 @@ public class ValueDataType implements DataType {
return
ValueStringIgnoreCase
.
get
(
readString
(
buff
));
return
ValueStringIgnoreCase
.
get
(
readString
(
buff
));
case
Value
.
STRING_FIXED
:
case
Value
.
STRING_FIXED
:
return
ValueStringFixed
.
get
(
readString
(
buff
));
return
ValueStringFixed
.
get
(
readString
(
buff
));
case
Value
.
INTERVAL_YEAR
:
{
int
ordinal
=
buff
.
get
()
&
0xff
;
return
ValueInterval
.
from
(
IntervalQualifier
.
valueOf
(
ordinal
),
readVarLong
(
buff
),
ordinal
<
5
?
0
:
readVarLong
(
buff
));
}
case
FLOAT_0_1:
case
FLOAT_0_1:
return
ValueFloat
.
get
(
0
);
return
ValueFloat
.
get
(
0
);
case
FLOAT_0_1
+
1
:
case
FLOAT_0_1
+
1
:
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
c3f92764
...
@@ -19,6 +19,7 @@ import java.sql.SQLException;
...
@@ -19,6 +19,7 @@ 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.api.IntervalQualifier
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.tools.SimpleResultSet
;
...
@@ -39,6 +40,7 @@ import org.h2.value.ValueDouble;
...
@@ -39,6 +40,7 @@ import org.h2.value.ValueDouble;
import
org.h2.value.ValueFloat
;
import
org.h2.value.ValueFloat
;
import
org.h2.value.ValueGeometry
;
import
org.h2.value.ValueGeometry
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInterval
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLobDb
;
import
org.h2.value.ValueLobDb
;
...
@@ -655,6 +657,32 @@ public class Data {
...
@@ -655,6 +657,32 @@ public class Data {
}
}
break
;
break
;
}
}
case
Value
.
INTERVAL_YEAR
:
case
Value
.
INTERVAL_MONTH
:
case
Value
.
INTERVAL_DAY
:
case
Value
.
INTERVAL_HOUR
:
case
Value
.
INTERVAL_MINUTE
:
{
ValueInterval
interval
=
(
ValueInterval
)
v
;
writeByte
((
byte
)
Value
.
INTERVAL_YEAR
);
writeByte
((
byte
)
(
type
-
Value
.
INTERVAL_YEAR
));
writeVarLong
(
interval
.
getLeading
());
break
;
}
case
Value
.
INTERVAL_SECOND
:
case
Value
.
INTERVAL_YEAR_TO_MONTH
:
case
Value
.
INTERVAL_DAY_TO_HOUR
:
case
Value
.
INTERVAL_DAY_TO_MINUTE
:
case
Value
.
INTERVAL_DAY_TO_SECOND
:
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
{
ValueInterval
interval
=
(
ValueInterval
)
v
;
writeByte
((
byte
)
Value
.
INTERVAL_YEAR
);
writeByte
((
byte
)
(
type
-
Value
.
INTERVAL_YEAR
));
writeVarLong
(
interval
.
getLeading
());
writeVarLong
(
interval
.
getRemaining
());
break
;
}
default
:
default
:
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
byte
[]
b
=
v
.
getBytesNoCopy
();
byte
[]
b
=
v
.
getBytesNoCopy
();
...
@@ -843,6 +871,11 @@ public class Data {
...
@@ -843,6 +871,11 @@ public class Data {
}
}
return
ValueResultSet
.
get
(
rs
);
return
ValueResultSet
.
get
(
rs
);
}
}
case
Value
.
INTERVAL_YEAR
:
{
int
ordinal
=
readByte
()
&
0xff
;
return
ValueInterval
.
from
(
IntervalQualifier
.
valueOf
(
ordinal
),
readVarLong
(),
ordinal
<
5
?
0
:
readVarLong
());
}
case
CUSTOM_DATA_TYPE:
{
case
CUSTOM_DATA_TYPE:
{
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
int
customType
=
readVarInt
();
int
customType
=
readVarInt
();
...
@@ -1082,6 +1115,25 @@ public class Data {
...
@@ -1082,6 +1115,25 @@ public class Data {
}
}
return
len
;
return
len
;
}
}
case
Value
.
INTERVAL_YEAR
:
case
Value
.
INTERVAL_MONTH
:
case
Value
.
INTERVAL_DAY
:
case
Value
.
INTERVAL_HOUR
:
case
Value
.
INTERVAL_MINUTE
:
{
ValueInterval
interval
=
(
ValueInterval
)
v
;
return
2
+
getVarLongLen
(
interval
.
getLeading
());
}
case
Value
.
INTERVAL_SECOND
:
case
Value
.
INTERVAL_YEAR_TO_MONTH
:
case
Value
.
INTERVAL_DAY_TO_HOUR
:
case
Value
.
INTERVAL_DAY_TO_MINUTE
:
case
Value
.
INTERVAL_DAY_TO_SECOND
:
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
{
ValueInterval
interval
=
(
ValueInterval
)
v
;
return
2
+
getVarLongLen
(
interval
.
getLeading
())
+
getVarLongLen
(
interval
.
getRemaining
());
}
default
:
default
:
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
byte
[]
b
=
v
.
getBytesNoCopy
();
byte
[]
b
=
v
.
getBytesNoCopy
();
...
...
h2/src/main/org/h2/value/ValueInterval.java
浏览文件 @
c3f92764
...
@@ -157,6 +157,26 @@ public class ValueInterval extends Value {
...
@@ -157,6 +157,26 @@ public class ValueInterval extends Value {
return
IntervalQualifier
.
valueOf
(
type
-
INTERVAL_YEAR
);
return
IntervalQualifier
.
valueOf
(
type
-
INTERVAL_YEAR
);
}
}
/**
* Returns value of leading field of this interval. For {@code SECOND}
* intervals returns integer part of seconds.
*
* @return value of leading field
*/
public
long
getLeading
()
{
return
leading
;
}
/**
* Returns combined value of remaining fields of this interval. For
* {@code SECOND} intervals returns nanoseconds.
*
* @return combined value of remaining fields
*/
public
long
getRemaining
()
{
return
remaining
;
}
@Override
@Override
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
{
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
{
prep
.
setString
(
parameterIndex
,
getString
());
prep
.
setString
(
parameterIndex
,
getString
());
...
...
h2/src/test/org/h2/test/scripts/datatypes/interval.sql
浏览文件 @
c3f92764
...
@@ -71,6 +71,8 @@ INSERT INTO TEST VALUES (
...
@@ -71,6 +71,8 @@ INSERT INTO TEST VALUES (
INTERVAL
-
'1:2:3.123456789'
HOUR
TO
SECOND
,
INTERVAL
-
'1:2.123456789'
MINUTE
TO
SECOND
);
INTERVAL
-
'1:2:3.123456789'
HOUR
TO
SECOND
,
INTERVAL
-
'1:2.123456789'
MINUTE
TO
SECOND
);
>
update
count
:
2
>
update
count
:
2
@
reconnect
SELECT
I01
,
I02
,
I03
,
I04
,
I05
,
I06
FROM
TEST
ORDER
BY
ID
;
SELECT
I01
,
I02
,
I03
,
I04
,
I05
,
I06
FROM
TEST
ORDER
BY
ID
;
>
I01
I02
I03
I04
I05
I06
>
I01
I02
I03
I04
I05
I06
>
------------------ ------------------- ----------------- ------------------ -------------------- --------------------------
>
------------------ ------------------- ----------------- ------------------ -------------------- --------------------------
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论