Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
95bc8bb4
Unverified
提交
95bc8bb4
authored
1月 15, 2018
作者:
Noel Grandin
提交者:
GitHub
1月 15, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #761 from katzyn/JDBC
Fix issue #406: Return from ResultSet.getObject not in line with JDBC specification
上级
4f4015db
e9d33d9e
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
59 行增加
和
19 行删除
+59
-19
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+9
-0
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+11
-10
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+10
-1
ValueByte.java
h2/src/main/org/h2/value/ValueByte.java
+5
-0
ValueShort.java
h2/src/main/org/h2/value/ValueShort.java
+5
-0
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+14
-4
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+5
-4
没有找到文件。
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
95bc8bb4
...
...
@@ -346,6 +346,15 @@ public class SysProperties {
Utils
.
getProperty
(
"h2.oldStyleOuterJoin"
,
Constants
.
VERSION_MINOR
<
4
);
/**
* System property {@code h2.oldResultSetGetObject}, {@code true} by default.
* Return {@code Byte} and {@code Short} instead of {@code Integer} from
* {@code ResultSet#getObject(...)} for {@code TINYINT} and {@code SMALLINT}
* values.
*/
public
static
final
boolean
OLD_RESULT_SET_GET_OBJECT
=
Utils
.
getProperty
(
"h2.oldResultSetGetObject"
,
true
);
/**
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
* Default client encoding for PG server. It is used if the client does not
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
95bc8bb4
...
...
@@ -2037,28 +2037,29 @@ public class JdbcConnection extends TraceObject
* @return the object
*/
Object
convertToDefaultObject
(
Value
v
)
{
Object
o
;
switch
(
v
.
getType
())
{
case
Value
.
CLOB
:
{
int
id
=
getNextId
(
TraceObject
.
CLOB
);
o
=
new
JdbcClob
(
this
,
v
,
id
);
break
;
return
new
JdbcClob
(
this
,
v
,
id
);
}
case
Value
.
BLOB
:
{
int
id
=
getNextId
(
TraceObject
.
BLOB
);
o
=
new
JdbcBlob
(
this
,
v
,
id
);
break
;
return
new
JdbcBlob
(
this
,
v
,
id
);
}
case
Value
.
JAVA_OBJECT
:
if
(
SysProperties
.
serializeJavaObject
)
{
o
=
JdbcUtils
.
deserialize
(
v
.
getBytesNoCopy
(),
return
JdbcUtils
.
deserialize
(
v
.
getBytesNoCopy
(),
session
.
getDataHandler
());
break
;
}
default
:
o
=
v
.
getObject
();
break
;
case
Value
.
BYTE
:
case
Value
.
SHORT
:
if
(!
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
)
{
return
v
.
getInt
();
}
break
;
}
return
o
;
return
v
.
getObject
()
;
}
CompareMode
getCompareMode
()
{
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
95bc8bb4
...
...
@@ -9,6 +9,7 @@ import java.lang.reflect.Array;
import
java.sql.PreparedStatement
;
import
java.util.ArrayList
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.MathUtils
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -124,7 +125,15 @@ public class ValueArray extends Value {
int
len
=
values
.
length
;
Object
[]
list
=
(
Object
[])
Array
.
newInstance
(
componentType
,
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
list
[
i
]
=
values
[
i
].
getObject
();
final
Value
value
=
values
[
i
];
if
(!
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
)
{
final
int
type
=
value
.
getType
();
if
(
type
==
Value
.
BYTE
||
type
==
Value
.
SHORT
)
{
list
[
i
]
=
value
.
getInt
();
continue
;
}
}
list
[
i
]
=
value
.
getObject
();
}
return
list
;
}
...
...
h2/src/main/org/h2/value/ValueByte.java
浏览文件 @
95bc8bb4
...
...
@@ -102,6 +102,11 @@ public class ValueByte extends Value {
return
value
;
}
@Override
public
int
getInt
()
{
return
value
;
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueByte
v
=
(
ValueByte
)
o
;
...
...
h2/src/main/org/h2/value/ValueShort.java
浏览文件 @
95bc8bb4
...
...
@@ -102,6 +102,11 @@ public class ValueShort extends Value {
return
value
;
}
@Override
public
int
getInt
()
{
return
value
;
}
@Override
protected
int
compareSecure
(
Value
o
,
CompareMode
mode
)
{
ValueShort
v
=
(
ValueShort
)
o
;
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
95bc8bb4
...
...
@@ -26,6 +26,7 @@ import java.sql.Types;
import
java.util.UUID
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.Trigger
;
import
org.h2.engine.SysProperties
;
import
org.h2.test.TestBase
;
import
org.h2.util.LocalDateTimeUtils
;
import
org.h2.util.Task
;
...
...
@@ -1118,7 +1119,7 @@ public class TestPreparedStatement extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello')"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? FROM TEST"
);
"SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
, ?, ?
FROM TEST"
);
prep
.
setObject
(
1
,
Boolean
.
TRUE
);
prep
.
setObject
(
2
,
"Abc"
);
prep
.
setObject
(
3
,
new
BigDecimal
(
"10.2"
));
...
...
@@ -1142,14 +1143,17 @@ public class TestPreparedStatement extends TestBase {
prep
.
setObject
(
18
,
"3.725"
,
Types
.
DOUBLE
);
prep
.
setObject
(
19
,
"23:22:21"
,
Types
.
TIME
);
prep
.
setObject
(
20
,
new
java
.
math
.
BigInteger
(
"12345"
),
Types
.
OTHER
);
prep
.
setArray
(
21
,
conn
.
createArrayOf
(
"TINYINT"
,
new
Object
[]
{(
byte
)
1
}));
prep
.
setArray
(
22
,
conn
.
createArrayOf
(
"SMALLINT"
,
new
Object
[]
{(
short
)
-
2
}));
rs
=
prep
.
executeQuery
();
rs
.
next
();
assertTrue
(
rs
.
getObject
(
1
).
equals
(
Boolean
.
TRUE
));
assertTrue
(
rs
.
getObject
(
2
).
equals
(
"Abc"
));
assertTrue
(
rs
.
getObject
(
3
).
equals
(
new
BigDecimal
(
"10.2"
)));
assertTrue
(
rs
.
getObject
(
4
).
equals
((
byte
)
0xff
));
assertTrue
(
rs
.
getObject
(
5
).
equals
(
new
Short
(
Short
.
MAX_VALUE
)));
assertTrue
(
rs
.
getObject
(
4
).
equals
(
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
?
(
Object
)
Byte
.
valueOf
((
byte
)
0xff
)
:
(
Object
)
Integer
.
valueOf
(-
1
)));
assertTrue
(
rs
.
getObject
(
5
).
equals
(
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
?
(
Object
)
Short
.
valueOf
(
Short
.
MAX_VALUE
)
:
(
Object
)
Integer
.
valueOf
(
Short
.
MAX_VALUE
)));
assertTrue
(
rs
.
getObject
(
6
).
equals
(
new
Integer
(
Integer
.
MIN_VALUE
)));
assertTrue
(
rs
.
getObject
(
7
).
equals
(
...
...
@@ -1178,6 +1182,12 @@ public class TestPreparedStatement extends TestBase {
java
.
sql
.
Time
.
valueOf
(
"23:22:21"
)));
assertTrue
(
rs
.
getObject
(
20
).
equals
(
new
java
.
math
.
BigInteger
(
"12345"
)));
Object
[]
a
=
(
Object
[])
rs
.
getObject
(
21
);
assertEquals
(
a
[
0
],
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
?
(
Object
)
Byte
.
valueOf
((
byte
)
1
)
:
(
Object
)
Integer
.
valueOf
(
1
));
a
=
(
Object
[])
rs
.
getObject
(
22
);
assertEquals
(
a
[
0
],
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
?
(
Object
)
Short
.
valueOf
((
short
)
-
2
)
:
(
Object
)
Integer
.
valueOf
(-
2
));
// } else if(x instanceof java.io.Reader) {
// return session.createLob(Value.CLOB,
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
95bc8bb4
...
...
@@ -37,6 +37,7 @@ import java.util.Collections;
import
java.util.TimeZone
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.SysProperties
;
import
org.h2.test.TestBase
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IOUtils
;
...
...
@@ -793,16 +794,16 @@ public class TestResultSet extends TestBase {
o
=
rs
.
getObject
(
"value"
);
trace
(
o
.
getClass
().
getName
());
assertTrue
(
o
instanceof
Short
);
assertTrue
(((
Short
)
o
).
shor
tValue
()
==
-
1
);
assertTrue
(
o
.
getClass
()
==
(
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
?
Short
.
class
:
Integer
.
class
)
);
assertTrue
(((
Number
)
o
).
in
tValue
()
==
-
1
);
o
=
rs
.
getObject
(
"value"
,
Short
.
class
);
trace
(
o
.
getClass
().
getName
());
assertTrue
(
o
instanceof
Short
);
assertTrue
(((
Short
)
o
).
shortValue
()
==
-
1
);
o
=
rs
.
getObject
(
2
);
trace
(
o
.
getClass
().
getName
());
assertTrue
(
o
instanceof
Short
);
assertTrue
(((
Short
)
o
).
shor
tValue
()
==
-
1
);
assertTrue
(
o
.
getClass
()
==
(
SysProperties
.
OLD_RESULT_SET_GET_OBJECT
?
Short
.
class
:
Integer
.
class
)
);
assertTrue
(((
Number
)
o
).
in
tValue
()
==
-
1
);
o
=
rs
.
getObject
(
2
,
Short
.
class
);
trace
(
o
.
getClass
().
getName
());
assertTrue
(
o
instanceof
Short
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论