Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
84bbf5bd
提交
84bbf5bd
authored
10 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 609: the spatial index did not support NULL with update and delete operations.
上级
03fc1e6f
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
65 行增加
和
8 行删除
+65
-8
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
MVSpatialIndex.java
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
+2
-4
SpatialDataType.java
h2/src/main/org/h2/mvstore/rtree/SpatialDataType.java
+5
-3
SpatialKey.java
h2/src/main/org/h2/mvstore/rtree/SpatialKey.java
+4
-0
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+52
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
84bbf5bd
...
@@ -20,7 +20,8 @@ Change Log
...
@@ -20,7 +20,8 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Pull request #2: Add external metadata type support (table type "external")
<ul><li>
Issue 609: the spatial index did not support NULL with update and delete operations.
</li><li>
Pull request #2: Add external metadata type support (table type "external")
</li><li>
MS SQL Server: the CONVERT method did not work in views
</li><li>
MS SQL Server: the CONVERT method did not work in views
and derrived tables.
and derrived tables.
</li><li>
Java 8 compatibility for "regexp_replace".
</li><li>
Java 8 compatibility for "regexp_replace".
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
浏览文件 @
84bbf5bd
...
@@ -171,6 +171,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
...
@@ -171,6 +171,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
try
{
try
{
Value
old
=
map
.
remove
(
key
);
Value
old
=
map
.
remove
(
key
);
if
(
old
==
null
)
{
if
(
old
==
null
)
{
old
=
map
.
remove
(
key
);
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
throw
DbException
.
get
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
getSQL
()
+
": "
+
row
.
getKey
());
getSQL
()
+
": "
+
row
.
getKey
());
}
}
...
@@ -211,12 +212,9 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
...
@@ -211,12 +212,9 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
}
}
private
SpatialKey
getKey
(
SearchRow
row
)
{
private
SpatialKey
getKey
(
SearchRow
row
)
{
if
(
row
==
null
)
{
return
null
;
}
Value
v
=
row
.
getValue
(
columnIds
[
0
]);
Value
v
=
row
.
getValue
(
columnIds
[
0
]);
if
(
v
==
ValueNull
.
INSTANCE
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
return
n
ull
;
return
n
ew
SpatialKey
(
row
.
getKey
())
;
}
}
Geometry
g
=
((
ValueGeometry
)
v
.
convertTo
(
Value
.
GEOMETRY
)).
getGeometryNoCopy
();
Geometry
g
=
((
ValueGeometry
)
v
.
convertTo
(
Value
.
GEOMETRY
)).
getGeometryNoCopy
();
Envelope
env
=
g
.
getEnvelopeInternal
();
Envelope
env
=
g
.
getEnvelopeInternal
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/rtree/SpatialDataType.java
浏览文件 @
84bbf5bd
...
@@ -83,11 +83,12 @@ public class SpatialDataType implements DataType {
...
@@ -83,11 +83,12 @@ public class SpatialDataType implements DataType {
@Override
@Override
public
void
write
(
WriteBuffer
buff
,
Object
obj
)
{
public
void
write
(
WriteBuffer
buff
,
Object
obj
)
{
if
(
obj
==
null
)
{
SpatialKey
k
=
(
SpatialKey
)
obj
;
if
(
k
.
isNull
())
{
buff
.
putVarInt
(-
1
);
buff
.
putVarInt
(-
1
);
buff
.
putVarLong
(
k
.
getId
());
return
;
return
;
}
}
SpatialKey
k
=
(
SpatialKey
)
obj
;
int
flags
=
0
;
int
flags
=
0
;
for
(
int
i
=
0
;
i
<
dimensions
;
i
++)
{
for
(
int
i
=
0
;
i
<
dimensions
;
i
++)
{
if
(
k
.
min
(
i
)
==
k
.
max
(
i
))
{
if
(
k
.
min
(
i
)
==
k
.
max
(
i
))
{
...
@@ -108,7 +109,8 @@ public class SpatialDataType implements DataType {
...
@@ -108,7 +109,8 @@ public class SpatialDataType implements DataType {
public
Object
read
(
ByteBuffer
buff
)
{
public
Object
read
(
ByteBuffer
buff
)
{
int
flags
=
DataUtils
.
readVarInt
(
buff
);
int
flags
=
DataUtils
.
readVarInt
(
buff
);
if
(
flags
==
-
1
)
{
if
(
flags
==
-
1
)
{
return
null
;
long
id
=
DataUtils
.
readVarLong
(
buff
);
return
new
SpatialKey
(
id
);
}
}
float
[]
minMax
=
new
float
[
dimensions
*
2
];
float
[]
minMax
=
new
float
[
dimensions
*
2
];
for
(
int
i
=
0
;
i
<
dimensions
;
i
++)
{
for
(
int
i
=
0
;
i
<
dimensions
;
i
++)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/rtree/SpatialKey.java
浏览文件 @
84bbf5bd
...
@@ -70,6 +70,10 @@ public class SpatialKey {
...
@@ -70,6 +70,10 @@ public class SpatialKey {
return
id
;
return
id
;
}
}
public
boolean
isNull
()
{
return
minMax
.
length
==
0
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
84bbf5bd
...
@@ -90,6 +90,8 @@ public class TestSpatial extends TestBase {
...
@@ -90,6 +90,8 @@ public class TestSpatial extends TestBase {
testStoreCorruption
();
testStoreCorruption
();
testExplainSpatialIndexWithPk
();
testExplainSpatialIndexWithPk
();
testNullableGeometry
();
testNullableGeometry
();
testNullableGeometryDelete
();
testNullableGeometryUpdate
();
}
}
private
void
testHashCode
()
{
private
void
testHashCode
()
{
...
@@ -920,6 +922,9 @@ public class TestSpatial extends TestBase {
...
@@ -920,6 +922,9 @@ public class TestSpatial extends TestBase {
+
"(id int primary key, the_geom geometry)"
);
+
"(id int primary key, the_geom geometry)"
);
stat
.
execute
(
"create spatial index on test(the_geom)"
);
stat
.
execute
(
"create spatial index on test(the_geom)"
);
stat
.
execute
(
"insert into test values(1, null)"
);
stat
.
execute
(
"insert into test values(1, null)"
);
stat
.
execute
(
"insert into test values(2, null)"
);
stat
.
execute
(
"delete from test where the_geom is null"
);
stat
.
execute
(
"insert into test values(1, null)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
1
,
rs
.
getInt
(
1
));
...
@@ -934,7 +939,54 @@ public class TestSpatial extends TestBase {
...
@@ -934,7 +939,54 @@ public class TestSpatial extends TestBase {
assertNull
(
rs
.
getObject
(
2
));
assertNull
(
rs
.
getObject
(
2
));
conn
.
close
();
conn
.
close
();
}
}
deleteDb
(
"spatial"
);
}
private
void
testNullableGeometryDelete
()
throws
SQLException
{
deleteDb
(
"spatial"
);
Connection
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create memory table test"
+
"(id int primary key, the_geom geometry)"
);
stat
.
execute
(
"create spatial index on test(the_geom)"
);
stat
.
execute
(
"insert into test values(1, null)"
);
stat
.
execute
(
"insert into test values(2, null)"
);
stat
.
execute
(
"insert into test values(3, null)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertNull
(
rs
.
getObject
(
2
));
stat
.
execute
(
"delete from test where id = 1"
);
stat
.
execute
(
"delete from test where id = 2"
);
stat
.
execute
(
"delete from test where id = 3"
);
stat
.
execute
(
"insert into test values(4, null)"
);
stat
.
execute
(
"insert into test values(5, null)"
);
stat
.
execute
(
"insert into test values(6, null)"
);
stat
.
execute
(
"delete from test where id = 4"
);
stat
.
execute
(
"delete from test where id = 5"
);
stat
.
execute
(
"delete from test where id = 6"
);
conn
.
close
();
deleteDb
(
"spatial"
);
}
private
void
testNullableGeometryUpdate
()
throws
SQLException
{
deleteDb
(
"spatial"
);
Connection
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create memory table test"
+
"(id int primary key, the_geom geometry, description varchar2(32))"
);
stat
.
execute
(
"create spatial index on test(the_geom)"
);
stat
.
execute
(
"insert into test values(1, null, null)"
);
stat
.
execute
(
"insert into test values(2, null, null)"
);
stat
.
execute
(
"insert into test values(3, null, null)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertNull
(
rs
.
getObject
(
2
));
stat
.
execute
(
"update test set description='DESCRIPTION' where id = 1"
);
stat
.
execute
(
"update test set description='DESCRIPTION' where id = 2"
);
stat
.
execute
(
"update test set description='DESCRIPTION' where id = 3"
);
conn
.
close
();
deleteDb
(
"spatial"
);
deleteDb
(
"spatial"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论