Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3f2932f9
提交
3f2932f9
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use TypeInfo in Value implementations
上级
41d238b1
master
version-1.4.198
无相关合并请求
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
74 个修改的文件
包含
678 行增加
和
584 行删除
+678
-584
Parser.java
h2/src/main/org/h2/command/Parser.java
+10
-9
Call.java
h2/src/main/org/h2/command/dml/Call.java
+1
-1
Query.java
h2/src/main/org/h2/command/dml/Query.java
+1
-1
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+5
-5
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+1
-1
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-1
Expression.java
h2/src/main/org/h2/expression/Expression.java
+1
-3
IntervalOperation.java
h2/src/main/org/h2/expression/IntervalOperation.java
+1
-1
Parameter.java
h2/src/main/org/h2/expression/Parameter.java
+4
-4
ParameterRemote.java
h2/src/main/org/h2/expression/ParameterRemote.java
+3
-3
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+5
-5
Variable.java
h2/src/main/org/h2/expression/Variable.java
+4
-4
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-1
AggregateDataDefault.java
...ain/org/h2/expression/aggregate/AggregateDataDefault.java
+3
-3
WindowFrame.java
h2/src/main/org/h2/expression/analysis/WindowFrame.java
+1
-1
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+1
-1
ConditionInParameter.java
...ain/org/h2/expression/condition/ConditionInParameter.java
+1
-1
ConditionInSelect.java
...c/main/org/h2/expression/condition/ConditionInSelect.java
+3
-2
Function.java
h2/src/main/org/h2/expression/function/Function.java
+9
-9
TableFunction.java
h2/src/main/org/h2/expression/function/TableFunction.java
+1
-1
JdbcBlob.java
h2/src/main/org/h2/jdbc/JdbcBlob.java
+3
-3
JdbcClob.java
h2/src/main/org/h2/jdbc/JdbcClob.java
+3
-3
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+1
-1
FunctionsMySQL.java
h2/src/main/org/h2/mode/FunctionsMySQL.java
+1
-1
ValueDataType.java
h2/src/main/org/h2/mvstore/db/ValueDataType.java
+3
-3
RowList.java
h2/src/main/org/h2/result/RowList.java
+1
-1
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+1
-1
Data.java
h2/src/main/org/h2/store/Data.java
+9
-9
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+1
-1
LobStorageMap.java
h2/src/main/org/h2/store/LobStorageMap.java
+2
-2
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+1
-1
Column.java
h2/src/main/org/h2/table/Column.java
+4
-3
Recover.java
h2/src/main/org/h2/tools/Recover.java
+3
-3
LocalDateTimeUtils.java
h2/src/main/org/h2/util/LocalDateTimeUtils.java
+2
-2
DataType.java
h2/src/main/org/h2/value/DataType.java
+34
-17
ExtTypeInfoEnum.java
h2/src/main/org/h2/value/ExtTypeInfoEnum.java
+4
-4
ExtTypeInfoGeometry.java
h2/src/main/org/h2/value/ExtTypeInfoGeometry.java
+1
-1
Transfer.java
h2/src/main/org/h2/value/Transfer.java
+5
-5
TypeInfo.java
h2/src/main/org/h2/value/TypeInfo.java
+163
-0
Value.java
h2/src/main/org/h2/value/Value.java
+46
-55
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+9
-4
ValueBoolean.java
h2/src/main/org/h2/value/ValueBoolean.java
+7
-12
ValueByte.java
h2/src/main/org/h2/value/ValueByte.java
+7
-12
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+14
-12
ValueCollectionBase.java
h2/src/main/org/h2/value/ValueCollectionBase.java
+17
-17
ValueDate.java
h2/src/main/org/h2/value/ValueDate.java
+7
-12
ValueDecimal.java
h2/src/main/org/h2/value/ValueDecimal.java
+17
-24
ValueDouble.java
h2/src/main/org/h2/value/ValueDouble.java
+7
-17
ValueEnum.java
h2/src/main/org/h2/value/ValueEnum.java
+5
-0
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+9
-14
ValueFloat.java
h2/src/main/org/h2/value/ValueFloat.java
+7
-17
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+7
-12
ValueInt.java
h2/src/main/org/h2/value/ValueInt.java
+7
-12
ValueInterval.java
h2/src/main/org/h2/value/ValueInterval.java
+25
-20
ValueJavaObject.java
h2/src/main/org/h2/value/ValueJavaObject.java
+25
-19
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+15
-15
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+18
-18
ValueLong.java
h2/src/main/org/h2/value/ValueLong.java
+7
-12
ValueNull.java
h2/src/main/org/h2/value/ValueNull.java
+9
-14
ValueResultSet.java
h2/src/main/org/h2/value/ValueResultSet.java
+4
-10
ValueRow.java
h2/src/main/org/h2/value/ValueRow.java
+9
-4
ValueShort.java
h2/src/main/org/h2/value/ValueShort.java
+7
-12
ValueString.java
h2/src/main/org/h2/value/ValueString.java
+14
-12
ValueStringFixed.java
h2/src/main/org/h2/value/ValueStringFixed.java
+2
-2
ValueStringIgnoreCase.java
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
+2
-2
ValueTime.java
h2/src/main/org/h2/value/ValueTime.java
+7
-12
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+7
-17
ValueTimestampTimeZone.java
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
+7
-17
ValueUuid.java
h2/src/main/org/h2/value/ValueUuid.java
+6
-11
TestCustomDataTypesHandler.java
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
+10
-14
TestDataPage.java
h2/src/test/org/h2/test/unit/TestDataPage.java
+3
-3
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+14
-10
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+20
-20
TestValueMemory.java
h2/src/test/org/h2/test/unit/TestValueMemory.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3f2932f9
...
...
@@ -4020,7 +4020,7 @@ public class Parser {
}
break
;
case
'D'
:
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
&&
if
(
currentTokenType
==
VALUE
&&
currentValue
.
get
Value
Type
()
==
Value
.
STRING
&&
(
equalsToken
(
"DATE"
,
name
)
||
equalsToken
(
"D"
,
name
)))
{
String
date
=
currentValue
.
getString
();
read
();
...
...
@@ -4028,7 +4028,7 @@ public class Parser {
}
break
;
case
'E'
:
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
&&
equalsToken
(
"E"
,
name
))
{
if
(
currentTokenType
==
VALUE
&&
currentValue
.
get
Value
Type
()
==
Value
.
STRING
&&
equalsToken
(
"E"
,
name
))
{
String
text
=
currentValue
.
getString
();
// the PostgreSQL ODBC driver uses
// LIKE E'PROJECT\\_DATA' instead of LIKE
...
...
@@ -4043,7 +4043,8 @@ public class Parser {
if
(
equalsToken
(
"NEXT"
,
name
)
&&
readIf
(
"VALUE"
))
{
read
(
FOR
);
return
new
SequenceValue
(
readSequence
());
}
else
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
&&
equalsToken
(
"N"
,
name
))
{
}
else
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getValueType
()
==
Value
.
STRING
&&
equalsToken
(
"N"
,
name
))
{
// SQL-92 "National Language" strings
String
text
=
currentValue
.
getString
();
read
();
...
...
@@ -4066,7 +4067,7 @@ public class Parser {
read
(
"TIME"
);
read
(
"ZONE"
);
}
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
if
(
currentTokenType
==
VALUE
&&
currentValue
.
get
Value
Type
()
==
Value
.
STRING
)
{
String
time
=
currentValue
.
getString
();
read
();
return
ValueExpression
.
get
(
ValueTime
.
parse
(
time
));
...
...
@@ -4077,7 +4078,7 @@ public class Parser {
if
(
readIf
(
WITH
))
{
read
(
"TIME"
);
read
(
"ZONE"
);
if
(
currentTokenType
!=
VALUE
||
currentValue
.
getType
()
!=
Value
.
STRING
)
{
if
(
currentTokenType
!=
VALUE
||
currentValue
.
get
Value
Type
()
!=
Value
.
STRING
)
{
throw
getSyntaxError
();
}
String
timestamp
=
currentValue
.
getString
();
...
...
@@ -4089,7 +4090,7 @@ public class Parser {
read
(
"TIME"
);
read
(
"ZONE"
);
}
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
if
(
currentTokenType
==
VALUE
&&
currentValue
.
get
Value
Type
()
==
Value
.
STRING
)
{
String
timestamp
=
currentValue
.
getString
();
read
();
return
ValueExpression
.
get
(
ValueTimestamp
.
parse
(
timestamp
,
database
.
getMode
()));
...
...
@@ -4099,7 +4100,7 @@ public class Parser {
}
}
else
if
(
equalsToken
(
"TODAY"
,
name
))
{
return
readFunctionWithoutParameters
(
"CURRENT_DATE"
);
}
else
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
}
else
if
(
currentTokenType
==
VALUE
&&
currentValue
.
get
Value
Type
()
==
Value
.
STRING
)
{
if
(
equalsToken
(
"T"
,
name
))
{
String
time
=
currentValue
.
getString
();
read
();
...
...
@@ -4112,7 +4113,7 @@ public class Parser {
}
break
;
case
'X'
:
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
&&
equalsToken
(
"X"
,
name
))
{
if
(
currentTokenType
==
VALUE
&&
currentValue
.
get
Value
Type
()
==
Value
.
STRING
&&
equalsToken
(
"X"
,
name
))
{
byte
[]
buffer
=
StringUtils
.
convertHexToBytes
(
currentValue
.
getString
());
read
();
return
ValueExpression
.
get
(
ValueBytes
.
getNoCopy
(
buffer
));
...
...
@@ -7685,7 +7686,7 @@ public class Parser {
if
(
readIf
(
"AUTO_INCREMENT"
))
{
read
(
EQUAL
);
if
(
currentTokenType
!=
VALUE
||
currentValue
.
getType
()
!=
Value
.
INT
)
{
currentValue
.
get
Value
Type
()
!=
Value
.
INT
)
{
throw
DbException
.
getSyntaxError
(
sqlCommand
,
parseIndex
,
"integer"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Call.java
浏览文件 @
3f2932f9
...
...
@@ -44,7 +44,7 @@ public class Call extends Prepared {
@Override
public
int
update
()
{
Value
v
=
expression
.
getValue
(
session
);
int
type
=
v
.
getType
();
int
type
=
v
.
get
Value
Type
();
switch
(
type
)
{
case
Value
.
RESULT_SET
:
// this will throw an exception
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
3f2932f9
...
...
@@ -362,7 +362,7 @@ public abstract class Query extends Prepared {
Database
db
=
s
.
getDatabase
();
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++)
{
Value
a
=
lastParams
[
i
],
b
=
params
[
i
];
if
(
a
.
get
Type
()
!=
b
.
get
Type
()
||
!
db
.
areEqual
(
a
,
b
))
{
if
(
a
.
get
ValueType
()
!=
b
.
getValue
Type
()
||
!
db
.
areEqual
(
a
,
b
))
{
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
3f2932f9
...
...
@@ -413,12 +413,12 @@ public class ScriptCommand extends ScriptBase {
buff
.
append
(
", "
);
}
Value
v
=
row
.
getValue
(
j
);
if
(
v
.
getPrecision
()
>
lobBlockSize
)
{
if
(
v
.
get
Type
().
get
Precision
()
>
lobBlockSize
)
{
int
id
;
if
(
v
.
getType
()
==
Value
.
CLOB
)
{
if
(
v
.
get
Value
Type
()
==
Value
.
CLOB
)
{
id
=
writeLobStream
(
v
);
buff
.
append
(
"SYSTEM_COMBINE_CLOB("
).
append
(
id
).
append
(
')'
);
}
else
if
(
v
.
getType
()
==
Value
.
BLOB
)
{
}
else
if
(
v
.
get
Value
Type
()
==
Value
.
BLOB
)
{
id
=
writeLobStream
(
v
);
buff
.
append
(
"SYSTEM_COMBINE_BLOB("
).
append
(
id
).
append
(
')'
);
}
else
{
...
...
@@ -459,7 +459,7 @@ public class ScriptCommand extends ScriptBase {
tempLobTableCreated
=
true
;
}
int
id
=
nextLobId
++;
switch
(
v
.
getType
())
{
switch
(
v
.
get
Value
Type
())
{
case
Value
.
BLOB
:
{
byte
[]
bytes
=
new
byte
[
lobBlockSize
];
try
(
InputStream
input
=
v
.
getInputStream
())
{
...
...
@@ -499,7 +499,7 @@ public class ScriptCommand extends ScriptBase {
break
;
}
default
:
DbException
.
throwInternalError
(
"type:"
+
v
.
getType
());
DbException
.
throwInternalError
(
"type:"
+
v
.
get
Value
Type
());
}
return
id
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
3f2932f9
...
...
@@ -403,7 +403,7 @@ public class FunctionAlias extends SchemaObjectBase {
Object
o
;
if
(
Value
.
class
.
isAssignableFrom
(
paramClass
))
{
o
=
v
;
}
else
if
(
v
.
getType
()
==
Value
.
ARRAY
&&
}
else
if
(
v
.
get
Value
Type
()
==
Value
.
ARRAY
&&
paramClass
.
isArray
()
&&
paramClass
.
getComponentType
()
!=
Object
.
class
)
{
Value
[]
array
=
((
ValueArray
)
v
).
getList
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
3f2932f9
...
...
@@ -1745,7 +1745,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
@Override
public
void
addTemporaryLob
(
Value
v
)
{
if
(!
DataType
.
isLargeObject
(
v
.
getType
()))
{
if
(!
DataType
.
isLargeObject
(
v
.
get
Value
Type
()))
{
return
;
}
if
(
v
.
getTableId
()
==
LobStorageFrontend
.
TABLE_RESULT
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
3f2932f9
...
...
@@ -395,9 +395,7 @@ public abstract class Expression {
ExpressionColumn
[]
expr
=
new
ExpressionColumn
[
list
.
length
];
for
(
int
i
=
0
,
len
=
list
.
length
;
i
<
len
;
i
++)
{
Value
v
=
list
[
i
];
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
v
.
getType
(),
v
.
getPrecision
(),
v
.
getScale
(),
v
.
getDisplaySize
());
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
v
.
getType
());
expr
[
i
]
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
}
return
expr
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/IntervalOperation.java
浏览文件 @
3f2932f9
...
...
@@ -144,7 +144,7 @@ public class IntervalOperation extends Expression {
if
(
l
==
ValueNull
.
INSTANCE
||
r
==
ValueNull
.
INSTANCE
)
{
return
ValueNull
.
INSTANCE
;
}
int
lType
=
l
.
get
Type
(),
rType
=
r
.
get
Type
();
int
lType
=
l
.
get
ValueType
(),
rType
=
r
.
getValue
Type
();
switch
(
opType
)
{
case
INTERVAL_PLUS_INTERVAL:
case
INTERVAL_MINUS_INTERVAL:
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Parameter.java
浏览文件 @
3f2932f9
...
...
@@ -63,7 +63,7 @@ public class Parameter extends Expression implements ParameterInterface {
@Override
public
int
getType
()
{
if
(
value
!=
null
)
{
return
value
.
getType
();
return
value
.
get
Value
Type
();
}
if
(
column
!=
null
)
{
return
column
.
getType
().
getValueType
();
...
...
@@ -111,7 +111,7 @@ public class Parameter extends Expression implements ParameterInterface {
@Override
public
int
getScale
()
{
if
(
value
!=
null
)
{
return
value
.
getScale
();
return
value
.
get
Type
().
get
Scale
();
}
if
(
column
!=
null
)
{
return
column
.
getType
().
getScale
();
...
...
@@ -122,7 +122,7 @@ public class Parameter extends Expression implements ParameterInterface {
@Override
public
long
getPrecision
()
{
if
(
value
!=
null
)
{
return
value
.
getPrecision
();
return
value
.
get
Type
().
get
Precision
();
}
if
(
column
!=
null
)
{
return
column
.
getType
().
getPrecision
();
...
...
@@ -133,7 +133,7 @@ public class Parameter extends Expression implements ParameterInterface {
@Override
public
int
getDisplaySize
()
{
if
(
value
!=
null
)
{
return
value
.
getDisplaySize
();
return
value
.
get
Type
().
get
DisplaySize
();
}
if
(
column
!=
null
)
{
return
column
.
getType
().
getDisplaySize
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ParameterRemote.java
浏览文件 @
3f2932f9
...
...
@@ -56,17 +56,17 @@ public class ParameterRemote implements ParameterInterface {
@Override
public
int
getType
()
{
return
value
==
null
?
dataType
:
value
.
getType
();
return
value
==
null
?
dataType
:
value
.
get
Value
Type
();
}
@Override
public
long
getPrecision
()
{
return
value
==
null
?
precision
:
value
.
getPrecision
();
return
value
==
null
?
precision
:
value
.
get
Type
().
get
Precision
();
}
@Override
public
int
getScale
()
{
return
value
==
null
?
scale
:
value
.
getScale
();
return
value
==
null
?
scale
:
value
.
get
Type
().
get
Scale
();
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
3f2932f9
...
...
@@ -76,12 +76,12 @@ public class ValueExpression extends Expression {
@Override
public
int
getType
()
{
return
value
.
getType
();
return
value
.
get
Value
Type
();
}
@Override
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
if
(
value
.
getType
()
==
Value
.
BOOLEAN
)
{
if
(
value
.
get
Value
Type
()
==
Value
.
BOOLEAN
)
{
boolean
v
=
((
ValueBoolean
)
value
).
getBoolean
();
if
(!
v
)
{
filter
.
addIndexCondition
(
IndexCondition
.
get
(
Comparison
.
FALSE
,
null
,
this
));
...
...
@@ -122,17 +122,17 @@ public class ValueExpression extends Expression {
@Override
public
int
getScale
()
{
return
value
.
getScale
();
return
value
.
get
Type
().
get
Scale
();
}
@Override
public
long
getPrecision
()
{
return
value
.
getPrecision
();
return
value
.
get
Type
().
get
Precision
();
}
@Override
public
int
getDisplaySize
()
{
return
value
.
getDisplaySize
();
return
value
.
get
Type
().
get
DisplaySize
();
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
3f2932f9
...
...
@@ -32,12 +32,12 @@ public class Variable extends Expression {
@Override
public
int
getDisplaySize
()
{
return
lastValue
.
getDisplaySize
();
return
lastValue
.
get
Type
().
get
DisplaySize
();
}
@Override
public
long
getPrecision
()
{
return
lastValue
.
getPrecision
();
return
lastValue
.
get
Type
().
get
Precision
();
}
@Override
...
...
@@ -48,12 +48,12 @@ public class Variable extends Expression {
@Override
public
int
getScale
()
{
return
lastValue
.
getScale
();
return
lastValue
.
get
Type
().
get
Scale
();
}
@Override
public
int
getType
()
{
return
lastValue
.
getType
();
return
lastValue
.
get
Value
Type
();
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
3f2932f9
...
...
@@ -497,7 +497,7 @@ public class Aggregate extends AbstractAggregate {
String
sep
=
groupConcatSeparator
==
null
?
","
:
groupConcatSeparator
.
getValue
(
session
).
getString
();
for
(
Value
val
:
array
)
{
String
s
;
if
(
val
.
getType
()
==
Value
.
ARRAY
)
{
if
(
val
.
get
Value
Type
()
==
Value
.
ARRAY
)
{
s
=
((
ValueArray
)
val
).
getList
()[
0
].
getString
();
}
else
{
s
=
val
.
getString
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/aggregate/AggregateDataDefault.java
浏览文件 @
3f2932f9
...
...
@@ -43,7 +43,7 @@ class AggregateDataDefault extends AggregateData {
if
(
value
==
null
)
{
value
=
v
.
convertTo
(
dataType
);
}
else
{
v
=
v
.
convertTo
(
value
.
getType
());
v
=
v
.
convertTo
(
value
.
get
Value
Type
());
value
=
value
.
add
(
v
);
}
break
;
...
...
@@ -51,7 +51,7 @@ class AggregateDataDefault extends AggregateData {
if
(
value
==
null
)
{
value
=
v
.
convertTo
(
DataType
.
getAddProofType
(
dataType
));
}
else
{
v
=
v
.
convertTo
(
value
.
getType
());
v
=
v
.
convertTo
(
value
.
get
Value
Type
());
value
=
value
.
add
(
v
);
}
break
;
...
...
@@ -174,7 +174,7 @@ class AggregateDataDefault extends AggregateData {
if
(
by
==
0
)
{
return
ValueNull
.
INSTANCE
;
}
int
type
=
Value
.
getHigherOrder
(
a
.
getType
(),
Value
.
LONG
);
int
type
=
Value
.
getHigherOrder
(
a
.
get
Value
Type
(),
Value
.
LONG
);
Value
b
=
ValueLong
.
get
(
by
).
convertTo
(
type
);
a
=
a
.
convertTo
(
type
).
divide
(
b
);
return
a
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/analysis/WindowFrame.java
浏览文件 @
3f2932f9
...
...
@@ -322,7 +322,7 @@ public final class WindowFrame {
int
sortIndex
=
sortOrder
.
getQueryColumnIndexes
()[
0
];
Value
[]
row
=
orderedRows
.
get
(
currentRow
);
Value
currentValue
=
row
[
sortIndex
];
int
type
=
currentValue
.
getType
();
int
type
=
currentValue
.
get
Value
Type
();
Value
newValue
;
Value
range
=
getValueOffset
(
bound
,
orderedRows
.
get
(
currentRow
),
session
);
switch
(
type
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
3f2932f9
...
...
@@ -226,7 +226,7 @@ public class Comparison extends Condition {
}
}
int
colType
=
left
.
getType
();
int
constType
=
r
.
getType
();
int
constType
=
r
.
get
Value
Type
();
int
resType
=
Value
.
getHigherOrder
(
colType
,
constType
);
// If not, the column values will need to be promoted
// to constant type, but vise versa, then let's do this here
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/ConditionInParameter.java
浏览文件 @
3f2932f9
...
...
@@ -77,7 +77,7 @@ public class ConditionInParameter extends Condition {
boolean
hasNull
=
false
;
if
(
value
.
containsNull
())
{
hasNull
=
true
;
}
else
if
(
value
.
getType
()
==
Value
.
RESULT_SET
)
{
}
else
if
(
value
.
get
Value
Type
()
==
Value
.
RESULT_SET
)
{
for
(
ResultInterface
ri
=
value
.
getResult
();
ri
.
next
();)
{
Value
r
=
ri
.
currentRow
()[
0
];
Value
cmp
=
Comparison
.
compare
(
database
,
l
,
r
,
Comparison
.
EQUAL
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/ConditionInSelect.java
浏览文件 @
3f2932f9
...
...
@@ -76,7 +76,7 @@ public class ConditionInSelect extends Condition {
if
(
dataType
==
Value
.
NULL
)
{
return
ValueBoolean
.
FALSE
;
}
if
(
l
.
getType
()
==
Value
.
ROW
)
{
if
(
l
.
get
Value
Type
()
==
Value
.
ROW
)
{
Value
[]
leftList
=
((
ValueRow
)
l
).
getList
();
if
(
leftList
.
length
!=
1
)
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
...
...
@@ -125,7 +125,8 @@ public class ConditionInSelect extends Condition {
private
Value
compare
(
Value
l
,
ResultInterface
rows
)
{
Value
[]
currentRow
=
rows
.
currentRow
();
Value
r
=
l
.
getType
()
!=
Value
.
ROW
&&
query
.
getColumnCount
()
==
1
?
currentRow
[
0
]
:
ValueRow
.
get
(
currentRow
);
Value
r
=
l
.
getValueType
()
!=
Value
.
ROW
&&
query
.
getColumnCount
()
==
1
?
currentRow
[
0
]
:
ValueRow
.
get
(
currentRow
);
return
Comparison
.
compare
(
database
,
l
,
r
,
compareType
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
3f2932f9
...
...
@@ -1099,7 +1099,7 @@ public class Function extends Expression implements FunctionCall {
}
private
static
Value
[]
getArray
(
Value
v0
)
{
int
t
=
v0
.
getType
();
int
t
=
v0
.
get
Value
Type
();
Value
[]
list
;
if
(
t
==
Value
.
ARRAY
||
t
==
Value
.
ROW
)
{
list
=
((
ValueCollectionBase
)
v0
).
getList
();
...
...
@@ -1243,15 +1243,15 @@ public class Function extends Expression implements FunctionCall {
break
;
}
case
TRUNCATE:
{
if
(
v0
.
getType
()
==
Value
.
TIMESTAMP
)
{
if
(
v0
.
get
Value
Type
()
==
Value
.
TIMESTAMP
)
{
result
=
ValueTimestamp
.
fromDateValueAndNanos
(((
ValueTimestamp
)
v0
).
getDateValue
(),
0
);
}
else
if
(
v0
.
getType
()
==
Value
.
DATE
)
{
}
else
if
(
v0
.
get
Value
Type
()
==
Value
.
DATE
)
{
result
=
ValueTimestamp
.
fromDateValueAndNanos
(((
ValueDate
)
v0
).
getDateValue
(),
0
);
}
else
if
(
v0
.
getType
()
==
Value
.
TIMESTAMP_TZ
)
{
}
else
if
(
v0
.
get
Value
Type
()
==
Value
.
TIMESTAMP_TZ
)
{
ValueTimestampTimeZone
ts
=
(
ValueTimestampTimeZone
)
v0
;
result
=
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
ts
.
getDateValue
(),
0
,
ts
.
getTimeZoneOffsetMins
());
}
else
if
(
v0
.
getType
()
==
Value
.
STRING
)
{
}
else
if
(
v0
.
get
Value
Type
()
==
Value
.
STRING
)
{
ValueTimestamp
ts
=
ValueTimestamp
.
parse
(
v0
.
getString
(),
session
.
getDatabase
().
getMode
());
result
=
ValueTimestamp
.
fromDateValueAndNanos
(
ts
.
getDateValue
(),
0
);
}
else
{
...
...
@@ -1408,7 +1408,7 @@ public class Function extends Expression implements FunctionCall {
database
.
getMode
().
treatEmptyStringsAsNull
);
break
;
case
TO_CHAR:
switch
(
v0
.
getType
()){
switch
(
v0
.
get
Value
Type
()){
case
Value
.
TIME
:
case
Value
.
DATE
:
case
Value
.
TIMESTAMP
:
...
...
@@ -1776,12 +1776,12 @@ public class Function extends Expression implements FunctionCall {
}
private
static
long
length
(
Value
v
)
{
switch
(
v
.
getType
())
{
switch
(
v
.
get
Value
Type
())
{
case
Value
.
BLOB
:
case
Value
.
CLOB
:
case
Value
.
BYTES
:
case
Value
.
JAVA_OBJECT
:
return
v
.
getPrecision
();
return
v
.
get
Type
().
get
Precision
();
default
:
return
v
.
getString
().
length
();
}
...
...
@@ -2057,7 +2057,7 @@ public class Function extends Expression implements FunctionCall {
private
static
MessageDigest
hashImpl
(
Value
value
,
String
algorithm
)
{
MessageDigest
md
;
switch
(
value
.
getType
())
{
switch
(
value
.
get
Value
Type
())
{
case
Value
.
NULL
:
return
null
;
case
Value
.
STRING
:
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/function/TableFunction.java
浏览文件 @
3f2932f9
...
...
@@ -105,7 +105,7 @@ public class TableFunction extends Function {
if
(
v
==
ValueNull
.
INSTANCE
)
{
list
[
i
]
=
new
Value
[
0
];
}
else
{
int
type
=
v
.
getType
();
int
type
=
v
.
get
Value
Type
();
if
(
type
!=
Value
.
ARRAY
&&
type
!=
Value
.
ROW
)
{
v
=
v
.
convertTo
(
Value
.
ARRAY
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcBlob.java
浏览文件 @
3f2932f9
...
...
@@ -44,8 +44,8 @@ public class JdbcBlob extends JdbcLob implements Blob {
try
{
debugCodeCall
(
"length"
);
checkReadable
();
if
(
value
.
getType
()
==
Value
.
BLOB
)
{
long
precision
=
value
.
getPrecision
();
if
(
value
.
get
Value
Type
()
==
Value
.
BLOB
)
{
long
precision
=
value
.
get
Type
().
get
Precision
();
if
(
precision
>
0
)
{
return
precision
;
}
...
...
@@ -144,7 +144,7 @@ public class JdbcBlob extends JdbcLob implements Blob {
throw
DbException
.
getInvalidValueException
(
"pos"
,
pos
);
}
completeWrite
(
conn
.
createBlob
(
new
ByteArrayInputStream
(
bytes
,
offset
,
len
),
-
1
));
return
(
int
)
value
.
getPrecision
();
return
(
int
)
value
.
get
Type
().
get
Precision
();
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcClob.java
浏览文件 @
3f2932f9
...
...
@@ -44,8 +44,8 @@ public class JdbcClob extends JdbcLob implements NClob {
try
{
debugCodeCall
(
"length"
);
checkReadable
();
if
(
value
.
getType
()
==
Value
.
CLOB
)
{
long
precision
=
value
.
getPrecision
();
if
(
value
.
get
Value
Type
()
==
Value
.
CLOB
)
{
long
precision
=
value
.
get
Type
().
get
Precision
();
if
(
precision
>
0
)
{
return
precision
;
}
...
...
@@ -206,7 +206,7 @@ public class JdbcClob extends JdbcLob implements NClob {
throw
DbException
.
getInvalidValueException
(
"str"
,
str
);
}
completeWrite
(
conn
.
createClob
(
new
RangeReader
(
new
StringReader
(
str
),
offset
,
len
),
-
1
));
return
(
int
)
value
.
getPrecision
();
return
(
int
)
value
.
get
Type
().
get
Precision
();
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
3f2932f9
...
...
@@ -2047,7 +2047,7 @@ public class JdbcConnection extends TraceObject
* @return the object
*/
Object
convertToDefaultObject
(
Value
v
)
{
switch
(
v
.
getType
())
{
switch
(
v
.
get
Value
Type
())
{
case
Value
.
CLOB
:
{
int
id
=
getNextId
(
TraceObject
.
CLOB
);
return
new
JdbcClob
(
this
,
v
,
JdbcLob
.
State
.
WITH_VALUE
,
id
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mode/FunctionsMySQL.java
浏览文件 @
3f2932f9
...
...
@@ -225,7 +225,7 @@ public class FunctionsMySQL extends FunctionsBase {
v1
==
null
?
fromUnixTime
(
v0
.
getInt
())
:
fromUnixTime
(
v0
.
getInt
(),
v1
.
getString
()));
break
;
case
DATE:
switch
(
v0
.
getType
())
{
switch
(
v0
.
get
Value
Type
())
{
case
Value
.
DATE
:
result
=
v0
;
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/ValueDataType.java
浏览文件 @
3f2932f9
...
...
@@ -206,7 +206,7 @@ public class ValueDataType implements DataType {
buff
.
put
((
byte
)
0
);
return
;
}
int
type
=
v
.
getType
();
int
type
=
v
.
get
Value
Type
();
switch
(
type
)
{
case
Value
.
BOOLEAN
:
buff
.
put
((
byte
)
(
v
.
getBoolean
()
?
BOOLEAN_TRUE
:
BOOLEAN_FALSE
));
...
...
@@ -392,7 +392,7 @@ public class ValueDataType implements DataType {
buff
.
putVarInt
(-
3
).
putVarInt
(
lob
.
getTableId
()).
putVarLong
(
lob
.
getLobId
()).
putVarLong
(
lob
.
getPrecision
());
putVarLong
(
lob
.
get
Type
().
get
Precision
());
}
else
{
buff
.
putVarInt
(
small
.
length
).
put
(
small
);
...
...
@@ -483,7 +483,7 @@ public class ValueDataType implements DataType {
put
(
b
);
break
;
}
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
DbException
.
throwInternalError
(
"type="
+
v
.
get
Value
Type
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/RowList.java
浏览文件 @
3f2932f9
...
...
@@ -63,7 +63,7 @@ public class RowList implements AutoCloseable {
buff
.
writeByte
((
byte
)
0
);
}
else
{
buff
.
writeByte
((
byte
)
1
);
if
(
DataType
.
isLargeObject
(
v
.
getType
()))
{
if
(
DataType
.
isLargeObject
(
v
.
get
Value
Type
()))
{
// need to keep a reference to temporary lobs,
// otherwise the temp file is deleted
if
(
v
.
getSmall
()
==
null
&&
v
.
getTableId
()
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
3f2932f9
...
...
@@ -573,7 +573,7 @@ public class TcpServerThread implements Runnable {
}
private
void
writeValue
(
Value
v
)
throws
IOException
{
if
(
DataType
.
isLargeObject
(
v
.
getType
()))
{
if
(
DataType
.
isLargeObject
(
v
.
get
Value
Type
()))
{
if
(
v
instanceof
ValueLobDb
)
{
ValueLobDb
lob
=
(
ValueLobDb
)
v
;
if
(
lob
.
isStored
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/Data.java
浏览文件 @
3f2932f9
...
...
@@ -423,7 +423,7 @@ public class Data {
data
[
pos
++]
=
0
;
return
;
}
int
type
=
v
.
getType
();
int
type
=
v
.
get
Value
Type
();
switch
(
type
)
{
case
Value
.
BOOLEAN
:
writeByte
((
byte
)
(
v
.
getBoolean
()
?
BOOLEAN_TRUE
:
BOOLEAN_FALSE
));
...
...
@@ -636,7 +636,7 @@ public class Data {
writeVarInt
(
t
);
writeVarInt
(
lob
.
getTableId
());
writeVarInt
(
lob
.
getObjectId
());
writeVarLong
(
lob
.
getPrecision
());
writeVarLong
(
lob
.
get
Type
().
get
Precision
());
writeByte
((
byte
)
(
lob
.
isCompressed
()
?
1
:
0
));
if
(
t
==
-
2
)
{
writeString
(
lob
.
getFileName
());
...
...
@@ -652,7 +652,7 @@ public class Data {
writeVarInt
(-
3
);
writeVarInt
(
lob
.
getTableId
());
writeVarLong
(
lob
.
getLobId
());
writeVarLong
(
lob
.
getPrecision
());
writeVarLong
(
lob
.
get
Type
().
get
Precision
());
}
else
{
writeVarInt
(
small
.
length
);
write
(
small
,
0
,
small
.
length
);
...
...
@@ -737,7 +737,7 @@ public class Data {
write
(
b
,
0
,
b
.
length
);
break
;
}
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
DbException
.
throwInternalError
(
"type="
+
v
.
get
Value
Type
());
}
assert
pos
-
start
==
getValueLen
(
v
)
:
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
);
...
...
@@ -978,7 +978,7 @@ public class Data {
if
(
v
==
ValueNull
.
INSTANCE
)
{
return
1
;
}
switch
(
v
.
getType
())
{
switch
(
v
.
get
Value
Type
())
{
case
Value
.
BOOLEAN
:
return
1
;
case
Value
.
BYTE
:
...
...
@@ -1125,7 +1125,7 @@ public class Data {
len
+=
getVarIntLen
(
t
);
len
+=
getVarIntLen
(
lob
.
getTableId
());
len
+=
getVarIntLen
(
lob
.
getObjectId
());
len
+=
getVarLongLen
(
lob
.
getPrecision
());
len
+=
getVarLongLen
(
lob
.
get
Type
().
get
Precision
());
len
+=
1
;
if
(
t
==
-
2
)
{
len
+=
getStringLen
(
lob
.
getFileName
());
...
...
@@ -1141,7 +1141,7 @@ public class Data {
len
+=
getVarIntLen
(-
3
);
len
+=
getVarIntLen
(
lob
.
getTableId
());
len
+=
getVarLongLen
(
lob
.
getLobId
());
len
+=
getVarLongLen
(
lob
.
getPrecision
());
len
+=
getVarLongLen
(
lob
.
get
Type
().
get
Precision
());
}
else
{
len
+=
getVarIntLen
(
small
.
length
);
len
+=
small
.
length
;
...
...
@@ -1204,10 +1204,10 @@ public class Data {
default
:
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
byte
[]
b
=
v
.
getBytesNoCopy
();
return
1
+
getVarIntLen
(
v
.
getType
())
return
1
+
getVarIntLen
(
v
.
get
Value
Type
())
+
getVarIntLen
(
b
.
length
)
+
b
.
length
;
}
throw
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
throw
DbException
.
throwInternalError
(
"type="
+
v
.
get
Value
Type
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
3f2932f9
...
...
@@ -434,7 +434,7 @@ public class LobStorageBackend implements LobStorageInterface {
@Override
public
ValueLobDb
copyLob
(
ValueLobDb
old
,
int
tableId
,
long
length
)
{
int
type
=
old
.
getType
();
int
type
=
old
.
get
Value
Type
();
long
oldLobId
=
old
.
getLobId
();
assertNotHolds
(
conn
.
getSession
());
// see locking discussion at the top
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LobStorageMap.java
浏览文件 @
3f2932f9
...
...
@@ -245,9 +245,9 @@ public class LobStorageMap implements LobStorageInterface {
@Override
public
ValueLobDb
copyLob
(
ValueLobDb
old
,
int
tableId
,
long
length
)
{
init
();
int
type
=
old
.
getType
();
int
type
=
old
.
get
Value
Type
();
long
oldLobId
=
old
.
getLobId
();
long
oldLength
=
old
.
getPrecision
();
long
oldLength
=
old
.
get
Type
().
get
Precision
();
if
(
oldLength
!=
length
)
{
throw
DbException
.
throwInternalError
(
"Length is different"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
3f2932f9
...
...
@@ -634,7 +634,7 @@ public class PageLog {
}
else
{
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
if
(
v
.
getType
()
==
Value
.
BYTES
)
{
if
(
v
.
get
Value
Type
()
==
Value
.
BYTES
)
{
data
.
writeValue
(
ValueNull
.
INSTANCE
);
}
else
{
data
.
writeValue
(
v
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Column.java
浏览文件 @
3f2932f9
...
...
@@ -373,11 +373,12 @@ public class Column {
if
(
s
.
length
()
>
127
)
{
s
=
s
.
substring
(
0
,
128
)
+
"..."
;
}
throw
DbException
.
get
(
ErrorCode
.
VALUE_TOO_LONG_2
,
getCreateSQL
(),
s
+
" ("
+
value
.
getPrecision
()
+
")"
);
throw
DbException
.
get
(
ErrorCode
.
VALUE_TOO_LONG_2
,
getCreateSQL
(),
s
+
" ("
+
value
.
getType
().
getPrecision
()
+
')'
);
}
}
if
(
value
!=
ValueNull
.
INSTANCE
&&
DataType
.
isExtInfoType
(
type
.
getValueType
())
&&
type
.
getExtTypeInfo
()
!=
null
)
{
if
(
value
!=
ValueNull
.
INSTANCE
&&
DataType
.
isExtInfoType
(
type
.
getValueType
())
&&
type
.
getExtTypeInfo
()
!=
null
)
{
value
=
type
.
getExtTypeInfo
().
cast
(
value
);
}
updateSequenceIfRequired
(
session
,
value
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
3f2932f9
...
...
@@ -423,7 +423,7 @@ public class Recover extends Tool implements DataHandler {
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
String
file
=
lob
.
getFileName
();
String
type
=
lob
.
getType
()
==
Value
.
BLOB
?
"BLOB"
:
"CLOB"
;
String
type
=
lob
.
get
Value
Type
()
==
Value
.
BLOB
?
"BLOB"
:
"CLOB"
;
if
(
lob
.
isCompressed
())
{
dumpLob
(
file
,
true
);
file
+=
".comp"
;
...
...
@@ -435,9 +435,9 @@ public class Recover extends Tool implements DataHandler {
ValueLobDb
lob
=
(
ValueLobDb
)
v
;
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
int
type
=
lob
.
getType
();
int
type
=
lob
.
get
Value
Type
();
long
id
=
lob
.
getLobId
();
long
precision
=
lob
.
getPrecision
();
long
precision
=
lob
.
get
Type
().
get
Precision
();
String
columnType
;
if
(
type
==
Value
.
BLOB
)
{
columnType
=
"BLOB"
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/LocalDateTimeUtils.java
浏览文件 @
3f2932f9
...
...
@@ -429,7 +429,7 @@ public class LocalDateTimeUtils {
if
(!(
value
instanceof
ValueInterval
))
{
value
=
value
.
convertTo
(
Value
.
INTERVAL_YEAR_TO_MONTH
);
}
if
(!
DataType
.
isYearMonthIntervalType
(
value
.
getType
()))
{
if
(!
DataType
.
isYearMonthIntervalType
(
value
.
get
Value
Type
()))
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
(
Throwable
)
null
,
value
.
getString
());
}
ValueInterval
v
=
(
ValueInterval
)
value
;
...
...
@@ -460,7 +460,7 @@ public class LocalDateTimeUtils {
if
(!(
value
instanceof
ValueInterval
))
{
value
=
value
.
convertTo
(
Value
.
INTERVAL_DAY_TO_SECOND
);
}
if
(
DataType
.
isYearMonthIntervalType
(
value
.
getType
()))
{
if
(
DataType
.
isYearMonthIntervalType
(
value
.
get
Value
Type
()))
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
(
Throwable
)
null
,
value
.
getString
());
}
BigInteger
[]
dr
=
IntervalUtils
.
intervalToAbsolute
((
ValueInterval
)
value
)
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/DataType.java
浏览文件 @
3f2932f9
...
...
@@ -70,7 +70,7 @@ public class DataType {
*/
private
static
final
ArrayList
<
DataType
>
TYPES
=
new
ArrayList
<>(
96
);
private
static
final
HashMap
<
String
,
DataType
>
TYPES_BY_NAME
=
new
HashMap
<>(
128
);
private
static
final
HashMap
<
Integer
,
DataType
>
TYPES_BY_VALUE_TYPE
=
new
HashMap
<>(
64
)
;
static
final
DataType
[]
TYPES_BY_VALUE_TYPE
=
new
DataType
[
Value
.
TYPE_COUNT
]
;
/**
* The value type of this data type.
...
...
@@ -183,8 +183,11 @@ public class DataType {
}
GEOMETRY_CLASS
=
g
;
DataType
dataType
=
new
DataType
();
dataType
.
defaultPrecision
=
dataType
.
maxPrecision
=
ValueNull
.
PRECISION
;
dataType
.
defaultDisplaySize
=
ValueNull
.
DISPLAY_SIZE
;
add
(
Value
.
NULL
,
Types
.
NULL
,
new
DataType
()
,
dataType
,
new
String
[]{
"NULL"
},
// the value is always in the cache
0
...
...
@@ -331,6 +334,10 @@ public class DataType {
new
String
[]{
"LONGVARBINARY"
},
32
);
dataType
=
new
DataType
();
dataType
.
prefix
=
dataType
.
suffix
=
"'"
;
dataType
.
defaultPrecision
=
dataType
.
maxPrecision
=
ValueUuid
.
PRECISION
;
dataType
.
defaultDisplaySize
=
ValueUuid
.
DISPLAY_SIZE
;
add
(
Value
.
UUID
,
Types
.
BINARY
,
createString
(
false
),
// UNIQUEIDENTIFIER is the MSSQL mode equivalent
...
...
@@ -361,9 +368,9 @@ public class DataType {
new
String
[]{
"GEOMETRY"
},
32
);
DataType
dataType
=
new
DataType
();
dataType
.
prefix
=
"
(
"
;
dataType
.
suffix
=
"
')
"
;
dataType
=
new
DataType
();
dataType
.
prefix
=
"
ARRAY[
"
;
dataType
.
suffix
=
"
]
"
;
add
(
Value
.
ARRAY
,
Types
.
ARRAY
,
dataType
,
new
String
[]{
"ARRAY"
},
...
...
@@ -386,9 +393,14 @@ public class DataType {
for
(
int
i
=
Value
.
INTERVAL_YEAR
;
i
<=
Value
.
INTERVAL_MINUTE_TO_SECOND
;
i
++)
{
addInterval
(
i
);
}
for
(
Integer
i
:
TYPES_BY_VALUE_TYPE
.
keySet
())
{
Value
.
getOrder
(
i
);
}
// Row value doesn't have a type name
dataType
=
new
DataType
();
dataType
.
type
=
Value
.
ROW
;
dataType
.
name
=
"ROW"
;
dataType
.
sqlType
=
Types
.
OTHER
;
dataType
.
prefix
=
"ROW("
;
dataType
.
suffix
=
")"
;
TYPES_BY_VALUE_TYPE
[
Value
.
ROW
]
=
dataType
;
}
private
static
void
addDecimal
()
{
...
...
@@ -466,8 +478,8 @@ public class DataType {
}
}
TYPES_BY_NAME
.
put
(
dt
.
name
,
dt
);
if
(
TYPES_BY_VALUE_TYPE
.
get
(
type
)
==
null
)
{
TYPES_BY_VALUE_TYPE
.
put
(
type
,
dt
)
;
if
(
TYPES_BY_VALUE_TYPE
[
type
]
==
null
)
{
TYPES_BY_VALUE_TYPE
[
type
]
=
dt
;
}
TYPES
.
add
(
dt
);
}
...
...
@@ -955,14 +967,19 @@ public class DataType {
if
(
type
==
Value
.
UNKNOWN
)
{
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"?"
);
}
DataType
dt
=
TYPES_BY_VALUE_TYPE
.
get
(
type
);
if
(
dt
==
null
&&
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
dt
=
JdbcUtils
.
customDataTypesHandler
.
getDataTypeById
(
type
);
if
(
type
>=
Value
.
NULL
&&
type
<
Value
.
TYPE_COUNT
)
{
DataType
dt
=
TYPES_BY_VALUE_TYPE
[
type
];
if
(
dt
!=
null
)
{
return
dt
;
}
}
if
(
dt
==
null
)
{
dt
=
TYPES_BY_VALUE_TYPE
.
get
(
Value
.
NULL
);
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
DataType
dt
=
JdbcUtils
.
customDataTypesHandler
.
getDataTypeById
(
type
);
if
(
dt
!=
null
)
{
return
dt
;
}
}
return
dt
;
return
TYPES_BY_VALUE_TYPE
[
Value
.
NULL
]
;
}
/**
...
...
@@ -1598,7 +1615,7 @@ public class DataType {
}
else
if
(
paramClass
==
Array
.
class
)
{
return
new
JdbcArray
(
conn
,
v
,
0
);
}
switch
(
v
.
getType
())
{
switch
(
v
.
get
Value
Type
())
{
case
Value
.
JAVA_OBJECT
:
{
Object
o
=
SysProperties
.
serializeJavaObject
?
JdbcUtils
.
deserialize
(
v
.
getBytes
(),
conn
.
getSession
().
getDataHandler
())
:
v
.
getObject
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ExtTypeInfoEnum.java
浏览文件 @
3f2932f9
...
...
@@ -29,13 +29,13 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
* if both values do not have enumerators
*/
public
static
ExtTypeInfoEnum
getEnumeratorsForBinaryOperation
(
Value
left
,
Value
right
)
{
if
(
left
.
getType
()
==
Value
.
ENUM
)
{
if
(
left
.
get
Value
Type
()
==
Value
.
ENUM
)
{
return
((
ValueEnum
)
left
).
getEnumerators
();
}
else
if
(
right
.
getType
()
==
Value
.
ENUM
)
{
}
else
if
(
right
.
get
Value
Type
()
==
Value
.
ENUM
)
{
return
((
ValueEnum
)
right
).
getEnumerators
();
}
else
{
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"type1="
+
left
.
get
Type
()
+
", type2="
+
right
.
get
Type
());
"type1="
+
left
.
get
ValueType
()
+
", type2="
+
right
.
getValue
Type
());
}
}
...
...
@@ -94,7 +94,7 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
@Override
public
Value
cast
(
Value
value
)
{
switch
(
value
.
getType
())
{
switch
(
value
.
get
Value
Type
())
{
case
Value
.
ENUM
:
if
(
value
instanceof
ValueEnum
&&
((
ValueEnum
)
value
).
getEnumerators
().
equals
(
this
))
{
return
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ExtTypeInfoGeometry.java
浏览文件 @
3f2932f9
...
...
@@ -51,7 +51,7 @@ public final class ExtTypeInfoGeometry extends ExtTypeInfo {
@Override
public
Value
cast
(
Value
value
)
{
if
(
value
.
getType
()
!=
Value
.
GEOMETRY
)
{
if
(
value
.
get
Value
Type
()
!=
Value
.
GEOMETRY
)
{
value
=
value
.
convertTo
(
Value
.
GEOMETRY
);
}
ValueGeometry
g
=
(
ValueGeometry
)
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Transfer.java
浏览文件 @
3f2932f9
...
...
@@ -321,7 +321,7 @@ public class Transfer {
* @param v the value
*/
public
void
writeValue
(
Value
v
)
throws
IOException
{
int
type
=
v
.
getType
();
int
type
=
v
.
get
Value
Type
();
switch
(
type
)
{
case
Value
.
NULL
:
writeInt
(
Value
.
NULL
);
...
...
@@ -425,12 +425,12 @@ public class Transfer {
if
(
version
>=
Constants
.
TCP_PROTOCOL_VERSION_12
)
{
writeBytes
(
calculateLobMac
(
lob
.
getLobId
()));
}
writeLong
(
lob
.
getPrecision
());
writeLong
(
lob
.
get
Type
().
get
Precision
());
break
;
}
}
}
long
length
=
v
.
getPrecision
();
long
length
=
v
.
get
Type
().
get
Precision
();
if
(
length
<
0
)
{
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
"length="
+
length
);
...
...
@@ -456,12 +456,12 @@ public class Transfer {
if
(
version
>=
Constants
.
TCP_PROTOCOL_VERSION_12
)
{
writeBytes
(
calculateLobMac
(
lob
.
getLobId
()));
}
writeLong
(
lob
.
getPrecision
());
writeLong
(
lob
.
get
Type
().
get
Precision
());
break
;
}
}
}
long
length
=
v
.
getPrecision
();
long
length
=
v
.
get
Type
().
get
Precision
();
if
(
length
<
0
)
{
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
"length="
+
length
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/TypeInfo.java
浏览文件 @
3f2932f9
...
...
@@ -5,11 +5,112 @@
*/
package
org
.
h2
.
value
;
import
org.h2.api.ErrorCode
;
import
org.h2.message.DbException
;
import
org.h2.util.JdbcUtils
;
/**
* Data type with parameters.
*/
public
class
TypeInfo
{
/**
* NULL type with parameters.
*/
public
static
final
TypeInfo
TYPE_NULL
;
/**
* BOOLEAN type with parameters.
*/
public
static
final
TypeInfo
TYPE_BOOLEAN
;
/**
* BYTE type with parameters.
*/
public
static
final
TypeInfo
TYPE_BYTE
;
/**
* SHORT type with parameters.
*/
public
static
final
TypeInfo
TYPE_SHORT
;
/**
* INT type with parameters.
*/
public
static
final
TypeInfo
TYPE_INT
;
/**
* LONG type with parameters.
*/
public
static
final
TypeInfo
TYPE_LONG
;
/**
* DOUBLE type with parameters.
*/
public
static
final
TypeInfo
TYPE_DOUBLE
;
/**
* FLOAT type with parameters.
*/
public
static
final
TypeInfo
TYPE_FLOAT
;
/**
* TIME type with parameters.
*/
public
static
final
TypeInfo
TYPE_TIME
;
/**
* DATE type with parameters.
*/
public
static
final
TypeInfo
TYPE_DATE
;
/**
* TIMESTAMP type with parameters.
*/
public
static
final
TypeInfo
TYPE_TIMESTAMP
;
/**
* ARRAY type with parameters.
*/
public
static
final
TypeInfo
TYPE_ARRAY
;
/**
* RESULT_SET type with parameters.
*/
public
static
final
TypeInfo
TYPE_RESULT_SET
;
/**
* JAVA_OBJECT type with parameters.
*/
public
static
final
TypeInfo
TYPE_JAVA_OBJECT
;
/**
* UUID type with parameters.
*/
public
static
final
TypeInfo
TYPE_UUID
;
/**
* GEOMETRY type with default parameters.
*/
public
static
final
TypeInfo
TYPE_GEOMETRY
;
/**
* TIMESTAMP WITH TIME ZONE type with parameters.
*/
public
static
final
TypeInfo
TYPE_TIMESTAMP_TZ
;
/**
* ENUM type with undefined parameters.
*/
public
static
final
TypeInfo
TYPE_ENUM_UNDEFINED
;
/**
* ROW (row value) type with parameters.
*/
public
static
final
TypeInfo
TYPE_ROW
;
private
static
final
TypeInfo
[]
TYPE_INFOS_BY_VALUE_TYPE
;
private
final
int
valueType
;
private
final
long
precision
;
...
...
@@ -20,6 +121,68 @@ public class TypeInfo {
private
final
ExtTypeInfo
extTypeInfo
;
static
{
DataType
[]
type
=
DataType
.
TYPES_BY_VALUE_TYPE
;
TypeInfo
[]
infos
=
new
TypeInfo
[
Value
.
TYPE_COUNT
];
for
(
int
i
=
0
;
i
<
type
.
length
;
i
++)
{
DataType
dt
=
type
[
i
];
if
(
dt
!=
null
)
{
Value
.
getOrder
(
i
);
infos
[
i
]
=
createTypeInfo
(
i
,
dt
);
}
}
TYPE_NULL
=
infos
[
Value
.
NULL
];
TYPE_BOOLEAN
=
infos
[
Value
.
BOOLEAN
];
TYPE_BYTE
=
infos
[
Value
.
BYTE
];
TYPE_SHORT
=
infos
[
Value
.
SHORT
];
TYPE_INT
=
infos
[
Value
.
INT
];
TYPE_LONG
=
infos
[
Value
.
LONG
];
TYPE_DOUBLE
=
infos
[
Value
.
DOUBLE
];
TYPE_FLOAT
=
infos
[
Value
.
FLOAT
];
TYPE_TIME
=
infos
[
Value
.
TIME
];
TYPE_DATE
=
infos
[
Value
.
DATE
];
TYPE_TIMESTAMP
=
infos
[
Value
.
TIMESTAMP
];
TYPE_ARRAY
=
infos
[
Value
.
ARRAY
];
TYPE_RESULT_SET
=
infos
[
Value
.
RESULT_SET
];
TYPE_JAVA_OBJECT
=
infos
[
Value
.
JAVA_OBJECT
];
TYPE_UUID
=
infos
[
Value
.
UUID
];
TYPE_GEOMETRY
=
infos
[
Value
.
GEOMETRY
];
TYPE_TIMESTAMP_TZ
=
infos
[
Value
.
TIMESTAMP_TZ
];
TYPE_ENUM_UNDEFINED
=
infos
[
Value
.
ENUM
];
TYPE_ROW
=
infos
[
Value
.
ROW
];
TYPE_INFOS_BY_VALUE_TYPE
=
infos
;
}
/**
* Get the data type with parameters object for the given value type and
* maximum parameters.
*
* @param type the value type
* @return the data type with parameters object
*/
public
static
TypeInfo
getTypeInfo
(
int
type
)
{
if
(
type
==
Value
.
UNKNOWN
)
{
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"?"
);
}
if
(
type
>=
Value
.
NULL
&&
type
<
Value
.
TYPE_COUNT
)
{
TypeInfo
t
=
TypeInfo
.
TYPE_INFOS_BY_VALUE_TYPE
[
type
];
if
(
t
!=
null
)
{
return
t
;
}
}
if
(
JdbcUtils
.
customDataTypesHandler
!=
null
)
{
DataType
dt
=
JdbcUtils
.
customDataTypesHandler
.
getDataTypeById
(
type
);
if
(
dt
!=
null
)
{
return
createTypeInfo
(
type
,
dt
);
}
}
return
TypeInfo
.
TYPE_INFOS_BY_VALUE_TYPE
[
Value
.
NULL
];
}
private
static
TypeInfo
createTypeInfo
(
int
valueType
,
DataType
dataType
)
{
return
new
TypeInfo
(
valueType
,
dataType
.
maxPrecision
,
dataType
.
maxScale
,
dataType
.
defaultDisplaySize
,
null
);
}
/**
* Creates new instance of data type with parameters.
*
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Value.java
浏览文件 @
3f2932f9
差异被折叠。
点击展开。
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
3f2932f9
...
...
@@ -62,8 +62,13 @@ public class ValueArray extends ValueCollectionBase {
}
@Override
public
int
getType
()
{
return
Value
.
ARRAY
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_ARRAY
;
}
@Override
public
int
getValueType
()
{
return
ARRAY
;
}
public
Class
<?>
getComponentType
()
{
...
...
@@ -109,7 +114,7 @@ public class ValueArray extends ValueCollectionBase {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
final
Value
value
=
values
[
i
];
if
(!
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
)
{
final
int
type
=
value
.
getType
();
final
int
type
=
value
.
get
Value
Type
();
if
(
type
==
Value
.
BYTE
||
type
==
Value
.
SHORT
)
{
list
[
i
]
=
value
.
getInt
();
continue
;
...
...
@@ -189,7 +194,7 @@ public class ValueArray extends ValueCollectionBase {
}
// empty byte arrays or strings have precision 0
// they count as precision 1 here
precision
-=
Math
.
max
(
1
,
v
.
getPrecision
());
precision
-=
Math
.
max
(
1
,
v
.
get
Type
().
get
Precision
());
if
(
precision
<
0
)
{
break
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueBoolean.java
浏览文件 @
3f2932f9
...
...
@@ -41,8 +41,13 @@ public class ValueBoolean extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
BOOLEAN
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_BOOLEAN
;
}
@Override
public
int
getValueType
()
{
return
BOOLEAN
;
}
@Override
...
...
@@ -70,11 +75,6 @@ public class ValueBoolean extends Value {
return
Boolean
.
compare
(
value
,
((
ValueBoolean
)
o
).
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
hashCode
()
{
return
value
?
1
:
0
;
...
...
@@ -101,11 +101,6 @@ public class ValueBoolean extends Value {
return
b
?
TRUE
:
FALSE
;
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
// there are only ever two instances, so the instance must match
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueByte.java
浏览文件 @
3f2932f9
...
...
@@ -93,8 +93,13 @@ public class ValueByte extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
BYTE
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_BYTE
;
}
@Override
public
int
getValueType
()
{
return
BYTE
;
}
@Override
...
...
@@ -117,11 +122,6 @@ public class ValueByte extends Value {
return
Integer
.
toString
(
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
hashCode
()
{
return
value
;
...
...
@@ -148,11 +148,6 @@ public class ValueByte extends Value {
return
(
ValueByte
)
Value
.
cache
(
new
ValueByte
(
i
));
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueByte
&&
value
==
((
ValueByte
)
other
).
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
3f2932f9
...
...
@@ -31,6 +31,8 @@ public class ValueBytes extends Value {
*/
protected
byte
[]
value
;
private
TypeInfo
type
;
/**
* The hash code.
*/
...
...
@@ -74,8 +76,18 @@ public class ValueBytes extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
BYTES
;
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
long
precision
=
value
.
length
;
this
.
type
=
type
=
new
TypeInfo
(
BYTES
,
precision
,
0
,
MathUtils
.
convertLongToInt
(
precision
*
2
),
null
);
}
return
type
;
}
@Override
public
int
getValueType
()
{
return
BYTES
;
}
@Override
...
...
@@ -108,11 +120,6 @@ public class ValueBytes extends Value {
return
StringUtils
.
convertBytesToHex
(
value
);
}
@Override
public
long
getPrecision
()
{
return
value
.
length
;
}
@Override
public
int
hashCode
()
{
if
(
hash
==
0
)
{
...
...
@@ -132,11 +139,6 @@ public class ValueBytes extends Value {
prep
.
setBytes
(
parameterIndex
,
value
);
}
@Override
public
int
getDisplaySize
()
{
return
MathUtils
.
convertLongToInt
(
value
.
length
*
2L
);
}
@Override
public
int
getMemory
()
{
return
value
.
length
+
24
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueCollectionBase.java
浏览文件 @
3f2932f9
...
...
@@ -21,6 +21,8 @@ public abstract class ValueCollectionBase extends Value {
*/
final
Value
[]
values
;
private
TypeInfo
type
;
private
int
hash
;
ValueCollectionBase
(
Value
[]
values
)
{
...
...
@@ -36,7 +38,7 @@ public abstract class ValueCollectionBase extends Value {
if
(
hash
!=
0
)
{
return
hash
;
}
int
h
=
getType
();
int
h
=
get
Value
Type
();
for
(
Value
v
:
values
)
{
h
=
h
*
31
+
v
.
hashCode
();
}
...
...
@@ -45,21 +47,19 @@ public abstract class ValueCollectionBase extends Value {
}
@Override
public
long
getPrecision
()
{
long
p
=
0
;
for
(
Value
v
:
values
)
{
p
+=
v
.
getPrecision
();
}
return
p
;
}
@Override
public
int
getDisplaySize
()
{
long
size
=
0
;
for
(
Value
v
:
values
)
{
size
+=
v
.
getDisplaySize
();
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
long
precision
=
0
,
displaySize
=
0
;
for
(
Value
v
:
values
)
{
TypeInfo
t
=
v
.
getType
();
precision
+=
t
.
getPrecision
();
displaySize
+=
t
.
getDisplaySize
();
}
this
.
type
=
type
=
new
TypeInfo
(
getValueType
(),
precision
,
0
,
MathUtils
.
convertLongToInt
(
displaySize
),
null
);
}
return
MathUtils
.
convertLongToInt
(
size
)
;
return
type
;
}
@Override
...
...
@@ -68,8 +68,8 @@ public abstract class ValueCollectionBase extends Value {
return
Integer
.
MIN_VALUE
;
}
ValueCollectionBase
l
=
this
;
int
leftType
=
l
.
getType
();
int
rightType
=
v
.
getType
();
int
leftType
=
l
.
get
Value
Type
();
int
rightType
=
v
.
get
Value
Type
();
if
(
rightType
!=
ARRAY
&&
rightType
!=
ROW
)
{
throw
v
.
getDataConversionError
(
leftType
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDate.java
浏览文件 @
3f2932f9
...
...
@@ -87,8 +87,13 @@ public class ValueDate extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
DATE
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_DATE
;
}
@Override
public
int
getValueType
()
{
return
DATE
;
}
@Override
...
...
@@ -105,16 +110,6 @@ public class ValueDate extends Value {
return
builder
.
append
(
'\''
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
getDisplaySize
()
{
return
PRECISION
;
}
@Override
public
int
compareTypeSafe
(
Value
o
,
CompareMode
mode
)
{
return
Long
.
compare
(
dateValue
,
((
ValueDate
)
o
).
dateValue
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDecimal.java
浏览文件 @
3f2932f9
...
...
@@ -52,8 +52,8 @@ public class ValueDecimal extends Value {
private
static
final
int
BIG_DECIMAL_SCALE_MAX
=
100_000
;
private
final
BigDecimal
value
;
private
TypeInfo
type
;
private
String
valueString
;
private
int
precision
;
private
ValueDecimal
(
BigDecimal
value
)
{
if
(
value
==
null
)
{
...
...
@@ -123,8 +123,20 @@ public class ValueDecimal extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
DECIMAL
;
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
long
precision
=
value
.
precision
();
this
.
type
=
type
=
new
TypeInfo
(
DECIMAL
,
precision
,
value
.
scale
(),
// add 2 characters for '-' and '.'
MathUtils
.
convertLongToInt
(
precision
+
2
),
null
);
}
return
type
;
}
@Override
public
int
getValueType
()
{
return
DECIMAL
;
}
@Override
...
...
@@ -155,25 +167,12 @@ public class ValueDecimal extends Value {
return
valueString
;
}
@Override
public
long
getPrecision
()
{
if
(
precision
==
0
)
{
precision
=
value
.
precision
();
}
return
precision
;
}
@Override
public
boolean
checkPrecision
(
long
prec
)
{
if
(
prec
==
DEFAULT_PRECISION
)
{
return
true
;
}
return
getPrecision
()
<=
prec
;
}
@Override
public
int
getScale
()
{
return
value
.
scale
();
return
value
.
precision
()
<=
prec
;
}
@Override
...
...
@@ -208,7 +207,7 @@ public class ValueDecimal extends Value {
@Override
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
if
(
getP
recision
()
<=
precision
)
{
if
(
value
.
p
recision
()
<=
precision
)
{
return
this
;
}
if
(
force
)
{
...
...
@@ -234,12 +233,6 @@ public class ValueDecimal extends Value {
return
(
ValueDecimal
)
Value
.
cache
(
new
ValueDecimal
(
dec
));
}
@Override
public
int
getDisplaySize
()
{
// add 2 characters for '-' and '.'
return
MathUtils
.
convertLongToInt
(
getPrecision
()
+
2
);
}
@Override
public
boolean
equals
(
Object
other
)
{
// Two BigDecimal objects are considered equal only if they are equal in
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDouble.java
浏览文件 @
3f2932f9
...
...
@@ -106,8 +106,13 @@ public class ValueDouble extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
DOUBLE
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_DOUBLE
;
}
@Override
public
int
getValueType
()
{
return
DOUBLE
;
}
@Override
...
...
@@ -130,16 +135,6 @@ public class ValueDouble extends Value {
return
Double
.
toString
(
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
int
hashCode
()
{
/*
...
...
@@ -179,11 +174,6 @@ public class ValueDouble extends Value {
return
(
ValueDouble
)
Value
.
cache
(
new
ValueDouble
(
d
));
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
ValueDouble
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueEnum.java
浏览文件 @
3f2932f9
...
...
@@ -17,6 +17,11 @@ public class ValueEnum extends ValueEnumBase {
this
.
enumerators
=
enumerators
;
}
@Override
public
TypeInfo
getType
()
{
return
new
TypeInfo
(
ENUM
,
PRECISION
,
0
,
DISPLAY_SIZE
,
enumerators
);
}
public
ExtTypeInfoEnum
getEnumerators
()
{
return
enumerators
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
3f2932f9
...
...
@@ -18,8 +18,8 @@ import org.h2.util.StringUtils;
* client-server communication.
*/
public
class
ValueEnumBase
extends
Value
{
private
static
final
int
PRECISION
=
10
;
private
static
final
int
DISPLAY_SIZE
=
11
;
static
final
int
PRECISION
=
10
;
static
final
int
DISPLAY_SIZE
=
11
;
private
final
String
label
;
private
final
int
ordinal
;
...
...
@@ -63,11 +63,6 @@ public class ValueEnumBase extends Value {
return
new
ValueEnumBase
(
label
,
ordinal
);
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
int
getInt
()
{
return
ordinal
;
...
...
@@ -83,11 +78,6 @@ public class ValueEnumBase extends Value {
return
label
;
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
getSignum
()
{
return
Integer
.
signum
(
ordinal
);
...
...
@@ -104,8 +94,13 @@ public class ValueEnumBase extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
ENUM
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_ENUM_UNDEFINED
;
}
@Override
public
int
getValueType
()
{
return
ENUM
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueFloat.java
浏览文件 @
3f2932f9
...
...
@@ -106,8 +106,13 @@ public class ValueFloat extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
FLOAT
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_FLOAT
;
}
@Override
public
int
getValueType
()
{
return
FLOAT
;
}
@Override
...
...
@@ -130,16 +135,6 @@ public class ValueFloat extends Value {
return
Float
.
toString
(
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
int
hashCode
()
{
/*
...
...
@@ -178,11 +173,6 @@ public class ValueFloat extends Value {
return
(
ValueFloat
)
Value
.
cache
(
new
ValueFloat
(
d
));
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
ValueFloat
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
3f2932f9
...
...
@@ -263,8 +263,13 @@ public class ValueGeometry extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
GEOMETRY
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_GEOMETRY
;
}
@Override
public
int
getValueType
()
{
return
GEOMETRY
;
}
@Override
...
...
@@ -284,11 +289,6 @@ public class ValueGeometry extends Value {
return
getEWKT
();
}
@Override
public
long
getPrecision
()
{
return
0
;
}
@Override
public
int
hashCode
()
{
return
hashCode
;
...
...
@@ -317,11 +317,6 @@ public class ValueGeometry extends Value {
prep
.
setBytes
(
parameterIndex
,
bytes
);
}
@Override
public
int
getDisplaySize
()
{
return
getEWKT
().
length
();
}
@Override
public
int
getMemory
()
{
return
bytes
.
length
*
20
+
24
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueInt.java
浏览文件 @
3f2932f9
...
...
@@ -126,8 +126,13 @@ public class ValueInt extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
INT
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_INT
;
}
@Override
public
int
getValueType
()
{
return
INT
;
}
@Override
...
...
@@ -150,11 +155,6 @@ public class ValueInt extends Value {
return
Integer
.
toString
(
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
hashCode
()
{
return
value
;
...
...
@@ -171,11 +171,6 @@ public class ValueInt extends Value {
prep
.
setInt
(
parameterIndex
,
value
);
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueInt
&&
value
==
((
ValueInt
)
other
).
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueInterval.java
浏览文件 @
3f2932f9
...
...
@@ -44,7 +44,9 @@ public class ValueInterval extends Value {
*/
public
static
final
int
MAXIMUM_SCALE
=
9
;
private
final
int
type
;
private
final
int
valueType
;
private
TypeInfo
type
;
private
final
boolean
negative
;
...
...
@@ -134,7 +136,7 @@ public class ValueInterval extends Value {
}
private
ValueInterval
(
int
type
,
boolean
negative
,
long
leading
,
long
remaining
)
{
this
.
t
ype
=
type
;
this
.
valueT
ype
=
type
;
this
.
negative
=
negative
;
this
.
leading
=
leading
;
this
.
remaining
=
remaining
;
...
...
@@ -146,19 +148,27 @@ public class ValueInterval extends Value {
}
@Override
public
int
getType
()
{
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
long
l
=
leading
;
int
precision
=
0
;
while
(
l
>
0
)
{
precision
++;
l
/=
10
;
}
if
(
precision
==
0
)
{
precision
=
1
;
}
this
.
type
=
type
=
new
TypeInfo
(
valueType
,
precision
,
0
,
getDisplaySize
(
valueType
,
MAXIMUM_PRECISION
,
MAXIMUM_SCALE
),
null
);
}
return
type
;
}
@Override
public
long
getPrecision
()
{
long
l
=
leading
;
int
precision
=
0
;
while
(
l
>
0
)
{
precision
++;
l
/=
10
;
}
return
precision
>
0
?
precision
:
1
;
public
int
getValueType
()
{
return
valueType
;
}
@Override
...
...
@@ -178,7 +188,7 @@ public class ValueInterval extends Value {
return
this
;
}
long
l
=
leading
;
switch
(
t
ype
)
{
switch
(
valueT
ype
)
{
case
INTERVAL_SECOND:
if
(
r
>=
NANOS_PER_SECOND
)
{
l
++;
...
...
@@ -207,11 +217,6 @@ public class ValueInterval extends Value {
return
from
(
qualifier
,
negative
,
l
,
r
);
}
@Override
public
int
getDisplaySize
()
{
return
getDisplaySize
(
type
,
MAXIMUM_PRECISION
,
MAXIMUM_SCALE
);
}
@Override
public
String
getString
()
{
return
IntervalUtils
.
appendInterval
(
new
StringBuilder
(),
getQualifier
(),
negative
,
leading
,
remaining
)
...
...
@@ -229,7 +234,7 @@ public class ValueInterval extends Value {
* @return the interval qualifier
*/
public
IntervalQualifier
getQualifier
()
{
return
IntervalQualifier
.
valueOf
(
t
ype
-
INTERVAL_YEAR
);
return
IntervalQualifier
.
valueOf
(
valueT
ype
-
INTERVAL_YEAR
);
}
/**
...
...
@@ -270,7 +275,7 @@ public class ValueInterval extends Value {
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
t
ype
;
result
=
prime
*
result
+
valueT
ype
;
result
=
prime
*
result
+
(
negative
?
1231
:
1237
);
result
=
prime
*
result
+
(
int
)
(
leading
^
leading
>>>
32
);
result
=
prime
*
result
+
(
int
)
(
remaining
^
remaining
>>>
32
);
...
...
@@ -286,7 +291,7 @@ public class ValueInterval extends Value {
return
false
;
}
ValueInterval
other
=
(
ValueInterval
)
obj
;
return
type
==
other
.
t
ype
&&
negative
==
other
.
negative
&&
leading
==
other
.
leading
return
valueType
==
other
.
valueT
ype
&&
negative
==
other
.
negative
&&
leading
==
other
.
leading
&&
remaining
==
other
.
remaining
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueJavaObject.java
浏览文件 @
3f2932f9
...
...
@@ -59,8 +59,13 @@ public class ValueJavaObject extends ValueBytes {
}
@Override
public
int
getType
()
{
return
Value
.
JAVA_OBJECT
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_JAVA_OBJECT
;
}
@Override
public
int
getValueType
()
{
return
JAVA_OBJECT
;
}
@Override
...
...
@@ -80,7 +85,7 @@ public class ValueJavaObject extends ValueBytes {
private
Object
javaObject
;
private
int
displaySize
=
-
1
;
private
TypeInfo
type
;
NotSerialized
(
Object
javaObject
,
byte
[]
v
,
DataHandler
dataHandler
)
{
super
(
v
,
dataHandler
);
...
...
@@ -139,17 +144,26 @@ public class ValueJavaObject extends ValueBytes {
}
@Override
public
String
getString
()
{
String
str
=
getObject
().
toString
();
if
(
displaySize
==
-
1
)
{
displaySize
=
str
.
length
();
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
String
string
=
getString
();
this
.
type
=
type
=
createType
(
string
);
}
return
str
;
return
type
;
}
private
static
TypeInfo
createType
(
String
string
)
{
return
new
TypeInfo
(
JAVA_OBJECT
,
0
,
0
,
string
.
length
(),
null
);
}
@Override
public
long
getPrecision
()
{
return
0
;
public
String
getString
()
{
String
str
=
getObject
().
toString
();
if
(
type
==
null
)
{
type
=
createType
(
str
);
}
return
str
;
}
@Override
...
...
@@ -168,18 +182,10 @@ public class ValueJavaObject extends ValueBytes {
return
javaObject
;
}
@Override
public
int
getDisplaySize
()
{
if
(
displaySize
==
-
1
)
{
displaySize
=
getString
().
length
();
}
return
displaySize
;
}
@Override
public
int
getMemory
()
{
if
(
value
==
null
)
{
return
DataType
.
getDataType
(
getType
()).
memory
;
return
DataType
.
getDataType
(
get
Value
Type
()).
memory
;
}
int
mem
=
super
.
getMemory
();
if
(
javaObject
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
3f2932f9
...
...
@@ -98,8 +98,8 @@ public class ValueLob extends Value {
* @return result of comparison
*/
static
int
compare
(
Value
v1
,
Value
v2
)
{
int
valueType
=
v1
.
getType
();
assert
valueType
==
v2
.
getType
();
int
valueType
=
v1
.
get
Value
Type
();
assert
valueType
==
v2
.
get
Value
Type
();
if
(
v1
instanceof
ValueLobDb
&&
v2
instanceof
ValueLobDb
)
{
byte
[]
small1
=
v1
.
getSmall
(),
small2
=
v2
.
getSmall
();
if
(
small1
!=
null
&&
small2
!=
null
)
{
...
...
@@ -110,7 +110,7 @@ public class ValueLob extends Value {
}
}
}
long
minPrec
=
Math
.
min
(
v1
.
get
Precision
(),
v2
.
getPrecision
());
long
minPrec
=
Math
.
min
(
v1
.
get
Type
().
getPrecision
(),
v2
.
getType
()
.
getPrecision
());
if
(
valueType
==
Value
.
BLOB
)
{
try
(
InputStream
is1
=
v1
.
getInputStream
();
InputStream
is2
=
v2
.
getInputStream
())
{
...
...
@@ -184,6 +184,7 @@ public class ValueLob extends Value {
* either Value.BLOB or Value.CLOB
*/
private
final
int
valueType
;
private
TypeInfo
type
;
private
final
long
precision
;
private
final
DataHandler
handler
;
private
int
tableId
;
...
...
@@ -448,13 +449,17 @@ public class ValueLob extends Value {
}
@Override
public
int
getType
()
{
return
valueType
;
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
this
.
type
=
type
=
new
TypeInfo
(
valueType
,
precision
,
0
,
MathUtils
.
convertLongToInt
(
precision
),
null
);
}
return
type
;
}
@Override
public
long
getPrecision
()
{
return
precision
;
public
int
getValueType
()
{
return
valueType
;
}
@Override
...
...
@@ -558,7 +563,7 @@ public class ValueLob extends Value {
@Override
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
{
long
p
=
getPrecision
()
;
long
p
=
precision
;
if
(
p
>
Integer
.
MAX_VALUE
||
p
<=
0
)
{
p
=
-
1
;
}
...
...
@@ -584,9 +589,9 @@ public class ValueLob extends Value {
public
String
getTraceSQL
()
{
StringBuilder
buff
=
new
StringBuilder
();
if
(
valueType
==
Value
.
CLOB
)
{
buff
.
append
(
"SPACE("
).
append
(
getPrecision
()
);
buff
.
append
(
"SPACE("
).
append
(
precision
);
}
else
{
buff
.
append
(
"CAST(REPEAT('00', "
).
append
(
getPrecision
()
).
append
(
") AS BINARY"
);
buff
.
append
(
"CAST(REPEAT('00', "
).
append
(
precision
).
append
(
") AS BINARY"
);
}
buff
.
append
(
" /* "
).
append
(
fileName
).
append
(
" */)"
);
return
buff
.
toString
();
...
...
@@ -602,11 +607,6 @@ public class ValueLob extends Value {
return
null
;
}
@Override
public
int
getDisplaySize
()
{
return
MathUtils
.
convertLongToInt
(
getPrecision
());
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(
other
instanceof
ValueLob
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
3f2932f9
...
...
@@ -43,6 +43,8 @@ public class ValueLobDb extends Value {
* the value type (Value.BLOB or CLOB)
*/
private
final
int
valueType
;
private
TypeInfo
type
;
/**
* If the LOB is managed by the one the LobStorageBackend classes, these are the
* unique key inside that storage.
...
...
@@ -261,14 +263,14 @@ public class ValueLobDb extends Value {
@Override
public
Value
copy
(
DataHandler
database
,
int
tableId
)
{
if
(
small
==
null
)
{
return
handler
.
getLobStorage
().
copyLob
(
this
,
tableId
,
getPrecision
()
);
return
handler
.
getLobStorage
().
copyLob
(
this
,
tableId
,
precision
);
}
else
if
(
small
.
length
>
database
.
getMaxLengthInplaceLob
())
{
LobStorageInterface
s
=
database
.
getLobStorage
();
Value
v
;
if
(
valueType
==
Value
.
BLOB
)
{
v
=
s
.
createBlob
(
getInputStream
(),
getPrecision
()
);
v
=
s
.
createBlob
(
getInputStream
(),
precision
);
}
else
{
v
=
s
.
createClob
(
getReader
(),
getPrecision
()
);
v
=
s
.
createClob
(
getReader
(),
precision
);
}
Value
v2
=
v
.
copy
(
database
,
tableId
);
v
.
remove
();
...
...
@@ -288,13 +290,17 @@ public class ValueLobDb extends Value {
}
@Override
public
int
getType
()
{
return
valueType
;
public
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
this
.
type
=
type
=
new
TypeInfo
(
valueType
,
precision
,
0
,
MathUtils
.
convertLongToInt
(
precision
),
null
);
}
return
type
;
}
@Override
public
long
getPrecision
()
{
return
precision
;
public
int
getValueType
()
{
return
valueType
;
}
@Override
...
...
@@ -449,7 +455,7 @@ public class ValueLobDb extends Value {
@Override
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
{
long
p
=
getPrecision
()
;
long
p
=
precision
;
if
(
p
>
Integer
.
MAX_VALUE
||
p
<=
0
)
{
p
=
-
1
;
}
...
...
@@ -473,14 +479,14 @@ public class ValueLobDb extends Value {
@Override
public
String
getTraceSQL
()
{
if
(
small
!=
null
&&
getPrecision
()
<=
SysProperties
.
MAX_TRACE_DATA_LENGTH
)
{
if
(
small
!=
null
&&
precision
<=
SysProperties
.
MAX_TRACE_DATA_LENGTH
)
{
return
getSQL
();
}
StringBuilder
buff
=
new
StringBuilder
();
if
(
valueType
==
Value
.
CLOB
)
{
buff
.
append
(
"SPACE("
).
append
(
getPrecision
()
);
buff
.
append
(
"SPACE("
).
append
(
precision
);
}
else
{
buff
.
append
(
"CAST(REPEAT('00', "
).
append
(
getPrecision
()
).
append
(
") AS BINARY"
);
buff
.
append
(
"CAST(REPEAT('00', "
).
append
(
precision
).
append
(
") AS BINARY"
);
}
buff
.
append
(
" /* table: "
).
append
(
tableId
).
append
(
" id: "
)
.
append
(
lobId
).
append
(
" */)"
);
...
...
@@ -497,11 +503,6 @@ public class ValueLobDb extends Value {
return
small
;
}
@Override
public
int
getDisplaySize
()
{
return
MathUtils
.
convertLongToInt
(
getPrecision
());
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
ValueLobDb
))
...
...
@@ -546,8 +547,7 @@ public class ValueLobDb extends Value {
if
(
s
.
isReadOnly
())
{
return
this
;
}
return
s
.
copyLob
(
this
,
LobStorageFrontend
.
TABLE_RESULT
,
getPrecision
());
return
s
.
copyLob
(
this
,
LobStorageFrontend
.
TABLE_RESULT
,
precision
);
}
public
long
getLobId
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLong.java
浏览文件 @
3f2932f9
...
...
@@ -151,8 +151,13 @@ public class ValueLong extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
LONG
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_LONG
;
}
@Override
public
int
getValueType
()
{
return
LONG
;
}
@Override
...
...
@@ -170,11 +175,6 @@ public class ValueLong extends Value {
return
Long
.
toString
(
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
hashCode
()
{
return
(
int
)
(
value
^
(
value
>>
32
));
...
...
@@ -204,11 +204,6 @@ public class ValueLong extends Value {
return
(
ValueLong
)
Value
.
cache
(
new
ValueLong
(
i
));
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueLong
&&
value
==
((
ValueLong
)
other
).
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueNull.java
浏览文件 @
3f2932f9
...
...
@@ -37,12 +37,12 @@ public class ValueNull extends Value {
/**
* The precision of NULL.
*/
private
static
final
int
PRECISION
=
1
;
static
final
int
PRECISION
=
1
;
/**
* The display size of the textual representation of NULL.
*/
private
static
final
int
DISPLAY_SIZE
=
4
;
static
final
int
DISPLAY_SIZE
=
4
;
private
ValueNull
()
{
// don't allow construction
...
...
@@ -54,8 +54,13 @@ public class ValueNull extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
NULL
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_NULL
;
}
@Override
public
int
getValueType
()
{
return
NULL
;
}
@Override
...
...
@@ -148,11 +153,6 @@ public class ValueNull extends Value {
return
true
;
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
hashCode
()
{
return
0
;
...
...
@@ -169,11 +169,6 @@ public class ValueNull extends Value {
prep
.
setNull
(
parameterIndex
,
Types
.
NULL
);
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
return
other
==
this
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueResultSet.java
浏览文件 @
3f2932f9
...
...
@@ -98,19 +98,13 @@ public class ValueResultSet extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
RESULT_SET
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_
RESULT_SET
;
}
@Override
public
long
getPrecision
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
public
int
getDisplaySize
()
{
// it doesn't make sense to calculate it
return
Integer
.
MAX_VALUE
;
public
int
getValueType
()
{
return
RESULT_SET
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueRow.java
浏览文件 @
3f2932f9
...
...
@@ -48,8 +48,13 @@ public class ValueRow extends ValueCollectionBase {
}
@Override
public
int
getType
()
{
return
Value
.
ROW
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_ROW
;
}
@Override
public
int
getValueType
()
{
return
ROW
;
}
@Override
...
...
@@ -92,7 +97,7 @@ public class ValueRow extends ValueCollectionBase {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
final
Value
value
=
values
[
i
];
if
(!
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
)
{
final
int
type
=
value
.
getType
();
final
int
type
=
value
.
get
Value
Type
();
if
(
type
==
Value
.
BYTE
||
type
==
Value
.
SHORT
)
{
list
[
i
]
=
value
.
getInt
();
continue
;
...
...
@@ -172,7 +177,7 @@ public class ValueRow extends ValueCollectionBase {
}
// empty byte arrays or strings have precision 0
// they count as precision 1 here
precision
-=
Math
.
max
(
1
,
v
.
getPrecision
());
precision
-=
Math
.
max
(
1
,
v
.
get
Type
().
get
Precision
());
if
(
precision
<
0
)
{
break
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueShort.java
浏览文件 @
3f2932f9
...
...
@@ -93,8 +93,13 @@ public class ValueShort extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
SHORT
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_SHORT
;
}
@Override
public
int
getValueType
()
{
return
SHORT
;
}
@Override
...
...
@@ -117,11 +122,6 @@ public class ValueShort extends Value {
return
Integer
.
toString
(
value
);
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
}
@Override
public
int
hashCode
()
{
return
value
;
...
...
@@ -148,11 +148,6 @@ public class ValueShort extends Value {
return
(
ValueShort
)
Value
.
cache
(
new
ValueShort
(
i
));
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
@Override
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueShort
&&
value
==
((
ValueShort
)
other
).
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueString.java
浏览文件 @
3f2932f9
...
...
@@ -29,6 +29,8 @@ public class ValueString extends Value {
*/
protected
final
String
value
;
private
TypeInfo
type
;
protected
ValueString
(
String
value
)
{
this
.
value
=
value
;
}
...
...
@@ -54,11 +56,6 @@ public class ValueString extends Value {
return
value
;
}
@Override
public
long
getPrecision
()
{
return
value
.
length
();
}
@Override
public
Object
getObject
()
{
return
value
;
...
...
@@ -70,11 +67,6 @@ public class ValueString extends Value {
prep
.
setString
(
parameterIndex
,
value
);
}
@Override
public
int
getDisplaySize
()
{
return
value
.
length
();
}
@Override
public
int
getMemory
()
{
return
value
.
length
()
*
2
+
48
;
...
...
@@ -122,8 +114,18 @@ public class ValueString extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
STRING
;
public
final
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
int
length
=
value
.
length
();
this
.
type
=
type
=
new
TypeInfo
(
getValueType
(),
length
,
0
,
length
,
null
);
}
return
type
;
}
@Override
public
int
getValueType
()
{
return
STRING
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueStringFixed.java
浏览文件 @
3f2932f9
...
...
@@ -58,8 +58,8 @@ public class ValueStringFixed extends ValueString {
}
@Override
public
int
getType
()
{
return
Value
.
STRING_FIXED
;
public
int
get
Value
Type
()
{
return
STRING_FIXED
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueStringIgnoreCase.java
浏览文件 @
3f2932f9
...
...
@@ -22,8 +22,8 @@ public class ValueStringIgnoreCase extends ValueString {
}
@Override
public
int
getType
()
{
return
Value
.
STRING_IGNORECASE
;
public
int
get
Value
Type
()
{
return
STRING_IGNORECASE
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
3f2932f9
...
...
@@ -127,8 +127,13 @@ public class ValueTime extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
TIME
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_TIME
;
}
@Override
public
int
getValueType
()
{
return
TIME
;
}
@Override
...
...
@@ -145,16 +150,6 @@ public class ValueTime extends Value {
return
builder
.
append
(
'\''
);
}
@Override
public
long
getPrecision
()
{
return
MAXIMUM_PRECISION
;
}
@Override
public
int
getDisplaySize
()
{
return
MAXIMUM_PRECISION
;
}
@Override
public
boolean
checkPrecision
(
long
precision
)
{
// TIME data type does not have precision parameter
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
3f2932f9
...
...
@@ -177,8 +177,13 @@ public class ValueTimestamp extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
TIMESTAMP
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_TIMESTAMP
;
}
@Override
public
int
getValueType
()
{
return
TIMESTAMP
;
}
@Override
...
...
@@ -199,21 +204,6 @@ public class ValueTimestamp extends Value {
return
builder
.
append
(
'\''
);
}
@Override
public
long
getPrecision
()
{
return
MAXIMUM_PRECISION
;
}
@Override
public
int
getScale
()
{
return
MAXIMUM_SCALE
;
}
@Override
public
int
getDisplaySize
()
{
return
MAXIMUM_PRECISION
;
}
@Override
public
boolean
checkPrecision
(
long
precision
)
{
// TIMESTAMP data type does not have precision parameter
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
浏览文件 @
3f2932f9
...
...
@@ -169,8 +169,13 @@ public class ValueTimestampTimeZone extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
TIMESTAMP_TZ
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_TIMESTAMP_TZ
;
}
@Override
public
int
getValueType
()
{
return
TIMESTAMP_TZ
;
}
@Override
...
...
@@ -187,21 +192,6 @@ public class ValueTimestampTimeZone extends Value {
return
builder
.
append
(
'\''
);
}
@Override
public
long
getPrecision
()
{
return
MAXIMUM_PRECISION
;
}
@Override
public
int
getScale
()
{
return
MAXIMUM_SCALE
;
}
@Override
public
int
getDisplaySize
()
{
return
MAXIMUM_PRECISION
;
}
@Override
public
boolean
checkPrecision
(
long
precision
)
{
// TIMESTAMP WITH TIME ZONE data type does not have precision parameter
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
3f2932f9
...
...
@@ -23,13 +23,13 @@ public class ValueUuid extends Value {
/**
* The precision of this value in number of bytes.
*/
private
static
final
int
PRECISION
=
16
;
static
final
int
PRECISION
=
16
;
/**
* The display size of the textual representation of a UUID.
* Example: cd38d882-7ada-4589-b5fb-7da0ca559d9a
*/
private
static
final
int
DISPLAY_SIZE
=
36
;
static
final
int
DISPLAY_SIZE
=
36
;
private
final
long
high
,
low
;
...
...
@@ -132,13 +132,13 @@ public class ValueUuid extends Value {
}
@Override
public
int
getType
()
{
return
Value
.
UUID
;
public
TypeInfo
getType
()
{
return
TypeInfo
.
TYPE_
UUID
;
}
@Override
public
long
getPrecision
()
{
return
PRECISION
;
public
int
getValueType
()
{
return
UUID
;
}
@Override
...
...
@@ -220,9 +220,4 @@ public class ValueUuid extends Value {
return
low
;
}
@Override
public
int
getDisplaySize
()
{
return
DISPLAY_SIZE
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
3f2932f9
...
...
@@ -26,6 +26,7 @@ import org.h2.util.StringUtils;
import
org.h2.value.CompareMode
;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueBytes
;
import
org.h2.value.ValueDouble
;
...
...
@@ -221,11 +222,11 @@ public class TestCustomDataTypesHandler extends TestDb {
@Override
public
Value
convert
(
Value
source
,
int
targetType
)
{
if
(
source
.
getType
()
==
targetType
)
{
if
(
source
.
get
Value
Type
()
==
targetType
)
{
return
source
;
}
if
(
targetType
==
COMPLEX_DATA_TYPE_ID
)
{
switch
(
source
.
getType
())
{
switch
(
source
.
get
Value
Type
())
{
case
Value
.
JAVA_OBJECT
:
{
assert
source
instanceof
ValueJavaObject
;
return
ValueComplex
.
get
((
ComplexNumber
)
...
...
@@ -275,13 +276,13 @@ public class TestCustomDataTypesHandler extends TestDb {
@Override
public
Object
getObject
(
Value
value
,
Class
<?>
cls
)
{
if
(
cls
.
equals
(
ComplexNumber
.
class
))
{
if
(
value
.
getType
()
==
COMPLEX_DATA_TYPE_ID
)
{
if
(
value
.
get
Value
Type
()
==
COMPLEX_DATA_TYPE_ID
)
{
return
value
.
getObject
();
}
return
convert
(
value
,
COMPLEX_DATA_TYPE_ID
).
getObject
();
}
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"type:"
+
value
.
getType
());
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"type:"
+
value
.
get
Value
Type
());
}
@Override
...
...
@@ -342,18 +343,13 @@ public class TestCustomDataTypesHandler extends TestDb {
}
@Override
public
int
getType
()
{
return
T
estOnlyCustomDataTypesHandler
.
COMPLEX_DATA_TYPE_ID
;
public
TypeInfo
getType
()
{
return
T
ypeInfo
.
getTypeInfo
(
TestOnlyCustomDataTypesHandler
.
COMPLEX_DATA_TYPE_ID
)
;
}
@Override
public
long
getPrecision
()
{
return
0
;
}
@Override
public
int
getDisplaySize
()
{
return
0
;
public
int
getValueType
()
{
return
TestOnlyCustomDataTypesHandler
.
COMPLEX_DATA_TYPE_ID
;
}
@Override
...
...
@@ -396,7 +392,7 @@ public class TestCustomDataTypesHandler extends TestDb {
@Override
public
Value
convertTo
(
int
targetType
,
int
precision
,
Mode
mode
,
Object
column
,
ExtTypeInfo
extTypeInfo
)
{
if
(
getType
()
==
targetType
)
{
if
(
get
Value
Type
()
==
targetType
)
{
return
this
;
}
switch
(
targetType
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestDataPage.java
浏览文件 @
3f2932f9
...
...
@@ -218,7 +218,7 @@ public class TestDataPage extends TestBase implements DataHandler {
private
void
testValue
(
Value
v
)
{
testValue
(
v
,
false
);
switch
(
v
.
getType
())
{
switch
(
v
.
get
Value
Type
())
{
case
Value
.
DATE
:
case
Value
.
TIME
:
case
Value
.
TIMESTAMP
:
...
...
@@ -228,12 +228,12 @@ public class TestDataPage extends TestBase implements DataHandler {
private
void
testValue
(
Value
v
,
boolean
storeLocalTime
)
{
Data
data
=
Data
.
create
(
null
,
1024
,
storeLocalTime
);
data
.
checkCapacity
((
int
)
v
.
getPrecision
());
data
.
checkCapacity
((
int
)
v
.
get
Type
().
get
Precision
());
data
.
writeValue
(
v
);
data
.
writeInt
(
123
);
data
.
reset
();
Value
v2
=
data
.
readValue
();
assertEquals
(
v
.
get
Type
(),
v2
.
get
Type
());
assertEquals
(
v
.
get
ValueType
(),
v2
.
getValue
Type
());
assertEquals
(
0
,
v
.
compareTo
(
v2
,
null
,
compareMode
));
assertEquals
(
123
,
data
.
readInt
());
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
3f2932f9
...
...
@@ -19,6 +19,7 @@ import org.h2.message.DbException;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.AssertThrows
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueDate
;
import
org.h2.value.ValueDouble
;
...
...
@@ -71,11 +72,12 @@ public class TestDate extends TestBase {
assertEquals
(
"2001-01-01"
,
d1
.
getDate
().
toString
());
assertEquals
(
"DATE '2001-01-01'"
,
d1
.
getSQL
());
assertEquals
(
"DATE '2001-01-01'"
,
d1
.
toString
());
assertEquals
(
Value
.
DATE
,
d1
.
getType
());
assertEquals
(
Value
.
DATE
,
d1
.
get
Value
Type
());
long
dv
=
d1
.
getDateValue
();
assertEquals
((
int
)
((
dv
>>>
32
)
^
dv
),
d1
.
hashCode
());
assertEquals
(
d1
.
getString
().
length
(),
d1
.
getDisplaySize
());
assertEquals
(
ValueDate
.
PRECISION
,
d1
.
getPrecision
());
TypeInfo
type
=
d1
.
getType
();
assertEquals
(
d1
.
getString
().
length
(),
type
.
getDisplaySize
());
assertEquals
(
ValueDate
.
PRECISION
,
type
.
getPrecision
());
assertEquals
(
"java.sql.Date"
,
d1
.
getObject
().
getClass
().
getName
());
ValueDate
d1b
=
ValueDate
.
parse
(
"2001-01-01"
);
assertTrue
(
d1
==
d1b
);
...
...
@@ -136,12 +138,13 @@ public class TestDate extends TestBase {
assertEquals
(
"TIME '11:11:11'"
,
t1
.
toString
());
assertEquals
(
"05:35:35.5"
,
t1
.
multiply
(
ValueDouble
.
get
(
0.5
)).
getString
());
assertEquals
(
"22:22:22"
,
t1
.
divide
(
ValueDouble
.
get
(
0.5
)).
getString
());
assertEquals
(
Value
.
TIME
,
t1
.
getType
());
assertEquals
(
Value
.
TIME
,
t1
.
get
Value
Type
());
long
nanos
=
t1
.
getNanos
();
assertEquals
((
int
)
((
nanos
>>>
32
)
^
nanos
),
t1
.
hashCode
());
// Literals return maximum precision
assertEquals
(
ValueTime
.
MAXIMUM_PRECISION
,
t1
.
getDisplaySize
());
assertEquals
(
ValueTime
.
MAXIMUM_PRECISION
,
t1
.
getPrecision
());
TypeInfo
type
=
t1
.
getType
();
assertEquals
(
ValueTime
.
MAXIMUM_PRECISION
,
type
.
getDisplaySize
());
assertEquals
(
ValueTime
.
MAXIMUM_PRECISION
,
type
.
getPrecision
());
assertEquals
(
"java.sql.Time"
,
t1
.
getObject
().
getClass
().
getName
());
ValueTime
t1b
=
ValueTime
.
parse
(
"11:11:11"
);
assertTrue
(
t1
==
t1b
);
...
...
@@ -210,16 +213,17 @@ public class TestDate extends TestBase {
assertEquals
(
"01:01:01"
,
t1
.
getTime
().
toString
());
assertEquals
(
"TIMESTAMP '2001-01-01 01:01:01.111'"
,
t1
.
getSQL
());
assertEquals
(
"TIMESTAMP '2001-01-01 01:01:01.111'"
,
t1
.
toString
());
assertEquals
(
Value
.
TIMESTAMP
,
t1
.
getType
());
assertEquals
(
Value
.
TIMESTAMP
,
t1
.
get
Value
Type
());
long
dateValue
=
t1
.
getDateValue
();
long
nanos
=
t1
.
getTimeNanos
();
assertEquals
((
int
)
((
dateValue
>>>
32
)
^
dateValue
^
(
nanos
>>>
32
)
^
nanos
),
t1
.
hashCode
());
// Literals return maximum precision
assertEquals
(
ValueTimestamp
.
MAXIMUM_PRECISION
,
t1
.
getDisplaySize
());
assertEquals
(
ValueTimestamp
.
MAXIMUM_PRECISION
,
t1
.
getPrecision
());
assertEquals
(
9
,
t1
.
getScale
());
TypeInfo
type
=
t1
.
getType
();
assertEquals
(
ValueTimestamp
.
MAXIMUM_PRECISION
,
type
.
getDisplaySize
());
assertEquals
(
ValueTimestamp
.
MAXIMUM_PRECISION
,
type
.
getPrecision
());
assertEquals
(
9
,
type
.
getScale
());
assertEquals
(
"java.sql.Timestamp"
,
t1
.
getObject
().
getClass
().
getName
());
ValueTimestamp
t1b
=
ValueTimestamp
.
parse
(
"2001-01-01 01:01:01.111"
);
assertTrue
(
t1
==
t1b
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
3f2932f9
...
...
@@ -131,7 +131,7 @@ public class TestValue extends TestDb {
rs
.
next
();
Value
v
=
DataType
.
readValue
(
null
,
rs
,
1
,
valueType
);
Value
v2
=
DataType
.
convertToValue
(
null
,
obj
,
valueType
);
if
(
v
.
getType
()
==
Value
.
RESULT_SET
)
{
if
(
v
.
get
Value
Type
()
==
Value
.
RESULT_SET
)
{
assertEquals
(
v
.
toString
(),
v2
.
toString
());
}
else
{
assertTrue
(
v
.
equals
(
v2
));
...
...
@@ -166,21 +166,21 @@ public class TestValue extends TestDb {
v
=
ValueArray
.
get
(
new
Value
[]
{
ValueString
.
get
(
"hello"
),
ValueString
.
get
(
"world"
)
});
assertEquals
(
10
,
v
.
getPrecision
());
assertEquals
(
5
,
v
.
convertPrecision
(
5
,
true
).
getPrecision
());
assertEquals
(
10
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
5
,
v
.
convertPrecision
(
5
,
true
).
get
Type
().
get
Precision
());
v
=
ValueArray
.
get
(
new
Value
[]{
ValueString
.
get
(
""
),
ValueString
.
get
(
""
)});
assertEquals
(
0
,
v
.
getPrecision
());
assertEquals
(
0
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
"['']"
,
v
.
convertPrecision
(
1
,
true
).
toString
());
v
=
ValueBytes
.
get
(
spaces
.
getBytes
());
assertEquals
(
100
,
v
.
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getPrecision
());
assertEquals
(
100
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getBytes
().
length
);
assertEquals
(
32
,
v
.
convertPrecision
(
10
,
false
).
getBytes
()[
9
]);
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
true
).
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
true
).
get
Type
().
get
Precision
());
final
Value
vd
=
ValueDecimal
.
get
(
new
BigDecimal
(
"1234567890.123456789"
));
assertEquals
(
19
,
vd
.
getPrecision
());
assertEquals
(
19
,
vd
.
get
Type
().
get
Precision
());
assertEquals
(
"1234567890.1234567"
,
vd
.
convertPrecision
(
10
,
true
).
getString
());
new
AssertThrows
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE_1
)
{
@Override
...
...
@@ -190,32 +190,32 @@ public class TestValue extends TestDb {
};
v
=
ValueLobDb
.
createSmallLob
(
Value
.
CLOB
,
spaces
.
getBytes
(),
100
);
assertEquals
(
100
,
v
.
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getPrecision
());
assertEquals
(
100
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getString
().
length
());
assertEquals
(
" "
,
v
.
convertPrecision
(
10
,
false
).
getString
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
true
).
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
true
).
get
Type
().
get
Precision
());
v
=
ValueLobDb
.
createSmallLob
(
Value
.
BLOB
,
spaces
.
getBytes
(),
100
);
assertEquals
(
100
,
v
.
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getPrecision
());
assertEquals
(
100
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getBytes
().
length
);
assertEquals
(
32
,
v
.
convertPrecision
(
10
,
false
).
getBytes
()[
9
]);
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
true
).
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
true
).
get
Type
().
get
Precision
());
SimpleResult
rs
=
new
SimpleResult
();
rs
.
addColumn
(
"X"
,
"X"
,
Value
.
INT
,
0
,
0
,
ValueInt
.
DISPLAY_SIZE
);
rs
.
addRow
(
ValueInt
.
get
(
1
));
v
=
ValueResultSet
.
get
(
rs
);
assertEquals
(
Integer
.
MAX_VALUE
,
v
.
getPrecision
());
assertEquals
(
Integer
.
MAX_VALUE
,
v
.
convertPrecision
(
10
,
false
).
getPrecision
());
assertEquals
(
Integer
.
MAX_VALUE
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
Integer
.
MAX_VALUE
,
v
.
convertPrecision
(
10
,
false
).
get
Type
().
get
Precision
());
assertEquals
(
1
,
v
.
convertPrecision
(
10
,
false
).
getResult
().
getRowCount
());
assertEquals
(
0
,
v
.
convertPrecision
(
10
,
true
).
getResult
().
getRowCount
());
assertEquals
(
Integer
.
MAX_VALUE
,
v
.
convertPrecision
(
10
,
true
).
getPrecision
());
assertEquals
(
Integer
.
MAX_VALUE
,
v
.
convertPrecision
(
10
,
true
).
get
Type
().
get
Precision
());
v
=
ValueString
.
get
(
spaces
);
assertEquals
(
100
,
v
.
getPrecision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
getPrecision
());
assertEquals
(
100
,
v
.
get
Type
().
get
Precision
());
assertEquals
(
10
,
v
.
convertPrecision
(
10
,
false
).
get
Type
().
get
Precision
());
assertEquals
(
" "
,
v
.
convertPrecision
(
10
,
false
).
getString
());
assertEquals
(
" "
,
v
.
convertPrecision
(
10
,
true
).
getString
());
...
...
@@ -367,7 +367,7 @@ public class TestValue extends TestDb {
private
void
testArray
()
{
ValueArray
src
=
ValueArray
.
get
(
String
.
class
,
new
Value
[]
{
ValueString
.
get
(
"1"
),
ValueString
.
get
(
"22"
),
ValueString
.
get
(
"333"
)});
assertEquals
(
6
,
src
.
getPrecision
());
assertEquals
(
6
,
src
.
get
Type
().
get
Precision
());
assertSame
(
src
,
src
.
convertPrecision
(
5
,
false
));
assertSame
(
src
,
src
.
convertPrecision
(
6
,
true
));
ValueArray
exp
=
ValueArray
.
get
(
String
.
class
,
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestValueMemory.java
浏览文件 @
3f2932f9
...
...
@@ -90,7 +90,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
continue
;
}
Value
v
=
create
(
i
);
String
s
=
"type: "
+
v
.
getType
()
+
String
s
=
"type: "
+
v
.
get
Value
Type
()
+
" calculated: "
+
v
.
getMemory
()
+
" real: "
+
MemoryFootprint
.
getObjectSize
(
v
)
+
" "
+
v
.
getClass
().
getName
()
+
": "
+
v
.
toString
();
...
...
@@ -111,7 +111,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
// jts not in the classpath, OK
continue
;
}
assertEquals
(
i
,
v
.
getType
());
assertEquals
(
i
,
v
.
get
Value
Type
());
testType
(
i
);
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论