Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
edaa8645
提交
edaa8645
authored
1月 21, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove precision parameter of Value.convertTo()
上级
a9030639
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
19 行增加
和
28 行删除
+19
-28
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+2
-3
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
-1
Column.java
h2/src/main/org/h2/table/Column.java
+1
-2
Value.java
h2/src/main/org/h2/value/Value.java
+4
-7
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+2
-2
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+2
-2
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+2
-5
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-3
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
浏览文件 @
edaa8645
...
...
@@ -21,7 +21,6 @@ import org.h2.message.DbException;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.util.MathUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueGeometry
;
...
...
@@ -234,8 +233,8 @@ public class Comparison extends Condition {
if
(
constType
!=
resType
)
{
Column
column
=
((
ExpressionColumn
)
left
).
getColumn
();
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
,
MathUtils
.
convertLongToInt
(
left
.
getType
().
getPrecision
()
),
session
.
getDatabase
().
getMode
(),
column
,
column
.
getType
().
getExtTypeInfo
()));
session
.
getDatabase
().
getMode
(
),
column
,
column
.
getType
().
getExtTypeInfo
()));
}
}
else
if
(
right
instanceof
Parameter
)
{
((
Parameter
)
right
).
setColumn
(
...
...
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
edaa8645
...
...
@@ -902,7 +902,7 @@ public class Function extends Expression implements FunctionCall {
case
CONVERT:
{
Mode
mode
=
database
.
getMode
();
TypeInfo
type
=
this
.
type
;
v0
=
v0
.
convertTo
(
dataType
,
MathUtils
.
convertLongToInt
(
type
.
getPrecision
()),
mode
,
null
,
extTypeInfo
);
v0
=
v0
.
convertTo
(
dataType
,
mode
,
null
,
extTypeInfo
);
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
type
.
getScale
());
v0
=
v0
.
convertPrecision
(
type
.
getPrecision
(),
false
);
result
=
v0
;
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
edaa8645
...
...
@@ -290,7 +290,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
Value
v
=
r
.
getValue
(
idx
);
if
(
v
!=
null
)
{
TypeInfo
type
=
c
.
getType
();
array
[
i
]
=
v
.
convertTo
(
type
.
getValueType
(),
-
1
,
database
.
getMode
(),
null
,
type
.
getExtTypeInfo
());
array
[
i
]
=
v
.
convertTo
(
type
.
getValueType
(),
database
.
getMode
(),
null
,
type
.
getExtTypeInfo
());
}
}
array
[
keyColumns
-
1
]
=
key
!=
null
?
key
:
ValueLong
.
get
(
r
.
getKey
());
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
edaa8645
...
...
@@ -164,8 +164,7 @@ public class Column {
*/
public
Value
convert
(
Value
v
,
Mode
mode
)
{
try
{
return
v
.
convertTo
(
type
.
getValueType
(),
MathUtils
.
convertLongToInt
(
type
.
getPrecision
()),
mode
,
this
,
type
.
getExtTypeInfo
());
return
v
.
convertTo
(
type
.
getValueType
(),
mode
,
this
,
type
.
getExtTypeInfo
());
}
catch
(
DbException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DATA_CONVERSION_ERROR_1
)
{
String
target
=
(
table
==
null
?
""
:
table
.
getName
()
+
": "
)
+
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
edaa8645
...
...
@@ -709,7 +709,7 @@ public abstract class Value extends VersionedValue {
public
final
Value
convertToEnum
(
ExtTypeInfo
enumerators
)
{
// Use -1 to indicate "default behaviour" where value conversion should not
// depend on any datatype precision.
return
convertTo
(
ENUM
,
-
1
,
null
,
null
,
enumerators
);
return
convertTo
(
ENUM
,
null
,
null
,
enumerators
);
}
/**
...
...
@@ -720,7 +720,7 @@ public abstract class Value extends VersionedValue {
* @return the converted value
*/
public
final
Value
convertTo
(
int
targetType
,
Mode
mode
)
{
return
convertTo
(
targetType
,
-
1
,
mode
,
null
,
null
);
return
convertTo
(
targetType
,
mode
,
null
,
null
);
}
/**
...
...
@@ -732,22 +732,19 @@ public abstract class Value extends VersionedValue {
* @return the converted value
*/
public
Value
convertTo
(
TypeInfo
targetType
,
Mode
mode
,
Object
column
)
{
return
convertTo
(
targetType
.
getValueType
(),
-
1
,
mode
,
column
,
targetType
.
getExtTypeInfo
());
return
convertTo
(
targetType
.
getValueType
(),
mode
,
column
,
targetType
.
getExtTypeInfo
());
}
/**
* Convert a value to the specified type.
*
* @param targetType the type of the returned value
* @param precision the precision of the column to convert this value to.
* The special constant <code>-1</code> is used to indicate that
* the precision plays no role when converting the value
* @param mode the conversion mode
* @param column the column (if any), used for to improve the error message if conversion fails
* @param extTypeInfo the extended data type information, or null
* @return the converted value
*/
public
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
// converting NULL is done in ValueNull
// converting BLOB to CLOB and vice versa is done in ValueLob
if
(
getValueType
()
==
targetType
)
{
...
...
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
edaa8645
...
...
@@ -137,11 +137,11 @@ public class ValueEnumBase extends Value {
}
@Override
public
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
targetType
==
Value
.
ENUM
)
{
return
extTypeInfo
.
cast
(
this
);
}
return
super
.
convertTo
(
targetType
,
precision
,
mode
,
column
,
extTypeInfo
);
return
super
.
convertTo
(
targetType
,
mode
,
column
,
extTypeInfo
);
}
}
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
edaa8645
...
...
@@ -346,13 +346,13 @@ public class ValueGeometry extends Value {
}
@Override
public
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
targetType
==
Value
.
GEOMETRY
)
{
return
extTypeInfo
!=
null
?
extTypeInfo
.
cast
(
this
)
:
this
;
}
else
if
(
targetType
==
Value
.
JAVA_OBJECT
)
{
return
this
;
}
return
super
.
convertTo
(
targetType
,
precision
,
mode
,
column
,
null
);
return
super
.
convertTo
(
targetType
,
mode
,
column
,
null
);
}
}
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
edaa8645
...
...
@@ -367,16 +367,13 @@ public class ValueLob extends Value {
* except when converting to BLOB or CLOB.
*
* @param t the new type
* @param precision the precision of the column to convert this value to.
* The special constant <code>-1</code> is used to indicate that
* the precision plays no role when converting the value
* @param mode the database mode
* @param column the column (if any), used for to improve the error message if conversion fails
* @param extTypeInfo the extended data type information, or null
* @return the converted value
*/
@Override
public
Value
convertTo
(
int
t
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
t
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
t
==
valueType
)
{
return
this
;
}
else
if
(
t
==
Value
.
CLOB
)
{
...
...
@@ -384,7 +381,7 @@ public class ValueLob extends Value {
}
else
if
(
t
==
Value
.
BLOB
)
{
return
ValueLobDb
.
createTempBlob
(
getInputStream
(),
-
1
,
handler
);
}
return
super
.
convertTo
(
t
,
precision
,
mode
,
column
,
null
);
return
super
.
convertTo
(
t
,
mode
,
column
,
null
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
edaa8645
...
...
@@ -205,14 +205,13 @@ public class ValueLobDb extends Value {
* except when converting to BLOB or CLOB.
*
* @param t the new type
* @param precision the precision
* @param mode the mode
* @param column the column (if any), used for to improve the error message if conversion fails
* @param extTypeInfo the extended data type information, or null
* @return the converted value
*/
@Override
public
Value
convertTo
(
int
t
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
t
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
t
==
valueType
)
{
return
this
;
}
else
if
(
t
==
Value
.
CLOB
)
{
...
...
@@ -230,7 +229,7 @@ public class ValueLobDb extends Value {
return
ValueLobDb
.
createSmallLob
(
t
,
small
);
}
}
return
super
.
convertTo
(
t
,
precision
,
mode
,
column
,
null
);
return
super
.
convertTo
(
t
,
mode
,
column
,
null
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueNull.java
浏览文件 @
edaa8645
...
...
@@ -139,7 +139,7 @@ public class ValueNull extends Value {
}
@Override
public
Value
convertTo
(
int
type
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
type
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
return
this
;
}
...
...
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
edaa8645
...
...
@@ -391,7 +391,7 @@ public class TestCustomDataTypesHandler extends TestDb {
}
@Override
public
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
public
Value
convertTo
(
int
targetType
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
getValueType
()
==
targetType
)
{
return
this
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论