提交 e948c80e authored 作者: noelgrandin's avatar noelgrandin

Issue 480: Bugfix post issue #475, #477, patch from Andrew Franklin.

上级 1196666c
......@@ -43,6 +43,7 @@ Change Log
</li><li>Issue 472: PgServer does not work with any recent Postgres JDBC driver, patch from Andrew Franklin.
</li><li>Add syntax for passing additional parameters into custom TableEngine implementations.
</li><li>Add support for spatial datatype GEOMETRY.
</li><li>Issue 480: Bugfix post issue #475, #477, patch from Andrew Franklin.
</li></ul>
<h2>Version 1.3.172 (2013-05-25)</h2>
......
......@@ -152,10 +152,13 @@ public class PgServerThread implements Runnable {
int pid = readInt();
int key = readInt();
PgServerThread c = server.getThread(pid);
if (c != null) {
c.cancelRequest(key);
if (c != null && key == c.secret) {
c.cancelRequest();
} else {
sendErrorResponse("unknown process: " + pid);
// 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);
}
close();
} else if (version == 80877103) {
......@@ -550,7 +553,7 @@ public class PgServerThread implements Runnable {
int col = i + 1;
int paramLen = readInt();
if (paramLen == -1) {
prep.setNull(i, Types.NULL);
prep.setNull(col, Types.NULL);
} else if (text) {
// plain text
byte[] data = DataUtils.newBytes(paramLen);
......@@ -958,14 +961,9 @@ public class PgServerThread implements Runnable {
/**
* Kill a currently running query on this thread.
* @param secret the private key of the command
*/
private synchronized void cancelRequest(int secret) throws IOException {
private synchronized void cancelRequest() {
if (activeRequest != null) {
if (secret != this.secret) {
sendErrorResponse("invalid cancel secret");
return;
}
try {
activeRequest.cancel();
activeRequest = null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论