Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e9e0d9bc
提交
e9e0d9bc
authored
14 年前
作者:
Sergi Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Memory leak fixed in PgServerThread (Prepared and Portal object were never deleted from connection)
上级
086f526f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
35 行增加
和
16 行删除
+35
-16
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+35
-16
没有找到文件。
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
e9e0d9bc
...
@@ -229,11 +229,10 @@ public class PgServerThread implements Runnable {
...
@@ -229,11 +229,10 @@ public class PgServerThread implements Runnable {
String
prepName
=
readString
();
String
prepName
=
readString
();
Prepared
prep
=
prepared
.
get
(
prepName
);
Prepared
prep
=
prepared
.
get
(
prepName
);
if
(
prep
==
null
)
{
if
(
prep
==
null
)
{
sendErrorResponse
(
"P
ortal
not found"
);
sendErrorResponse
(
"P
repared
not found"
);
break
;
break
;
}
}
portal
.
sql
=
prep
.
sql
;
portal
.
prep
=
prep
;
portal
.
prep
=
prep
.
prep
;
portals
.
put
(
portal
.
name
,
portal
);
portals
.
put
(
portal
.
name
,
portal
);
int
formatCodeCount
=
readShort
();
int
formatCodeCount
=
readShort
();
int
[]
formatCodes
=
new
int
[
formatCodeCount
];
int
[]
formatCodes
=
new
int
[
formatCodeCount
];
...
@@ -246,7 +245,7 @@ public class PgServerThread implements Runnable {
...
@@ -246,7 +245,7 @@ public class PgServerThread implements Runnable {
byte
[]
d2
=
Utils
.
newBytes
(
paramLen
);
byte
[]
d2
=
Utils
.
newBytes
(
paramLen
);
readFully
(
d2
);
readFully
(
d2
);
try
{
try
{
setParameter
(
p
ortal
.
prep
,
i
,
d2
,
formatCodes
);
setParameter
(
p
rep
.
prep
,
i
,
d2
,
formatCodes
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
sendErrorResponse
(
e
);
sendErrorResponse
(
e
);
}
}
...
@@ -259,6 +258,25 @@ public class PgServerThread implements Runnable {
...
@@ -259,6 +258,25 @@ public class PgServerThread implements Runnable {
sendBindComplete
();
sendBindComplete
();
break
;
break
;
}
}
case
'C'
:
{
char
type
=
(
char
)
readByte
();
String
name
=
readString
();
server
.
trace
(
"Close"
);
if
(
type
==
'S'
)
{
Prepared
p
=
prepared
.
remove
(
name
);
if
(
p
!=
null
)
{
JdbcUtils
.
closeSilently
(
p
.
prep
);
}
}
else
if
(
type
==
'P'
)
{
portals
.
remove
(
name
);
}
else
{
server
.
trace
(
"expected S or P, got "
+
type
);
sendErrorResponse
(
"expected S or P"
);
break
;
}
sendCloseComplete
();
break
;
}
case
'D'
:
{
case
'D'
:
{
char
type
=
(
char
)
readByte
();
char
type
=
(
char
)
readByte
();
String
name
=
readString
();
String
name
=
readString
();
...
@@ -275,7 +293,7 @@ public class PgServerThread implements Runnable {
...
@@ -275,7 +293,7 @@ public class PgServerThread implements Runnable {
if
(
p
==
null
)
{
if
(
p
==
null
)
{
sendErrorResponse
(
"Portal not found: "
+
name
);
sendErrorResponse
(
"Portal not found: "
+
name
);
}
else
{
}
else
{
PreparedStatement
prep
=
p
.
prep
;
PreparedStatement
prep
=
p
.
prep
.
prep
;
try
{
try
{
ResultSetMetaData
meta
=
prep
.
getMetaData
();
ResultSetMetaData
meta
=
prep
.
getMetaData
();
sendRowDescription
(
meta
);
sendRowDescription
(
meta
);
...
@@ -298,8 +316,9 @@ public class PgServerThread implements Runnable {
...
@@ -298,8 +316,9 @@ public class PgServerThread implements Runnable {
break
;
break
;
}
}
int
maxRows
=
readShort
();
int
maxRows
=
readShort
();
PreparedStatement
prep
=
p
.
prep
;
Prepared
prepared
=
p
.
prep
;
server
.
trace
(
p
.
sql
);
PreparedStatement
prep
=
prepared
.
prep
;
server
.
trace
(
prepared
.
sql
);
try
{
try
{
prep
.
setMaxRows
(
maxRows
);
prep
.
setMaxRows
(
maxRows
);
boolean
result
=
prep
.
execute
();
boolean
result
=
prep
.
execute
();
...
@@ -311,12 +330,12 @@ public class PgServerThread implements Runnable {
...
@@ -311,12 +330,12 @@ public class PgServerThread implements Runnable {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
sendDataRow
(
rs
);
sendDataRow
(
rs
);
}
}
sendCommandComplete
(
p
.
sql
,
0
);
sendCommandComplete
(
p
repared
.
sql
,
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
sendErrorResponse
(
e
);
sendErrorResponse
(
e
);
}
}
}
else
{
}
else
{
sendCommandComplete
(
p
.
sql
,
prep
.
getUpdateCount
());
sendCommandComplete
(
p
repared
.
sql
,
prep
.
getUpdateCount
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
sendErrorResponse
(
e
);
sendErrorResponse
(
e
);
...
@@ -586,6 +605,11 @@ public class PgServerThread implements Runnable {
...
@@ -586,6 +605,11 @@ public class PgServerThread implements Runnable {
sendMessage
();
sendMessage
();
}
}
private
void
sendCloseComplete
()
throws
IOException
{
startMessage
(
'3'
);
sendMessage
();
}
private
void
initDb
()
throws
SQLException
{
private
void
initDb
()
throws
SQLException
{
Statement
stat
=
null
;
Statement
stat
=
null
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
...
@@ -807,20 +831,15 @@ public class PgServerThread implements Runnable {
...
@@ -807,20 +831,15 @@ public class PgServerThread implements Runnable {
*/
*/
String
name
;
String
name
;
/**
* The SQL statement.
*/
String
sql
;
/**
/**
* The format used in the result set columns (if set).
* The format used in the result set columns (if set).
*/
*/
int
[]
resultColumnFormat
;
int
[]
resultColumnFormat
;
/**
/**
* The prepared
statemen
t.
* The prepared
objec
t.
*/
*/
Prepared
Statement
prep
;
Prepared
prep
;
}
}
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论