Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8aced489
提交
8aced489
authored
3月 21, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Preserve type names in more places especially for UUID
上级
1b50216c
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
32 行增加
和
10 行删除
+32
-10
TableFunction.java
h2/src/main/org/h2/expression/TableFunction.java
+4
-6
MergedResultSet.java
h2/src/main/org/h2/util/MergedResultSet.java
+9
-4
DataType.java
h2/src/main/org/h2/value/DataType.java
+5
-0
TestGetGeneratedKeys.java
h2/src/test/org/h2/test/jdbc/TestGetGeneratedKeys.java
+4
-0
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+10
-0
没有找到文件。
h2/src/main/org/h2/expression/TableFunction.java
浏览文件 @
8aced489
...
@@ -135,14 +135,12 @@ public class TableFunction extends Function {
...
@@ -135,14 +135,12 @@ public class TableFunction extends Function {
simple
.
setAutoClose
(
false
);
simple
.
setAutoClose
(
false
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
String
name
=
rs
.
getColumnName
(
i
);
String
name
=
rs
.
getColumnName
(
i
);
/*
DataType
dataType
=
DataType
.
getDataType
(
rs
.
getColumnType
(
i
));
* TODO Some types, such as Value.BYTES and Value.UUID are mapped to the same
int
sqlType
=
dataType
.
sqlType
;
* SQL type and we can lose real type here.
String
sqlTypeName
=
dataType
.
name
;
*/
int
sqlType
=
DataType
.
convertTypeToSQLType
(
rs
.
getColumnType
(
i
));
int
precision
=
MathUtils
.
convertLongToInt
(
rs
.
getColumnPrecision
(
i
));
int
precision
=
MathUtils
.
convertLongToInt
(
rs
.
getColumnPrecision
(
i
));
int
scale
=
rs
.
getColumnScale
(
i
);
int
scale
=
rs
.
getColumnScale
(
i
);
simple
.
addColumn
(
name
,
sqlType
,
precision
,
scale
);
simple
.
addColumn
(
name
,
sqlType
,
sqlTypeName
,
precision
,
scale
);
}
}
rs
.
reset
();
rs
.
reset
();
for
(
int
i
=
0
;
i
<
maxrows
&&
rs
.
next
();
i
++)
{
for
(
int
i
=
0
;
i
<
maxrows
&&
rs
.
next
();
i
++)
{
...
...
h2/src/main/org/h2/util/MergedResultSet.java
浏览文件 @
8aced489
...
@@ -32,6 +32,8 @@ public final class MergedResultSet {
...
@@ -32,6 +32,8 @@ public final class MergedResultSet {
final
int
type
;
final
int
type
;
final
String
typeName
;
final
int
precision
;
final
int
precision
;
final
int
scale
;
final
int
scale
;
...
@@ -43,14 +45,17 @@ public final class MergedResultSet {
...
@@ -43,14 +45,17 @@ public final class MergedResultSet {
* name of the column
* name of the column
* @param type
* @param type
* type of the column, see {@link java.sql.Types}
* type of the column, see {@link java.sql.Types}
* @param typeName
* type name of the column
* @param precision
* @param precision
* precision of the column
* precision of the column
* @param scale
* @param scale
* scale of the column
* scale of the column
*/
*/
ColumnInfo
(
String
name
,
int
type
,
int
precision
,
int
scale
)
{
ColumnInfo
(
String
name
,
int
type
,
String
typeName
,
int
precision
,
int
scale
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
type
=
type
;
this
.
type
=
type
;
this
.
typeName
=
typeName
;
this
.
precision
=
precision
;
this
.
precision
=
precision
;
this
.
scale
=
scale
;
this
.
scale
=
scale
;
}
}
...
@@ -94,8 +99,8 @@ public final class MergedResultSet {
...
@@ -94,8 +99,8 @@ public final class MergedResultSet {
}
}
ColumnInfo
[]
info
=
new
ColumnInfo
[
cols
];
ColumnInfo
[]
info
=
new
ColumnInfo
[
cols
];
for
(
int
i
=
1
;
i
<=
cols
;
i
++)
{
for
(
int
i
=
1
;
i
<=
cols
;
i
++)
{
ColumnInfo
ci
=
new
ColumnInfo
(
meta
.
getColumnName
(
i
),
meta
.
getColumnType
(
i
),
meta
.
get
Precision
(
i
),
ColumnInfo
ci
=
new
ColumnInfo
(
meta
.
getColumnName
(
i
),
meta
.
getColumnType
(
i
),
meta
.
get
ColumnTypeName
(
i
),
meta
.
getScale
(
i
));
meta
.
get
Precision
(
i
),
meta
.
get
Scale
(
i
));
info
[
i
-
1
]
=
ci
;
info
[
i
-
1
]
=
ci
;
if
(!
columns
.
contains
(
ci
))
{
if
(!
columns
.
contains
(
ci
))
{
columns
.
add
(
ci
);
columns
.
add
(
ci
);
...
@@ -123,7 +128,7 @@ public final class MergedResultSet {
...
@@ -123,7 +128,7 @@ public final class MergedResultSet {
public
SimpleResultSet
getResult
()
{
public
SimpleResultSet
getResult
()
{
SimpleResultSet
rs
=
new
SimpleResultSet
();
SimpleResultSet
rs
=
new
SimpleResultSet
();
for
(
ColumnInfo
ci
:
columns
)
{
for
(
ColumnInfo
ci
:
columns
)
{
rs
.
addColumn
(
ci
.
name
,
ci
.
type
,
ci
.
precision
,
ci
.
scale
);
rs
.
addColumn
(
ci
.
name
,
ci
.
type
,
ci
.
typeName
,
ci
.
precision
,
ci
.
scale
);
}
}
for
(
Map
<
ColumnInfo
,
Object
>
map
:
data
)
{
for
(
Map
<
ColumnInfo
,
Object
>
map
:
data
)
{
Object
[]
row
=
new
Object
[
columns
.
size
()];
Object
[]
row
=
new
Object
[
columns
.
size
()];
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
8aced489
...
@@ -856,6 +856,11 @@ public class DataType {
...
@@ -856,6 +856,11 @@ public class DataType {
*/
*/
public
static
int
convertSQLTypeToValueType
(
int
sqlType
,
String
sqlTypeName
)
{
public
static
int
convertSQLTypeToValueType
(
int
sqlType
,
String
sqlTypeName
)
{
switch
(
sqlType
)
{
switch
(
sqlType
)
{
case
Types
.
BINARY
:
if
(
sqlTypeName
.
equalsIgnoreCase
(
"UUID"
))
{
return
Value
.
UUID
;
}
break
;
case
Types
.
OTHER
:
case
Types
.
OTHER
:
case
Types
.
JAVA_OBJECT
:
case
Types
.
JAVA_OBJECT
:
if
(
sqlTypeName
.
equalsIgnoreCase
(
"geometry"
))
{
if
(
sqlTypeName
.
equalsIgnoreCase
(
"geometry"
))
{
...
...
h2/src/test/org/h2/test/jdbc/TestGetGeneratedKeys.java
浏览文件 @
8aced489
...
@@ -8,6 +8,7 @@ package org.h2.test.jdbc;
...
@@ -8,6 +8,7 @@ package org.h2.test.jdbc;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -127,6 +128,9 @@ public class TestGetGeneratedKeys extends TestBase {
...
@@ -127,6 +128,9 @@ public class TestGetGeneratedKeys extends TestBase {
prep
.
addBatch
();
prep
.
addBatch
();
prep
.
executeBatch
();
prep
.
executeBatch
();
ResultSet
rs
=
prep
.
getGeneratedKeys
();
ResultSet
rs
=
prep
.
getGeneratedKeys
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
assertEquals
(
"BIGINT"
,
meta
.
getColumnTypeName
(
1
));
assertEquals
(
"UUID"
,
meta
.
getColumnTypeName
(
2
));
rs
.
next
();
rs
.
next
();
assertEquals
(
1L
,
rs
.
getLong
(
1
));
assertEquals
(
1L
,
rs
.
getLong
(
1
));
UUID
u1
=
(
UUID
)
rs
.
getObject
(
2
);
UUID
u1
=
(
UUID
)
rs
.
getObject
(
2
);
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
8aced489
...
@@ -8,11 +8,14 @@ package org.h2.test.jdbc;
...
@@ -8,11 +8,14 @@ package org.h2.test.jdbc;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.DatabaseMetaData
;
import
java.sql.Driver
;
import
java.sql.Driver
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.sql.Types
;
import
java.sql.Types
;
import
java.util.UUID
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
...
@@ -135,6 +138,13 @@ public class TestMetaData extends TestBase {
...
@@ -135,6 +138,13 @@ public class TestMetaData extends TestBase {
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
rs
.
getHoldability
());
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
rs
.
getHoldability
());
stat
.
executeUpdate
(
"drop table test"
);
stat
.
executeUpdate
(
"drop table test"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT X FROM TABLE (X UUID = ?)"
);
prep
.
setObject
(
1
,
UUID
.
randomUUID
());
rs
=
prep
.
executeQuery
();
rsMeta
=
rs
.
getMetaData
();
assertEquals
(
"UUID"
,
rsMeta
.
getColumnTypeName
(
1
));
conn
.
close
();
conn
.
close
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论