Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
42a81202
Unverified
提交
42a81202
authored
6 年前
作者:
Evgenij Ryazanov
提交者:
GitHub
6 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1349 from katzyn/value
Changes is conversion and comparison methods of Value
上级
feb11859
60063f8a
隐藏空白字符变更
内嵌
并排
正在显示
36 个修改的文件
包含
66 行增加
和
93 行删除
+66
-93
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+1
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+2
-2
ConditionInConstantSet.java
h2/src/main/org/h2/expression/ConditionInConstantSet.java
+2
-2
ConditionInSelect.java
h2/src/main/org/h2/expression/ConditionInSelect.java
+1
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-2
Operation.java
h2/src/main/org/h2/expression/Operation.java
+2
-2
HashIndex.java
h2/src/main/org/h2/index/HashIndex.java
+1
-1
NonUniqueHashIndex.java
h2/src/main/org/h2/index/NonUniqueHashIndex.java
+1
-1
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+1
-1
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+1
-1
Value.java
h2/src/main/org/h2/value/Value.java
+9
-24
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+1
-2
ValueBoolean.java
h2/src/main/org/h2/value/ValueBoolean.java
+2
-3
ValueByte.java
h2/src/main/org/h2/value/ValueByte.java
+2
-3
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+1
-1
ValueDate.java
h2/src/main/org/h2/value/ValueDate.java
+1
-1
ValueDecimal.java
h2/src/main/org/h2/value/ValueDecimal.java
+2
-3
ValueDouble.java
h2/src/main/org/h2/value/ValueDouble.java
+3
-4
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+1
-1
ValueFloat.java
h2/src/main/org/h2/value/ValueFloat.java
+3
-4
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+2
-3
ValueInt.java
h2/src/main/org/h2/value/ValueInt.java
+2
-3
ValueJavaObject.java
h2/src/main/org/h2/value/ValueJavaObject.java
+1
-1
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+2
-2
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-2
ValueLong.java
h2/src/main/org/h2/value/ValueLong.java
+2
-3
ValueNull.java
h2/src/main/org/h2/value/ValueNull.java
+1
-1
ValueResultSet.java
h2/src/main/org/h2/value/ValueResultSet.java
+1
-1
ValueShort.java
h2/src/main/org/h2/value/ValueShort.java
+2
-3
ValueString.java
h2/src/main/org/h2/value/ValueString.java
+2
-4
ValueStringIgnoreCase.java
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
+2
-3
ValueTime.java
h2/src/main/org/h2/value/ValueTime.java
+1
-1
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+1
-1
ValueTimestampTimeZone.java
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
+1
-1
ValueUuid.java
h2/src/main/org/h2/value/ValueUuid.java
+2
-2
TestCustomDataTypesHandler.java
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
+3
-2
没有找到文件。
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
42a81202
...
@@ -143,7 +143,7 @@ public class SelectUnion extends Query {
...
@@ -143,7 +143,7 @@ public class SelectUnion extends Query {
Mode
mode
=
session
.
getDatabase
().
getMode
();
Mode
mode
=
session
.
getDatabase
().
getMode
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
Expression
e
=
expressions
.
get
(
i
);
newValues
[
i
]
=
values
[
i
].
convertTo
(
e
.
getType
(),
-
1
,
mode
);
newValues
[
i
]
=
values
[
i
].
convertTo
(
e
.
getType
(),
mode
);
}
}
return
newValues
;
return
newValues
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
42a81202
...
@@ -412,11 +412,11 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -412,11 +412,11 @@ public class FunctionAlias extends SchemaObjectBase {
paramClass
.
getComponentType
());
paramClass
.
getComponentType
());
Mode
mode
=
session
.
getDatabase
().
getMode
();
Mode
mode
=
session
.
getDatabase
().
getMode
();
for
(
int
i
=
0
;
i
<
objArray
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
objArray
.
length
;
i
++)
{
objArray
[
i
]
=
array
[
i
].
convertTo
(
componentType
,
-
1
,
mode
).
getObject
();
objArray
[
i
]
=
array
[
i
].
convertTo
(
componentType
,
mode
).
getObject
();
}
}
o
=
objArray
;
o
=
objArray
;
}
else
{
}
else
{
v
=
v
.
convertTo
(
type
,
-
1
,
session
.
getDatabase
().
getMode
());
v
=
v
.
convertTo
(
type
,
session
.
getDatabase
().
getMode
());
o
=
v
.
getObject
();
o
=
v
.
getObject
();
}
}
if
(
o
==
null
)
{
if
(
o
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ConditionInConstantSet.java
浏览文件 @
42a81202
...
@@ -60,7 +60,7 @@ public class ConditionInConstantSet extends Condition {
...
@@ -60,7 +60,7 @@ public class ConditionInConstantSet extends Condition {
}
}
}
else
{
}
else
{
for
(
Expression
expression
:
valueList
)
{
for
(
Expression
expression
:
valueList
)
{
valueSet
.
add
(
expression
.
getValue
(
session
).
convertTo
(
type
,
-
1
,
mode
));
valueSet
.
add
(
expression
.
getValue
(
session
).
convertTo
(
type
,
mode
));
}
}
}
}
}
}
...
@@ -172,7 +172,7 @@ public class ConditionInConstantSet extends Condition {
...
@@ -172,7 +172,7 @@ public class ConditionInConstantSet extends Condition {
if
(
type
==
Value
.
ENUM
)
{
if
(
type
==
Value
.
ENUM
)
{
valueSet
.
add
(
add
.
getValue
(
session
).
convertToEnum
(
enumerators
));
valueSet
.
add
(
add
.
getValue
(
session
).
convertToEnum
(
enumerators
));
}
else
{
}
else
{
valueSet
.
add
(
add
.
getValue
(
session
).
convertTo
(
type
,
-
1
,
session
.
getDatabase
().
getMode
()));
valueSet
.
add
(
add
.
getValue
(
session
).
convertTo
(
type
,
session
.
getDatabase
().
getMode
()));
}
}
return
this
;
return
this
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ConditionInSelect.java
浏览文件 @
42a81202
...
@@ -62,7 +62,7 @@ public class ConditionInSelect extends Condition {
...
@@ -62,7 +62,7 @@ public class ConditionInSelect extends Condition {
if
(
dataType
==
Value
.
NULL
)
{
if
(
dataType
==
Value
.
NULL
)
{
return
ValueBoolean
.
FALSE
;
return
ValueBoolean
.
FALSE
;
}
}
l
=
l
.
convertTo
(
dataType
,
-
1
,
database
.
getMode
());
l
=
l
.
convertTo
(
dataType
,
database
.
getMode
());
if
(
rows
.
containsDistinct
(
new
Value
[]
{
l
}))
{
if
(
rows
.
containsDistinct
(
new
Value
[]
{
l
}))
{
return
ValueBoolean
.
TRUE
;
return
ValueBoolean
.
TRUE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
42a81202
...
@@ -873,7 +873,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -873,7 +873,7 @@ public class Function extends Expression implements FunctionCall {
case
CAST:
case
CAST:
case
CONVERT:
{
case
CONVERT:
{
Mode
mode
=
database
.
getMode
();
Mode
mode
=
database
.
getMode
();
v0
=
v0
.
convertTo
(
dataType
,
-
1
,
mode
);
v0
=
v0
.
convertTo
(
dataType
,
mode
);
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
scale
);
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
scale
);
v0
=
v0
.
convertPrecision
(
getPrecision
(),
false
);
v0
=
v0
.
convertPrecision
(
getPrecision
(),
false
);
result
=
v0
;
result
=
v0
;
...
@@ -902,7 +902,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -902,7 +902,7 @@ public class Function extends Expression implements FunctionCall {
if
(
v0
==
ValueNull
.
INSTANCE
)
{
if
(
v0
==
ValueNull
.
INSTANCE
)
{
result
=
getNullOrValue
(
session
,
args
,
values
,
1
);
result
=
getNullOrValue
(
session
,
args
,
values
,
1
);
}
}
result
=
result
.
convertTo
(
dataType
,
-
1
,
database
.
getMode
());
result
=
result
.
convertTo
(
dataType
,
database
.
getMode
());
break
;
break
;
}
}
case
CASEWHEN:
{
case
CASEWHEN:
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Operation.java
浏览文件 @
42a81202
...
@@ -110,14 +110,14 @@ public class Operation extends Expression {
...
@@ -110,14 +110,14 @@ public class Operation extends Expression {
@Override
@Override
public
Value
getValue
(
Session
session
)
{
public
Value
getValue
(
Session
session
)
{
Mode
mode
=
session
.
getDatabase
().
getMode
();
Mode
mode
=
session
.
getDatabase
().
getMode
();
Value
l
=
left
.
getValue
(
session
).
convertTo
(
dataType
,
-
1
,
mode
);
Value
l
=
left
.
getValue
(
session
).
convertTo
(
dataType
,
mode
);
Value
r
;
Value
r
;
if
(
right
==
null
)
{
if
(
right
==
null
)
{
r
=
null
;
r
=
null
;
}
else
{
}
else
{
r
=
right
.
getValue
(
session
);
r
=
right
.
getValue
(
session
);
if
(
convertRight
)
{
if
(
convertRight
)
{
r
=
r
.
convertTo
(
dataType
,
-
1
,
mode
);
r
=
r
.
convertTo
(
dataType
,
mode
);
}
}
}
}
switch
(
opType
)
{
switch
(
opType
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/HashIndex.java
浏览文件 @
42a81202
...
@@ -77,7 +77,7 @@ public class HashIndex extends BaseIndex {
...
@@ -77,7 +77,7 @@ public class HashIndex extends BaseIndex {
* case we need to convert, otherwise the ValueHashMap will not find the
* case we need to convert, otherwise the ValueHashMap will not find the
* result.
* result.
*/
*/
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
(),
-
1
,
database
.
getMode
());
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
(),
database
.
getMode
());
Row
result
;
Row
result
;
Long
pos
=
rows
.
get
(
v
);
Long
pos
=
rows
.
get
(
v
);
if
(
pos
==
null
)
{
if
(
pos
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/NonUniqueHashIndex.java
浏览文件 @
42a81202
...
@@ -101,7 +101,7 @@ public class NonUniqueHashIndex extends BaseIndex {
...
@@ -101,7 +101,7 @@ public class NonUniqueHashIndex extends BaseIndex {
* case we need to convert, otherwise the ValueHashMap will not find the
* case we need to convert, otherwise the ValueHashMap will not find the
* result.
* result.
*/
*/
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
(),
-
1
,
database
.
getMode
());
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
(),
database
.
getMode
());
ArrayList
<
Long
>
positions
=
rows
.
get
(
v
);
ArrayList
<
Long
>
positions
=
rows
.
get
(
v
);
return
new
NonUniqueHashCursor
(
session
,
tableData
,
positions
);
return
new
NonUniqueHashCursor
(
session
,
tableData
,
positions
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
42a81202
...
@@ -562,7 +562,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements
...
@@ -562,7 +562,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements
setParameter
(
parameterIndex
,
ValueNull
.
INSTANCE
);
setParameter
(
parameterIndex
,
ValueNull
.
INSTANCE
);
}
else
{
}
else
{
Value
v
=
DataType
.
convertToValue
(
conn
.
getSession
(),
x
,
type
);
Value
v
=
DataType
.
convertToValue
(
conn
.
getSession
(),
x
,
type
);
setParameter
(
parameterIndex
,
v
.
convertTo
(
type
,
-
1
,
conn
.
getMode
()));
setParameter
(
parameterIndex
,
v
.
convertTo
(
type
,
conn
.
getMode
()));
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
42a81202
...
@@ -1066,7 +1066,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
...
@@ -1066,7 +1066,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
public
byte
[]
getBytes
(
int
columnIndex
)
throws
SQLException
{
public
byte
[]
getBytes
(
int
columnIndex
)
throws
SQLException
{
try
{
try
{
debugCodeCall
(
"getBytes"
,
columnIndex
);
debugCodeCall
(
"getBytes"
,
columnIndex
);
return
get
(
columnIndex
).
convertTo
(
Value
.
BYTES
,
-
1
,
conn
.
getMode
()).
getBytes
();
return
get
(
columnIndex
).
convertTo
(
Value
.
BYTES
,
conn
.
getMode
()).
getBytes
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Value.java
浏览文件 @
42a81202
...
@@ -265,16 +265,6 @@ public abstract class Value {
...
@@ -265,16 +265,6 @@ public abstract class Value {
public
abstract
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
public
abstract
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
;
throws
SQLException
;
/**
* Compare the value with another value of the same type.
*
* @param v the other value
* @param mode the compare mode
* @return 0 if both values are equal, -1 if the other value is smaller, and
* 1 otherwise
*/
protected
abstract
int
compareSecure
(
Value
v
,
CompareMode
mode
);
@Override
@Override
public
abstract
int
hashCode
();
public
abstract
int
hashCode
();
...
@@ -586,10 +576,10 @@ public abstract class Value {
...
@@ -586,10 +576,10 @@ public abstract class Value {
* @param targetType the type of the returned value
* @param targetType the type of the returned value
* @return the converted value
* @return the converted value
*/
*/
public
Value
convertTo
(
int
targetType
)
{
public
final
Value
convertTo
(
int
targetType
)
{
// Use -1 to indicate "default behaviour" where value conversion should not
// Use -1 to indicate "default behaviour" where value conversion should not
// depend on any datatype precision.
// depend on any datatype precision.
return
convertTo
(
targetType
,
-
1
,
null
);
return
convertTo
(
targetType
,
null
);
}
}
/**
/**
...
@@ -597,7 +587,7 @@ public abstract class Value {
...
@@ -597,7 +587,7 @@ public abstract class Value {
* @param enumerators allowed values for the ENUM to which the value is converted
* @param enumerators allowed values for the ENUM to which the value is converted
* @return value represented as ENUM
* @return value represented as ENUM
*/
*/
public
Value
convertToEnum
(
String
[]
enumerators
)
{
public
final
Value
convertToEnum
(
String
[]
enumerators
)
{
// Use -1 to indicate "default behaviour" where value conversion should not
// Use -1 to indicate "default behaviour" where value conversion should not
// depend on any datatype precision.
// depend on any datatype precision.
return
convertTo
(
ENUM
,
-
1
,
null
,
null
,
enumerators
);
return
convertTo
(
ENUM
,
-
1
,
null
,
null
,
enumerators
);
...
@@ -607,14 +597,11 @@ public abstract class Value {
...
@@ -607,14 +597,11 @@ public abstract class Value {
* Compare a value to the specified type.
* Compare a value to the specified type.
*
*
* @param targetType the type of the returned value
* @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 mode
* @param mode the mode
* @return the converted value
* @return the converted value
*/
*/
public
final
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
)
{
public
final
Value
convertTo
(
int
targetType
,
Mode
mode
)
{
return
convertTo
(
targetType
,
precision
,
mode
,
null
,
null
);
return
convertTo
(
targetType
,
-
1
,
mode
,
null
,
null
);
}
}
/**
/**
...
@@ -1160,9 +1147,7 @@ public abstract class Value {
...
@@ -1160,9 +1147,7 @@ public abstract class Value {
* @return 0 if both values are equal, -1 if the other value is smaller, and
* @return 0 if both values are equal, -1 if the other value is smaller, and
* 1 otherwise
* 1 otherwise
*/
*/
public
final
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
)
{
public
abstract
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
);
return
compareSecure
(
v
,
mode
);
}
/**
/**
* Compare this value against another value using the specified compare
* Compare this value against another value using the specified compare
...
@@ -1193,11 +1178,11 @@ public abstract class Value {
...
@@ -1193,11 +1178,11 @@ public abstract class Value {
l
=
l
.
convertToEnum
(
enumerators
);
l
=
l
.
convertToEnum
(
enumerators
);
v
=
v
.
convertToEnum
(
enumerators
);
v
=
v
.
convertToEnum
(
enumerators
);
}
else
{
}
else
{
l
=
l
.
convertTo
(
dataType
,
-
1
,
databaseMode
);
l
=
l
.
convertTo
(
dataType
,
databaseMode
);
v
=
v
.
convertTo
(
dataType
,
-
1
,
databaseMode
);
v
=
v
.
convertTo
(
dataType
,
databaseMode
);
}
}
}
}
return
l
.
compare
Secur
e
(
v
,
compareMode
);
return
l
.
compare
TypeSaf
e
(
v
,
compareMode
);
}
}
public
int
getScale
()
{
public
int
getScale
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
42a81202
...
@@ -11,7 +11,6 @@ import java.sql.SQLException;
...
@@ -11,7 +11,6 @@ import java.sql.SQLException;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Mode
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StatementBuilder
;
...
@@ -99,7 +98,7 @@ public class ValueArray extends Value {
...
@@ -99,7 +98,7 @@ public class ValueArray extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
ValueArray
v
=
(
ValueArray
)
o
;
ValueArray
v
=
(
ValueArray
)
o
;
if
(
values
==
v
.
values
)
{
if
(
values
==
v
.
values
)
{
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueBoolean.java
浏览文件 @
42a81202
...
@@ -66,9 +66,8 @@ public class ValueBoolean extends Value {
...
@@ -66,9 +66,8 @@ public class ValueBoolean extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueBoolean
v
=
(
ValueBoolean
)
o
;
return
Boolean
.
compare
(
value
,
((
ValueBoolean
)
o
).
value
);
return
Boolean
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueByte.java
浏览文件 @
42a81202
...
@@ -108,9 +108,8 @@ public class ValueByte extends Value {
...
@@ -108,9 +108,8 @@ public class ValueByte extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueByte
v
=
(
ValueByte
)
o
;
return
Integer
.
compare
(
value
,
((
ValueByte
)
o
).
value
);
return
Integer
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
42a81202
...
@@ -94,7 +94,7 @@ public class ValueBytes extends Value {
...
@@ -94,7 +94,7 @@ public class ValueBytes extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
byte
[]
v2
=
((
ValueBytes
)
v
).
value
;
byte
[]
v2
=
((
ValueBytes
)
v
).
value
;
if
(
mode
.
isBinaryUnsigned
())
{
if
(
mode
.
isBinaryUnsigned
())
{
return
Bits
.
compareNotNullUnsigned
(
value
,
v2
);
return
Bits
.
compareNotNullUnsigned
(
value
,
v2
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDate.java
浏览文件 @
42a81202
...
@@ -113,7 +113,7 @@ public class ValueDate extends Value {
...
@@ -113,7 +113,7 @@ public class ValueDate extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
return
Long
.
compare
(
dateValue
,
((
ValueDate
)
o
).
dateValue
);
return
Long
.
compare
(
dateValue
,
((
ValueDate
)
o
).
dateValue
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDecimal.java
浏览文件 @
42a81202
...
@@ -127,9 +127,8 @@ public class ValueDecimal extends Value {
...
@@ -127,9 +127,8 @@ public class ValueDecimal extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueDecimal
v
=
(
ValueDecimal
)
o
;
return
value
.
compareTo
(((
ValueDecimal
)
o
).
value
);
return
value
.
compareTo
(
v
.
value
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDouble.java
浏览文件 @
42a81202
...
@@ -101,9 +101,8 @@ public class ValueDouble extends Value {
...
@@ -101,9 +101,8 @@ public class ValueDouble extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueDouble
v
=
(
ValueDouble
)
o
;
return
Double
.
compare
(
value
,
((
ValueDouble
)
o
).
value
);
return
Double
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
@@ -180,7 +179,7 @@ public class ValueDouble extends Value {
...
@@ -180,7 +179,7 @@ public class ValueDouble extends Value {
if
(!(
other
instanceof
ValueDouble
))
{
if
(!(
other
instanceof
ValueDouble
))
{
return
false
;
return
false
;
}
}
return
compare
Secur
e
((
ValueDouble
)
other
,
null
)
==
0
;
return
compare
TypeSaf
e
((
ValueDouble
)
other
,
null
)
==
0
;
}
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
42a81202
...
@@ -33,7 +33,7 @@ public class ValueEnumBase extends Value {
...
@@ -33,7 +33,7 @@ public class ValueEnumBase extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecure
(
final
Value
v
,
final
CompareMode
mode
)
{
p
ublic
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
)
{
return
Integer
.
compare
(
getInt
(),
v
.
getInt
());
return
Integer
.
compare
(
getInt
(),
v
.
getInt
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueFloat.java
浏览文件 @
42a81202
...
@@ -102,9 +102,8 @@ public class ValueFloat extends Value {
...
@@ -102,9 +102,8 @@ public class ValueFloat extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueFloat
v
=
(
ValueFloat
)
o
;
return
Float
.
compare
(
value
,
((
ValueFloat
)
o
).
value
);
return
Float
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
@@ -180,7 +179,7 @@ public class ValueFloat extends Value {
...
@@ -180,7 +179,7 @@ public class ValueFloat extends Value {
if
(!(
other
instanceof
ValueFloat
))
{
if
(!(
other
instanceof
ValueFloat
))
{
return
false
;
return
false
;
}
}
return
compare
Secur
e
((
ValueFloat
)
other
,
null
)
==
0
;
return
compare
TypeSaf
e
((
ValueFloat
)
other
,
null
)
==
0
;
}
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
42a81202
...
@@ -243,9 +243,8 @@ public class ValueGeometry extends Value {
...
@@ -243,9 +243,8 @@ public class ValueGeometry extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
)
{
Geometry
g
=
((
ValueGeometry
)
v
).
getGeometryNoCopy
();
return
getGeometryNoCopy
().
compareTo
(((
ValueGeometry
)
v
).
getGeometryNoCopy
());
return
getGeometryNoCopy
().
compareTo
(
g
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueInt.java
浏览文件 @
42a81202
...
@@ -141,9 +141,8 @@ public class ValueInt extends Value {
...
@@ -141,9 +141,8 @@ public class ValueInt extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueInt
v
=
(
ValueInt
)
o
;
return
Integer
.
compare
(
value
,
((
ValueInt
)
o
).
value
);
return
Integer
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueJavaObject.java
浏览文件 @
42a81202
...
@@ -102,7 +102,7 @@ public class ValueJavaObject extends ValueBytes {
...
@@ -102,7 +102,7 @@ public class ValueJavaObject extends ValueBytes {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
Object
o1
=
getObject
();
Object
o1
=
getObject
();
Object
o2
=
v
.
getObject
();
Object
o2
=
v
.
getObject
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
42a81202
...
@@ -515,7 +515,7 @@ public class ValueLob extends Value {
...
@@ -515,7 +515,7 @@ public class ValueLob extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
return
compare
(
this
,
v
);
return
compare
(
this
,
v
);
}
}
...
@@ -613,7 +613,7 @@ public class ValueLob extends Value {
...
@@ -613,7 +613,7 @@ public class ValueLob extends Value {
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(
other
instanceof
ValueLob
)
{
if
(
other
instanceof
ValueLob
)
{
ValueLob
o
=
(
ValueLob
)
other
;
ValueLob
o
=
(
ValueLob
)
other
;
return
valueType
==
o
.
valueType
&&
compare
Secur
e
(
o
,
null
)
==
0
;
return
valueType
==
o
.
valueType
&&
compare
TypeSaf
e
(
o
,
null
)
==
0
;
}
}
return
false
;
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
42a81202
...
@@ -375,7 +375,7 @@ public class ValueLobDb extends Value {
...
@@ -375,7 +375,7 @@ public class ValueLobDb extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
if
(
v
instanceof
ValueLobDb
)
{
if
(
v
instanceof
ValueLobDb
)
{
ValueLobDb
v2
=
(
ValueLobDb
)
v
;
ValueLobDb
v2
=
(
ValueLobDb
)
v
;
if
(
v
==
this
)
{
if
(
v
==
this
)
{
...
@@ -511,7 +511,7 @@ public class ValueLobDb extends Value {
...
@@ -511,7 +511,7 @@ public class ValueLobDb extends Value {
ValueLobDb
otherLob
=
(
ValueLobDb
)
other
;
ValueLobDb
otherLob
=
(
ValueLobDb
)
other
;
if
(
hashCode
()
!=
otherLob
.
hashCode
())
if
(
hashCode
()
!=
otherLob
.
hashCode
())
return
false
;
return
false
;
return
compare
Secur
e
((
Value
)
other
,
null
)
==
0
;
return
compare
TypeSaf
e
((
Value
)
other
,
null
)
==
0
;
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLong.java
浏览文件 @
42a81202
...
@@ -161,9 +161,8 @@ public class ValueLong extends Value {
...
@@ -161,9 +161,8 @@ public class ValueLong extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueLong
v
=
(
ValueLong
)
o
;
return
Long
.
compare
(
value
,
((
ValueLong
)
o
).
value
);
return
Long
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueNull.java
浏览文件 @
42a81202
...
@@ -139,7 +139,7 @@ public class ValueNull extends Value {
...
@@ -139,7 +139,7 @@ public class ValueNull extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
throw
DbException
.
throwInternalError
(
"compare null"
);
throw
DbException
.
throwInternalError
(
"compare null"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueResultSet.java
浏览文件 @
42a81202
...
@@ -116,7 +116,7 @@ public class ValueResultSet extends Value {
...
@@ -116,7 +116,7 @@ public class ValueResultSet extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
return
this
==
v
?
0
:
super
.
toString
().
compareTo
(
v
.
toString
());
return
this
==
v
?
0
:
super
.
toString
().
compareTo
(
v
.
toString
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueShort.java
浏览文件 @
42a81202
...
@@ -108,9 +108,8 @@ public class ValueShort extends Value {
...
@@ -108,9 +108,8 @@ public class ValueShort extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueShort
v
=
(
ValueShort
)
o
;
return
Integer
.
compare
(
value
,
((
ValueShort
)
o
).
value
);
return
Integer
.
compare
(
value
,
v
.
value
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueString.java
浏览文件 @
42a81202
...
@@ -45,10 +45,8 @@ public class ValueString extends Value {
...
@@ -45,10 +45,8 @@ public class ValueString extends Value {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
// compatibility: the other object could be another type
return
mode
.
compareString
(
value
,
((
ValueString
)
o
).
value
,
false
);
ValueString
v
=
(
ValueString
)
o
;
return
mode
.
compareString
(
value
,
v
.
value
,
false
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
浏览文件 @
42a81202
...
@@ -27,9 +27,8 @@ public class ValueStringIgnoreCase extends ValueString {
...
@@ -27,9 +27,8 @@ public class ValueStringIgnoreCase extends ValueString {
}
}
@Override
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
ValueStringIgnoreCase
v
=
(
ValueStringIgnoreCase
)
o
;
return
mode
.
compareString
(
value
,
((
ValueStringIgnoreCase
)
o
).
value
,
true
);
return
mode
.
compareString
(
value
,
v
.
value
,
true
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
42a81202
...
@@ -181,7 +181,7 @@ public class ValueTime extends Value {
...
@@ -181,7 +181,7 @@ public class ValueTime extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
return
Long
.
compare
(
nanos
,
((
ValueTime
)
o
).
nanos
);
return
Long
.
compare
(
nanos
,
((
ValueTime
)
o
).
nanos
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
42a81202
...
@@ -235,7 +235,7 @@ public class ValueTimestamp extends Value {
...
@@ -235,7 +235,7 @@ public class ValueTimestamp extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
ValueTimestamp
t
=
(
ValueTimestamp
)
o
;
ValueTimestamp
t
=
(
ValueTimestamp
)
o
;
int
c
=
Long
.
compare
(
dateValue
,
t
.
dateValue
);
int
c
=
Long
.
compare
(
dateValue
,
t
.
dateValue
);
if
(
c
!=
0
)
{
if
(
c
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
浏览文件 @
42a81202
...
@@ -224,7 +224,7 @@ public class ValueTimestampTimeZone extends Value {
...
@@ -224,7 +224,7 @@ public class ValueTimestampTimeZone extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
ValueTimestampTimeZone
t
=
(
ValueTimestampTimeZone
)
o
;
ValueTimestampTimeZone
t
=
(
ValueTimestampTimeZone
)
o
;
// Maximum time zone offset is +/-18 hours so difference in days between local
// Maximum time zone offset is +/-18 hours so difference in days between local
// and UTC cannot be more than one day
// and UTC cannot be more than one day
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
42a81202
...
@@ -163,7 +163,7 @@ public class ValueUuid extends Value {
...
@@ -163,7 +163,7 @@ public class ValueUuid extends Value {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
if
(
o
==
this
)
{
if
(
o
==
this
)
{
return
0
;
return
0
;
}
}
...
@@ -176,7 +176,7 @@ public class ValueUuid extends Value {
...
@@ -176,7 +176,7 @@ public class ValueUuid extends Value {
@Override
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueUuid
&&
compare
Secur
e
((
Value
)
other
,
null
)
==
0
;
return
other
instanceof
ValueUuid
&&
compare
TypeSaf
e
((
Value
)
other
,
null
)
==
0
;
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
42a81202
...
@@ -16,6 +16,7 @@ import java.text.DecimalFormat;
...
@@ -16,6 +16,7 @@ import java.text.DecimalFormat;
import
java.util.Locale
;
import
java.util.Locale
;
import
org.h2.api.CustomDataTypesHandler
;
import
org.h2.api.CustomDataTypesHandler
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Mode
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.DataHandler
;
import
org.h2.store.DataHandler
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
...
@@ -371,7 +372,7 @@ public class TestCustomDataTypesHandler extends TestDb {
...
@@ -371,7 +372,7 @@ public class TestCustomDataTypesHandler extends TestDb {
}
}
@Override
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
return
val
.
compare
((
ComplexNumber
)
v
.
getObject
());
return
val
.
compare
((
ComplexNumber
)
v
.
getObject
());
}
}
...
@@ -393,7 +394,7 @@ public class TestCustomDataTypesHandler extends TestDb {
...
@@ -393,7 +394,7 @@ public class TestCustomDataTypesHandler extends TestDb {
}
}
@Override
@Override
public
Value
convertTo
(
int
targetType
)
{
public
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
,
Object
column
,
String
[]
enumerators
)
{
if
(
getType
()
==
targetType
)
{
if
(
getType
()
==
targetType
)
{
return
this
;
return
this
;
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论