Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
45fe1a64
提交
45fe1a64
authored
9月 05, 2016
作者:
Sergi Vladykin
提交者:
GitHub
9月 05, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #351 from kostya-sh/bind-formatCode
Respect format codes from Bind message when sending results
上级
d45b830c
696a50ed
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
28 行增加
和
11 行删除
+28
-11
pom.xml
h2/pom.xml
+2
-2
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+17
-6
TestPgServer.java
h2/src/test/org/h2/test/unit/TestPgServer.java
+9
-3
没有找到文件。
h2/pom.xml
浏览文件 @
45fe1a64
...
@@ -107,9 +107,9 @@
...
@@ -107,9 +107,9 @@
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
postgresql
</groupId>
<groupId>
org.
postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
<artifactId>
postgresql
</artifactId>
<version>
8.3-603.jdbc3
</version>
<version>
9.4.1209
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
45fe1a64
...
@@ -368,7 +368,7 @@ public class PgServerThread implements Runnable {
...
@@ -368,7 +368,7 @@ public class PgServerThread implements Runnable {
ResultSet
rs
=
prep
.
getResultSet
();
ResultSet
rs
=
prep
.
getResultSet
();
// the meta-data is sent in the prior 'Describe'
// the meta-data is sent in the prior 'Describe'
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
sendDataRow
(
rs
);
sendDataRow
(
rs
,
p
.
resultColumnFormat
);
}
}
sendCommandComplete
(
prep
,
0
);
sendCommandComplete
(
prep
,
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -414,7 +414,7 @@ public class PgServerThread implements Runnable {
...
@@ -414,7 +414,7 @@ public class PgServerThread implements Runnable {
try
{
try
{
sendRowDescription
(
meta
);
sendRowDescription
(
meta
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
sendDataRow
(
rs
);
sendDataRow
(
rs
,
null
);
}
}
sendCommandComplete
(
stat
,
0
);
sendCommandComplete
(
stat
,
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -495,20 +495,31 @@ public class PgServerThread implements Runnable {
...
@@ -495,20 +495,31 @@ public class PgServerThread implements Runnable {
sendMessage
();
sendMessage
();
}
}
private
void
sendDataRow
(
ResultSet
rs
)
throws
Exception
{
private
void
sendDataRow
(
ResultSet
rs
,
int
[]
formatCodes
)
throws
Exception
{
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
int
columns
=
metaData
.
getColumnCount
();
int
columns
=
metaData
.
getColumnCount
();
startMessage
(
'D'
);
startMessage
(
'D'
);
writeShort
(
columns
);
writeShort
(
columns
);
for
(
int
i
=
1
;
i
<=
columns
;
i
++)
{
for
(
int
i
=
1
;
i
<=
columns
;
i
++)
{
writeDataColumn
(
rs
,
i
,
PgServer
.
convertType
(
metaData
.
getColumnType
(
i
)));
int
pgType
=
PgServer
.
convertType
(
metaData
.
getColumnType
(
i
));
boolean
text
=
formatAsText
(
pgType
);
if
(
formatCodes
!=
null
)
{
if
(
formatCodes
.
length
==
0
)
{
text
=
true
;
}
else
if
(
formatCodes
.
length
==
1
)
{
text
=
formatCodes
[
0
]
==
0
;
}
else
if
(
i
-
1
<
formatCodes
.
length
)
{
text
=
formatCodes
[
i
-
1
]
==
0
;
}
}
writeDataColumn
(
rs
,
i
,
pgType
,
text
);
}
}
sendMessage
();
sendMessage
();
}
}
private
void
writeDataColumn
(
ResultSet
rs
,
int
column
,
int
pgType
)
private
void
writeDataColumn
(
ResultSet
rs
,
int
column
,
int
pgType
,
boolean
text
)
throws
Exception
{
throws
Exception
{
if
(
formatAsText
(
pgType
)
)
{
if
(
text
)
{
// plain text
// plain text
switch
(
pgType
)
{
switch
(
pgType
)
{
case
PgServer
.
PG_TYPE_BOOL
:
case
PgServer
.
PG_TYPE_BOOL
:
...
...
h2/src/test/org/h2/test/unit/TestPgServer.java
浏览文件 @
45fe1a64
...
@@ -369,8 +369,14 @@ public class TestPgServer extends TestBase {
...
@@ -369,8 +369,14 @@ public class TestPgServer extends TestBase {
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"test"
,
"mem:test"
);
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"test"
,
"mem:test"
);
server
.
start
();
server
.
start
();
try
{
try
{
Properties
props
=
new
Properties
();
props
.
setProperty
(
"user"
,
"sa"
);
props
.
setProperty
(
"password"
,
"sa"
);
// force binary
props
.
setProperty
(
"prepareThreshold"
,
"-1"
);
Connection
conn
=
DriverManager
.
getConnection
(
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5535/test"
,
"sa"
,
"sa"
);
"jdbc:postgresql://localhost:5535/test"
,
props
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
stat
.
execute
(
...
@@ -386,7 +392,7 @@ public class TestPgServer extends TestBase {
...
@@ -386,7 +392,7 @@ public class TestPgServer extends TestBase {
ps
.
setLong
(
4
,
1234567890123L
);
ps
.
setLong
(
4
,
1234567890123L
);
ps
.
setDouble
(
5
,
123.456
);
ps
.
setDouble
(
5
,
123.456
);
ps
.
setFloat
(
6
,
123.456f
);
ps
.
setFloat
(
6
,
123.456f
);
ps
.
set
Double
(
7
,
123.456
);
ps
.
set
Float
(
7
,
123.456f
);
ps
.
setBoolean
(
8
,
true
);
ps
.
setBoolean
(
8
,
true
);
ps
.
setByte
(
9
,
(
byte
)
0xfe
);
ps
.
setByte
(
9
,
(
byte
)
0xfe
);
ps
.
setBytes
(
10
,
new
byte
[]
{
'a'
,
(
byte
)
0xfe
,
'\
127
'
});
ps
.
setBytes
(
10
,
new
byte
[]
{
'a'
,
(
byte
)
0xfe
,
'\
127
'
});
...
@@ -400,7 +406,7 @@ public class TestPgServer extends TestBase {
...
@@ -400,7 +406,7 @@ public class TestPgServer extends TestBase {
assertEquals
(
1234567890123L
,
rs
.
getLong
(
4
));
assertEquals
(
1234567890123L
,
rs
.
getLong
(
4
));
assertEquals
(
123.456
,
rs
.
getDouble
(
5
));
assertEquals
(
123.456
,
rs
.
getDouble
(
5
));
assertEquals
(
123.456f
,
rs
.
getFloat
(
6
));
assertEquals
(
123.456f
,
rs
.
getFloat
(
6
));
assertEquals
(
123.456
,
rs
.
getDouble
(
7
));
assertEquals
(
123.456
f
,
rs
.
getFloat
(
7
));
assertEquals
(
true
,
rs
.
getBoolean
(
8
));
assertEquals
(
true
,
rs
.
getBoolean
(
8
));
assertEquals
((
byte
)
0xfe
,
rs
.
getByte
(
9
));
assertEquals
((
byte
)
0xfe
,
rs
.
getByte
(
9
));
assertEquals
(
new
byte
[]
{
'a'
,
(
byte
)
0xfe
,
'\
127
'
},
assertEquals
(
new
byte
[]
{
'a'
,
(
byte
)
0xfe
,
'\
127
'
},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论