Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f4f75172
提交
f4f75172
authored
8月 02, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge compareTypeSafe() and compareSecure() methods of Value
上级
ad92b287
隐藏空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
43 行增加
和
68 行删除
+43
-68
Value.java
h2/src/main/org/h2/value/Value.java
+2
-14
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
+1
-1
没有找到文件。
h2/src/main/org/h2/value/Value.java
浏览文件 @
f4f75172
...
...
@@ -265,16 +265,6 @@ public abstract class Value {
public
abstract
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
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
public
abstract
int
hashCode
();
...
...
@@ -1157,9 +1147,7 @@ public abstract class Value {
* @return 0 if both values are equal, -1 if the other value is smaller, and
* 1 otherwise
*/
public
final
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
)
{
return
compareSecure
(
v
,
mode
);
}
public
abstract
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
);
/**
* Compare this value against another value using the specified compare
...
...
@@ -1194,7 +1182,7 @@ public abstract class Value {
v
=
v
.
convertTo
(
dataType
,
databaseMode
);
}
}
return
l
.
compare
Secur
e
(
v
,
compareMode
);
return
l
.
compare
TypeSaf
e
(
v
,
compareMode
);
}
public
int
getScale
()
{
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
f4f75172
...
...
@@ -11,7 +11,6 @@ import java.sql.SQLException;
import
java.util.Arrays
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Mode
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -99,7 +98,7 @@ public class ValueArray extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
ValueArray
v
=
(
ValueArray
)
o
;
if
(
values
==
v
.
values
)
{
return
0
;
...
...
h2/src/main/org/h2/value/ValueBoolean.java
浏览文件 @
f4f75172
...
...
@@ -66,9 +66,8 @@ public class ValueBoolean extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueBoolean
v
=
(
ValueBoolean
)
o
;
return
Boolean
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Boolean
.
compare
(
value
,
((
ValueBoolean
)
o
).
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueByte.java
浏览文件 @
f4f75172
...
...
@@ -108,9 +108,8 @@ public class ValueByte extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueByte
v
=
(
ValueByte
)
o
;
return
Integer
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Integer
.
compare
(
value
,
((
ValueByte
)
o
).
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
f4f75172
...
...
@@ -94,7 +94,7 @@ public class ValueBytes extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
byte
[]
v2
=
((
ValueBytes
)
v
).
value
;
if
(
mode
.
isBinaryUnsigned
())
{
return
Bits
.
compareNotNullUnsigned
(
value
,
v2
);
...
...
h2/src/main/org/h2/value/ValueDate.java
浏览文件 @
f4f75172
...
...
@@ -113,7 +113,7 @@ public class ValueDate extends Value {
}
@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
);
}
...
...
h2/src/main/org/h2/value/ValueDecimal.java
浏览文件 @
f4f75172
...
...
@@ -127,9 +127,8 @@ public class ValueDecimal extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueDecimal
v
=
(
ValueDecimal
)
o
;
return
value
.
compareTo
(
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
value
.
compareTo
(((
ValueDecimal
)
o
).
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueDouble.java
浏览文件 @
f4f75172
...
...
@@ -101,9 +101,8 @@ public class ValueDouble extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueDouble
v
=
(
ValueDouble
)
o
;
return
Double
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Double
.
compare
(
value
,
((
ValueDouble
)
o
).
value
);
}
@Override
...
...
@@ -180,7 +179,7 @@ public class ValueDouble extends Value {
if
(!(
other
instanceof
ValueDouble
))
{
return
false
;
}
return
compare
Secur
e
((
ValueDouble
)
other
,
null
)
==
0
;
return
compare
TypeSaf
e
((
ValueDouble
)
other
,
null
)
==
0
;
}
}
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
f4f75172
...
...
@@ -33,7 +33,7 @@ public class ValueEnumBase extends Value {
}
@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
());
}
...
...
h2/src/main/org/h2/value/ValueFloat.java
浏览文件 @
f4f75172
...
...
@@ -102,9 +102,8 @@ public class ValueFloat extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueFloat
v
=
(
ValueFloat
)
o
;
return
Float
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Float
.
compare
(
value
,
((
ValueFloat
)
o
).
value
);
}
@Override
...
...
@@ -180,7 +179,7 @@ public class ValueFloat extends Value {
if
(!(
other
instanceof
ValueFloat
))
{
return
false
;
}
return
compare
Secur
e
((
ValueFloat
)
other
,
null
)
==
0
;
return
compare
TypeSaf
e
((
ValueFloat
)
other
,
null
)
==
0
;
}
}
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
f4f75172
...
...
@@ -243,9 +243,8 @@ public class ValueGeometry extends Value {
}
@Override
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
Geometry
g
=
((
ValueGeometry
)
v
).
getGeometryNoCopy
();
return
getGeometryNoCopy
().
compareTo
(
g
);
public
int
compareTypeSafe
(
Value
v
,
CompareMode
mode
)
{
return
getGeometryNoCopy
().
compareTo
(((
ValueGeometry
)
v
).
getGeometryNoCopy
());
}
@Override
...
...
h2/src/main/org/h2/value/ValueInt.java
浏览文件 @
f4f75172
...
...
@@ -141,9 +141,8 @@ public class ValueInt extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueInt
v
=
(
ValueInt
)
o
;
return
Integer
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Integer
.
compare
(
value
,
((
ValueInt
)
o
).
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueJavaObject.java
浏览文件 @
f4f75172
...
...
@@ -102,7 +102,7 @@ public class ValueJavaObject extends ValueBytes {
}
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
Object
o1
=
getObject
();
Object
o2
=
v
.
getObject
();
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
f4f75172
...
...
@@ -515,7 +515,7 @@ public class ValueLob extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
return
compare
(
this
,
v
);
}
...
...
@@ -613,7 +613,7 @@ public class ValueLob extends Value {
public
boolean
equals
(
Object
other
)
{
if
(
other
instanceof
ValueLob
)
{
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
;
}
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
f4f75172
...
...
@@ -375,7 +375,7 @@ public class ValueLobDb extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
if
(
v
instanceof
ValueLobDb
)
{
ValueLobDb
v2
=
(
ValueLobDb
)
v
;
if
(
v
==
this
)
{
...
...
@@ -511,7 +511,7 @@ public class ValueLobDb extends Value {
ValueLobDb
otherLob
=
(
ValueLobDb
)
other
;
if
(
hashCode
()
!=
otherLob
.
hashCode
())
return
false
;
return
compare
Secur
e
((
Value
)
other
,
null
)
==
0
;
return
compare
TypeSaf
e
((
Value
)
other
,
null
)
==
0
;
}
@Override
...
...
h2/src/main/org/h2/value/ValueLong.java
浏览文件 @
f4f75172
...
...
@@ -161,9 +161,8 @@ public class ValueLong extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueLong
v
=
(
ValueLong
)
o
;
return
Long
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Long
.
compare
(
value
,
((
ValueLong
)
o
).
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueNull.java
浏览文件 @
f4f75172
...
...
@@ -139,7 +139,7 @@ public class ValueNull extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
v
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
v
,
CompareMode
mode
)
{
throw
DbException
.
throwInternalError
(
"compare null"
);
}
...
...
h2/src/main/org/h2/value/ValueResultSet.java
浏览文件 @
f4f75172
...
...
@@ -116,7 +116,7 @@ public class ValueResultSet extends Value {
}
@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
());
}
...
...
h2/src/main/org/h2/value/ValueShort.java
浏览文件 @
f4f75172
...
...
@@ -108,9 +108,8 @@ public class ValueShort extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueShort
v
=
(
ValueShort
)
o
;
return
Integer
.
compare
(
value
,
v
.
value
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Integer
.
compare
(
value
,
((
ValueShort
)
o
).
value
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueString.java
浏览文件 @
f4f75172
...
...
@@ -45,10 +45,8 @@ public class ValueString extends Value {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
// compatibility: the other object could be another type
ValueString
v
=
(
ValueString
)
o
;
return
mode
.
compareString
(
value
,
v
.
value
,
false
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
mode
.
compareString
(
value
,
((
ValueString
)
o
).
value
,
false
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
浏览文件 @
f4f75172
...
...
@@ -27,9 +27,8 @@ public class ValueStringIgnoreCase extends ValueString {
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueStringIgnoreCase
v
=
(
ValueStringIgnoreCase
)
o
;
return
mode
.
compareString
(
value
,
v
.
value
,
true
);
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
mode
.
compareString
(
value
,
((
ValueStringIgnoreCase
)
o
).
value
,
true
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
f4f75172
...
...
@@ -181,7 +181,7 @@ public class ValueTime extends Value {
}
@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
);
}
...
...
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
f4f75172
...
...
@@ -235,7 +235,7 @@ public class ValueTimestamp extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
ValueTimestamp
t
=
(
ValueTimestamp
)
o
;
int
c
=
Long
.
compare
(
dateValue
,
t
.
dateValue
);
if
(
c
!=
0
)
{
...
...
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
浏览文件 @
f4f75172
...
...
@@ -224,7 +224,7 @@ public class ValueTimestampTimeZone extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
ValueTimestampTimeZone
t
=
(
ValueTimestampTimeZone
)
o
;
// Maximum time zone offset is +/-18 hours so difference in days between local
// and UTC cannot be more than one day
...
...
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
f4f75172
...
...
@@ -163,7 +163,7 @@ public class ValueUuid extends Value {
}
@Override
p
rotected
int
compareSecur
e
(
Value
o
,
CompareMode
mode
)
{
p
ublic
int
compareTypeSaf
e
(
Value
o
,
CompareMode
mode
)
{
if
(
o
==
this
)
{
return
0
;
}
...
...
@@ -176,7 +176,7 @@ public class ValueUuid extends Value {
@Override
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
...
...
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
f4f75172
...
...
@@ -371,7 +371,7 @@ public class TestCustomDataTypesHandler extends TestDb {
}
@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
());
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论