Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ff192980
提交
ff192980
authored
5月 29, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue #127: Linked tables now support geometry columns.
上级
357f9251
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
2 行删除
+37
-2
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+2
-1
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+33
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
ff192980
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #127: Linked tables now support geometry columns.
</li>
<li>
ABS(CAST(0.0 AS DOUBLE)) returned -0.0 instead of 0.0.
<li>
ABS(CAST(0.0 AS DOUBLE)) returned -0.0 instead of 0.0.
</li>
</li>
<li>
BNF auto-completion failed with unquoted identifiers.
<li>
BNF auto-completion failed with unquoted identifiers.
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
ff192980
...
@@ -150,12 +150,13 @@ public class TableLink extends Table {
...
@@ -150,12 +150,13 @@ public class TableLink extends Table {
String
n
=
rs
.
getString
(
"COLUMN_NAME"
);
String
n
=
rs
.
getString
(
"COLUMN_NAME"
);
n
=
convertColumnName
(
n
);
n
=
convertColumnName
(
n
);
int
sqlType
=
rs
.
getInt
(
"DATA_TYPE"
);
int
sqlType
=
rs
.
getInt
(
"DATA_TYPE"
);
String
sqlTypeName
=
rs
.
getString
(
"TYPE_NAME"
);
long
precision
=
rs
.
getInt
(
"COLUMN_SIZE"
);
long
precision
=
rs
.
getInt
(
"COLUMN_SIZE"
);
precision
=
convertPrecision
(
sqlType
,
precision
);
precision
=
convertPrecision
(
sqlType
,
precision
);
int
scale
=
rs
.
getInt
(
"DECIMAL_DIGITS"
);
int
scale
=
rs
.
getInt
(
"DECIMAL_DIGITS"
);
scale
=
convertScale
(
sqlType
,
scale
);
scale
=
convertScale
(
sqlType
,
scale
);
int
displaySize
=
MathUtils
.
convertLongToInt
(
precision
);
int
displaySize
=
MathUtils
.
convertLongToInt
(
precision
);
int
type
=
DataType
.
convertSQLTypeToValueType
(
sqlType
);
int
type
=
DataType
.
convertSQLTypeToValueType
(
sqlType
,
sqlTypeName
);
Column
col
=
new
Column
(
n
,
type
,
precision
,
scale
,
displaySize
);
Column
col
=
new
Column
(
n
,
type
,
precision
,
scale
,
displaySize
);
col
.
setTable
(
this
,
i
++);
col
.
setTable
(
this
,
i
++);
columnList
.
add
(
col
);
columnList
.
add
(
col
);
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
ff192980
...
@@ -18,6 +18,7 @@ import java.sql.Timestamp;
...
@@ -18,6 +18,7 @@ import java.sql.Timestamp;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.value.DataType
;
/**
/**
* Tests the linked table feature (CREATE LINKED TABLE).
* Tests the linked table feature (CREATE LINKED TABLE).
...
@@ -52,7 +53,7 @@ public class TestLinkedTable extends TestBase {
...
@@ -52,7 +53,7 @@ public class TestLinkedTable extends TestBase {
testLinkTwoTables
();
testLinkTwoTables
();
testCachingResults
();
testCachingResults
();
testLinkedTableInReadOnlyDb
();
testLinkedTableInReadOnlyDb
();
testGeometry
();
deleteDb
(
"linkedTable"
);
deleteDb
(
"linkedTable"
);
}
}
...
@@ -693,4 +694,35 @@ public class TestLinkedTable extends TestBase {
...
@@ -693,4 +694,35 @@ public class TestLinkedTable extends TestBase {
deleteDb
(
"testLinkedTableInReadOnlyDb"
);
deleteDb
(
"testLinkedTableInReadOnlyDb"
);
}
}
private
void
testGeometry
()
throws
SQLException
{
if
(!
config
.
mvStore
&&
config
.
mvcc
)
{
return
;
}
if
(
config
.
memory
&&
config
.
mvcc
)
{
return
;
}
if
(
DataType
.
GEOMETRY_CLASS
==
null
)
{
return
;
}
org
.
h2
.
Driver
.
load
();
Connection
ca
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:one"
,
"sa"
,
"sa"
);
Connection
cb
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:two"
,
"sa"
,
"sa"
);
Statement
sa
=
ca
.
createStatement
();
Statement
sb
=
cb
.
createStatement
();
sa
.
execute
(
"CREATE TABLE TEST(ID SERIAL, the_geom geometry)"
);
sa
.
execute
(
"INSERT INTO TEST(THE_GEOM) VALUES('POINT (1 1)')"
);
String
sql
=
"CREATE LINKED TABLE T(NULL, "
+
"'jdbc:h2:mem:one', 'sa', 'sa', 'TEST') READONLY"
;
sb
.
execute
(
sql
);
ResultSet
rs
=
sb
.
executeQuery
(
"SELECT * FROM T"
);
try
{
assertTrue
(
rs
.
next
());
assertEquals
(
"POINT (1 1)"
,
rs
.
getString
(
"THE_GEOM"
));
}
finally
{
rs
.
close
();
}
sb
.
execute
(
"DROP TABLE T"
);
ca
.
close
();
cb
.
close
();
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论