Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
86fba974
提交
86fba974
authored
6月 26, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup.
上级
a75bf79a
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
77 行增加
和
43 行删除
+77
-43
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+1
-1
PgServer.java
h2/src/main/org/h2/server/pg/PgServer.java
+9
-5
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+5
-3
Data.java
h2/src/main/org/h2/store/Data.java
+9
-12
Value.java
h2/src/main/org/h2/value/Value.java
+1
-1
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+52
-21
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
86fba974
...
...
@@ -543,7 +543,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Check whether the statement was cancelled.
*
*
* @return true if yes
*/
public
boolean
wasCancelled
()
{
...
...
h2/src/main/org/h2/server/pg/PgServer.java
浏览文件 @
86fba974
...
...
@@ -262,7 +262,8 @@ public class PgServer implements Service {
/**
* Get the thread with the given process id.
*
*
* @param processId the process id
* @return the thread
*/
PgServerThread
getThread
(
int
processId
)
{
...
...
@@ -463,9 +464,10 @@ public class PgServer implements Service {
* A fake wrapper around pg_get_expr(expr_text, relation_oid), in PostgreSQL
* it "decompiles the internal form of an expression, assuming that any vars
* in it refer to the relation indicated by the second parameter".
*
*
* @param exprText the expression text
* @param relationOid the relation object id
* @return always null
*/
public
static
String
getPgExpr
(
String
exprText
,
int
relationOid
)
{
return
null
;
...
...
@@ -475,12 +477,14 @@ public class PgServer implements Service {
* Check if the current session has access to this table.
* This method is called by the database.
*
* @param pgType the postgres type oid
* @param conn the connection
* @param pgType the PostgreSQL type oid
* @param typeMod the type modifier (typically -1)
* @return
A string name for
the given type
* @return
the name of
the given type
*/
public
static
String
formatType
(
Connection
conn
,
int
pgType
,
int
typeMod
)
throws
SQLException
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select typname from pg_catalog.pg_type where oid = ? and typtypmod = ?"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select typname from pg_catalog.pg_type where oid = ? and typtypmod = ?"
);
prep
.
setInt
(
1
,
pgType
);
prep
.
setInt
(
2
,
typeMod
);
ResultSet
rs
=
prep
.
executeQuery
();
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
86fba974
...
...
@@ -155,7 +155,8 @@ public class PgServerThread implements Runnable {
if
(
c
!=
null
&&
key
==
c
.
secret
)
{
c
.
cancelRequest
();
}
else
{
// According to http://www.postgresql.org/docs/9.1/static/protocol-flow.html#AEN91739,
// According to
// http://www.postgresql.org/docs/9.1/static/protocol-flow.html#AEN91739,
// when canceling a request, if an invalid secret is provided then no exception
// should be sent back to the client.
server
.
trace
(
"Invalid CancelRequest: pid="
+
pid
+
", key="
+
key
);
...
...
@@ -548,7 +549,8 @@ public class PgServerThread implements Runnable {
return
clientEncoding
;
}
private
void
setParameter
(
PreparedStatement
prep
,
int
pgType
,
int
i
,
int
[]
formatCodes
)
throws
SQLException
,
IOException
{
private
void
setParameter
(
PreparedStatement
prep
,
int
pgType
,
int
i
,
int
[]
formatCodes
)
throws
SQLException
,
IOException
{
boolean
text
=
(
i
>=
formatCodes
.
length
)
||
(
formatCodes
[
i
]
==
0
);
int
col
=
i
+
1
;
int
paramLen
=
readInt
();
...
...
@@ -711,7 +713,7 @@ public class PgServerThread implements Runnable {
/**
* Check whether the given type should be formatted as text.
*
*
* @return true for binary
*/
private
static
boolean
formatAsText
(
int
pgType
)
{
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
86fba974
...
...
@@ -675,14 +675,8 @@ public class Data {
writeByte
((
byte
)
type
);
byte
[]
b
=
v
.
getBytes
();
int
len
=
b
.
length
;
if
(
len
<
32
)
{
writeByte
((
byte
)
(
BYTES_0_31
+
len
));
write
(
b
,
0
,
b
.
length
);
}
else
{
writeByte
((
byte
)
type
);
writeVarInt
(
b
.
length
);
write
(
b
,
0
,
b
.
length
);
}
writeVarInt
(
len
);
write
(
b
,
0
,
len
);
break
;
}
default
:
...
...
@@ -854,6 +848,12 @@ public class Data {
}
return
ValueResultSet
.
get
(
rs
);
}
case
Value
.
GEOMETRY
:
{
int
len
=
readVarInt
();
byte
[]
b
=
DataUtils
.
newBytes
(
len
);
read
(
b
,
0
,
len
);
return
ValueGeometry
.
get
(
b
);
}
default
:
if
(
type
>=
INT_0_15
&&
type
<
INT_0_15
+
16
)
{
return
ValueInt
.
get
(
type
-
INT_0_15
);
...
...
@@ -1092,10 +1092,7 @@ public class Data {
case
Value
.
GEOMETRY
:
{
byte
[]
b
=
v
.
getBytesNoCopy
();
int
len
=
b
.
length
;
if
(
len
<
32
)
{
return
1
+
b
.
length
;
}
return
1
+
getVarIntLen
(
b
.
length
)
+
b
.
length
;
return
1
+
getVarIntLen
(
len
)
+
len
;
}
default
:
throw
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
86fba974
...
...
@@ -155,7 +155,7 @@ public abstract class Value {
* The value type for string values with a fixed size.
*/
public
static
final
int
GEOMETRY
=
22
;
/**
* The number of value types.
*/
...
...
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
86fba974
...
...
@@ -9,6 +9,8 @@ package org.h2.value;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
org.h2.message.DbException
;
import
org.h2.util.StringUtils
;
import
com.vividsolutions.jts.geom.Geometry
;
import
com.vividsolutions.jts.io.ParseException
;
import
com.vividsolutions.jts.io.WKBReader
;
...
...
@@ -49,7 +51,7 @@ public class ValueGeometry extends Value {
public
static
ValueGeometry
get
(
String
s
)
{
return
(
ValueGeometry
)
Value
.
cache
(
new
ValueGeometry
(
fromWKT
(
s
)));
}
/**
* Get or create a geometry value for the given geometry.
*
...
...
@@ -59,23 +61,41 @@ public class ValueGeometry extends Value {
public
static
ValueGeometry
get
(
byte
[]
bytes
)
{
return
(
ValueGeometry
)
Value
.
cache
(
new
ValueGeometry
(
fromWKB
(
bytes
)));
}
public
Geometry
getGeometry
()
{
return
geometry
;
}
/**
* Check whether two values intersect.
*
* @param r the second value
* @return true if they intersect
*/
public
boolean
intersects
(
ValueGeometry
r
)
{
return
geometry
.
intersects
(
r
.
getGeometry
());
}
/**
* Get the intersection of two values.
*
* @param r the second value
* @return the intersection
*/
public
Value
intersection
(
ValueGeometry
r
)
{
return
get
(
this
.
geometry
.
intersection
(
r
.
geometry
));
return
get
(
geometry
.
intersection
(
r
.
geometry
));
}
/**
* Get the union of two values.
*
* @param r the second value
* @return the union
*/
public
Value
union
(
ValueGeometry
r
)
{
return
get
(
this
.
geometry
.
union
(
r
.
geometry
));
return
get
(
geometry
.
union
(
r
.
geometry
));
}
@Override
public
int
getType
()
{
return
Value
.
GEOMETRY
;
...
...
@@ -83,13 +103,13 @@ public class ValueGeometry extends Value {
@Override
public
String
getSQL
()
{
return
"'"
+
toWKT
()
+
"'"
;
return
StringUtils
.
quoteStringSQL
(
toWKT
())
;
}
@Override
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
Geometry
g
=
((
ValueGeometry
)
v
).
geometry
;
return
this
.
geometry
.
compareTo
(
g
);
return
geometry
.
compareTo
(
g
);
}
@Override
...
...
@@ -104,7 +124,7 @@ public class ValueGeometry extends Value {
@Override
public
int
hashCode
()
{
return
this
.
geometry
.
hashCode
();
return
geometry
.
hashCode
();
}
@Override
...
...
@@ -116,7 +136,7 @@ public class ValueGeometry extends Value {
public
byte
[]
getBytes
()
{
return
toWKB
();
}
@Override
public
void
set
(
PreparedStatement
prep
,
int
parameterIndex
)
throws
SQLException
{
prep
.
setObject
(
parameterIndex
,
geometry
);
...
...
@@ -136,25 +156,32 @@ public class ValueGeometry extends Value {
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueGeometry
&&
geometry
.
equals
(((
ValueGeometry
)
other
).
geometry
);
}
/**
* Convert to Well-Known-Text format.
* Convert the value to the Well-Known-Text format.
*
* @return the well-known-text
*/
public
String
toWKT
()
{
WKTWriter
w
=
new
WKTWriter
();
return
w
.
write
(
this
.
geometry
);
return
w
.
write
(
geometry
);
}
/**
* Convert to Well-Known-Binary format.
* Convert to value to the Well-Known-Binary format.
*
* @return the well-known-binary
*/
public
byte
[]
toWKB
()
{
WKBWriter
w
=
new
WKBWriter
();
return
w
.
write
(
this
.
geometry
);
return
w
.
write
(
geometry
);
}
/**
* Convert from Well-Known-Text format.
* Convert a Well-Known-Text to a Geometry object.
*
* @param s the well-known-text
* @return the Geometry object
*/
private
static
Geometry
fromWKT
(
String
s
)
{
WKTReader
r
=
new
WKTReader
();
...
...
@@ -164,9 +191,12 @@ public class ValueGeometry extends Value {
throw
DbException
.
convert
(
ex
);
}
}
/**
* Convert from Well-Known-Binary format.
* Convert a Well-Known-Binary to a Geometry object.
*
* @param s the well-known-binary
* @return the Geometry object
*/
private
static
Geometry
fromWKB
(
byte
[]
bytes
)
{
WKBReader
r
=
new
WKBReader
();
...
...
@@ -176,4 +206,5 @@ public class ValueGeometry extends Value {
throw
DbException
.
convert
(
ex
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论