Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a03cc5e6
提交
a03cc5e6
authored
1月 21, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Value.convertTo() with TypeInfo in more places
上级
edaa8645
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
25 行增加
和
30 行删除
+25
-30
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+12
-11
Function.java
h2/src/main/org/h2/expression/function/Function.java
+1
-1
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+1
-3
Column.java
h2/src/main/org/h2/table/Column.java
+1
-1
Value.java
h2/src/main/org/h2/value/Value.java
+4
-8
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+1
-1
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+1
-1
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+1
-1
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+1
-1
ValueNull.java
h2/src/main/org/h2/value/ValueNull.java
+1
-1
TestCustomDataTypesHandler.java
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
+1
-1
没有找到文件。
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
a03cc5e6
...
@@ -21,6 +21,7 @@ import org.h2.message.DbException;
...
@@ -21,6 +21,7 @@ import org.h2.message.DbException;
import
org.h2.table.Column
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueGeometry
;
import
org.h2.value.ValueGeometry
;
...
@@ -224,17 +225,17 @@ public class Comparison extends Condition {
...
@@ -224,17 +225,17 @@ public class Comparison extends Condition {
return
ValueExpression
.
getNull
();
return
ValueExpression
.
getNull
();
}
}
}
}
int
colType
=
left
.
getType
().
getValueType
();
TypeInfo
colType
=
left
.
getType
(),
constType
=
r
.
getType
();
int
constType
=
r
.
getValueType
();
int
constValueType
=
constType
.
getValueType
();
int
resType
=
Value
.
getHigherOrder
(
colType
,
constType
);
if
(
constValueType
!=
colType
.
getValueType
())
{
TypeInfo
resType
=
Value
.
getHigherType
(
colType
,
constType
);
// If not, the column values will need to be promoted
// If not, the column values will need to be promoted
// to constant type, but vise versa, then let's do this here
// to constant type, but vise versa, then let's do this here
// once.
// once.
if
(
constType
!=
resType
)
{
if
(
constValueType
!=
resType
.
getValueType
()
)
{
Column
column
=
((
ExpressionColumn
)
left
).
getColumn
();
Column
column
=
((
ExpressionColumn
)
left
).
getColumn
();
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
,
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
,
session
.
getDatabase
().
getMode
(),
column
));
session
.
getDatabase
().
getMode
(),
}
column
,
column
.
getType
().
getExtTypeInfo
()));
}
}
}
else
if
(
right
instanceof
Parameter
)
{
}
else
if
(
right
instanceof
Parameter
)
{
((
Parameter
)
right
).
setColumn
(
((
Parameter
)
right
).
setColumn
(
...
...
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
a03cc5e6
...
@@ -902,7 +902,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -902,7 +902,7 @@ public class Function extends Expression implements FunctionCall {
case
CONVERT:
{
case
CONVERT:
{
Mode
mode
=
database
.
getMode
();
Mode
mode
=
database
.
getMode
();
TypeInfo
type
=
this
.
type
;
TypeInfo
type
=
this
.
type
;
v0
=
v0
.
convertTo
(
dataType
,
mode
,
null
,
extTypeInfo
);
v0
=
v0
.
convertTo
(
type
,
mode
,
null
);
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
type
.
getScale
());
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
type
.
getScale
());
v0
=
v0
.
convertPrecision
(
type
.
getPrecision
(),
false
);
v0
=
v0
.
convertPrecision
(
type
.
getPrecision
(),
false
);
result
=
v0
;
result
=
v0
;
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
a03cc5e6
...
@@ -30,7 +30,6 @@ import org.h2.table.Column;
...
@@ -30,7 +30,6 @@ import org.h2.table.Column;
import
org.h2.table.IndexColumn
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.value.CompareMode
;
import
org.h2.value.CompareMode
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueLong
;
...
@@ -289,8 +288,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -289,8 +288,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
int
idx
=
c
.
getColumnId
();
int
idx
=
c
.
getColumnId
();
Value
v
=
r
.
getValue
(
idx
);
Value
v
=
r
.
getValue
(
idx
);
if
(
v
!=
null
)
{
if
(
v
!=
null
)
{
TypeInfo
type
=
c
.
getType
();
array
[
i
]
=
v
.
convertTo
(
c
.
getType
(),
database
.
getMode
(),
null
);
array
[
i
]
=
v
.
convertTo
(
type
.
getValueType
(),
database
.
getMode
(),
null
,
type
.
getExtTypeInfo
());
}
}
}
}
array
[
keyColumns
-
1
]
=
key
!=
null
?
key
:
ValueLong
.
get
(
r
.
getKey
());
array
[
keyColumns
-
1
]
=
key
!=
null
?
key
:
ValueLong
.
get
(
r
.
getKey
());
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
a03cc5e6
...
@@ -164,7 +164,7 @@ public class Column {
...
@@ -164,7 +164,7 @@ public class Column {
*/
*/
public
Value
convert
(
Value
v
,
Mode
mode
)
{
public
Value
convert
(
Value
v
,
Mode
mode
)
{
try
{
try
{
return
v
.
convertTo
(
type
.
getValueType
(),
mode
,
this
,
type
.
getExtTypeInfo
()
);
return
v
.
convertTo
(
type
,
mode
,
this
);
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DATA_CONVERSION_ERROR_1
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DATA_CONVERSION_ERROR_1
)
{
String
target
=
(
table
==
null
?
""
:
table
.
getName
()
+
": "
)
+
String
target
=
(
table
==
null
?
""
:
table
.
getName
()
+
": "
)
+
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
a03cc5e6
...
@@ -696,9 +696,7 @@ public abstract class Value extends VersionedValue {
...
@@ -696,9 +696,7 @@ public abstract class Value extends VersionedValue {
* @return the converted value
* @return the converted value
*/
*/
public
final
Value
convertTo
(
int
targetType
)
{
public
final
Value
convertTo
(
int
targetType
)
{
// Use -1 to indicate "default behaviour" where value conversion should not
return
convertTo
(
targetType
,
null
,
null
,
null
);
// depend on any datatype precision.
return
convertTo
(
targetType
,
null
);
}
}
/**
/**
...
@@ -706,9 +704,7 @@ public abstract class Value extends VersionedValue {
...
@@ -706,9 +704,7 @@ public abstract class Value extends VersionedValue {
* @param enumerators the extended type information for the ENUM data type
* @param enumerators the extended type information for the ENUM data type
* @return value represented as ENUM
* @return value represented as ENUM
*/
*/
public
final
Value
convertToEnum
(
ExtTypeInfo
enumerators
)
{
private
Value
convertToEnum
(
ExtTypeInfo
enumerators
)
{
// Use -1 to indicate "default behaviour" where value conversion should not
// depend on any datatype precision.
return
convertTo
(
ENUM
,
null
,
null
,
enumerators
);
return
convertTo
(
ENUM
,
null
,
null
,
enumerators
);
}
}
...
@@ -731,7 +727,7 @@ public abstract class Value extends VersionedValue {
...
@@ -731,7 +727,7 @@ public abstract class Value extends VersionedValue {
* @param column the column (if any), used for to improve the error message if conversion fails
* @param column the column (if any), used for to improve the error message if conversion fails
* @return the converted value
* @return the converted value
*/
*/
public
Value
convertTo
(
TypeInfo
targetType
,
Mode
mode
,
Object
column
)
{
public
final
Value
convertTo
(
TypeInfo
targetType
,
Mode
mode
,
Object
column
)
{
return
convertTo
(
targetType
.
getValueType
(),
mode
,
column
,
targetType
.
getExtTypeInfo
());
return
convertTo
(
targetType
.
getValueType
(),
mode
,
column
,
targetType
.
getExtTypeInfo
());
}
}
...
@@ -744,7 +740,7 @@ public abstract class Value extends VersionedValue {
...
@@ -744,7 +740,7 @@ public abstract class Value extends VersionedValue {
* @param extTypeInfo the extended data type information, or null
* @param extTypeInfo the extended data type information, or null
* @return the converted value
* @return the converted value
*/
*/
p
ublic
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
// converting NULL is done in ValueNull
// converting NULL is done in ValueNull
// converting BLOB to CLOB and vice versa is done in ValueLob
// converting BLOB to CLOB and vice versa is done in ValueLob
if
(
getValueType
()
==
targetType
)
{
if
(
getValueType
()
==
targetType
)
{
...
...
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
a03cc5e6
...
@@ -137,7 +137,7 @@ public class ValueEnumBase extends Value {
...
@@ -137,7 +137,7 @@ public class ValueEnumBase extends Value {
}
}
@Override
@Override
p
ublic
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
targetType
==
Value
.
ENUM
)
{
if
(
targetType
==
Value
.
ENUM
)
{
return
extTypeInfo
.
cast
(
this
);
return
extTypeInfo
.
cast
(
this
);
}
}
...
...
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
a03cc5e6
...
@@ -346,7 +346,7 @@ public class ValueGeometry extends Value {
...
@@ -346,7 +346,7 @@ public class ValueGeometry extends Value {
}
}
@Override
@Override
p
ublic
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
targetType
==
Value
.
GEOMETRY
)
{
if
(
targetType
==
Value
.
GEOMETRY
)
{
return
extTypeInfo
!=
null
?
extTypeInfo
.
cast
(
this
)
:
this
;
return
extTypeInfo
!=
null
?
extTypeInfo
.
cast
(
this
)
:
this
;
}
else
if
(
targetType
==
Value
.
JAVA_OBJECT
)
{
}
else
if
(
targetType
==
Value
.
JAVA_OBJECT
)
{
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
a03cc5e6
...
@@ -373,7 +373,7 @@ public class ValueLob extends Value {
...
@@ -373,7 +373,7 @@ public class ValueLob extends Value {
* @return the converted value
* @return the converted value
*/
*/
@Override
@Override
p
ublic
Value
convertTo
(
int
t
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
t
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
t
==
valueType
)
{
if
(
t
==
valueType
)
{
return
this
;
return
this
;
}
else
if
(
t
==
Value
.
CLOB
)
{
}
else
if
(
t
==
Value
.
CLOB
)
{
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
a03cc5e6
...
@@ -211,7 +211,7 @@ public class ValueLobDb extends Value {
...
@@ -211,7 +211,7 @@ public class ValueLobDb extends Value {
* @return the converted value
* @return the converted value
*/
*/
@Override
@Override
p
ublic
Value
convertTo
(
int
t
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
t
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
t
==
valueType
)
{
if
(
t
==
valueType
)
{
return
this
;
return
this
;
}
else
if
(
t
==
Value
.
CLOB
)
{
}
else
if
(
t
==
Value
.
CLOB
)
{
...
...
h2/src/main/org/h2/value/ValueNull.java
浏览文件 @
a03cc5e6
...
@@ -139,7 +139,7 @@ public class ValueNull extends Value {
...
@@ -139,7 +139,7 @@ public class ValueNull extends Value {
}
}
@Override
@Override
p
ublic
Value
convertTo
(
int
type
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
type
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
return
this
;
return
this
;
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
a03cc5e6
...
@@ -391,7 +391,7 @@ public class TestCustomDataTypesHandler extends TestDb {
...
@@ -391,7 +391,7 @@ public class TestCustomDataTypesHandler extends TestDb {
}
}
@Override
@Override
p
ublic
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
p
rotected
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
getValueType
()
==
targetType
)
{
if
(
getValueType
()
==
targetType
)
{
return
this
;
return
this
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论