PQcancel hangs

From: "Ender" <fionik(at)gmail(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: PQcancel hangs
Date: 2007-07-19 11:01:29
Message-ID: f7ng9m$168f$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi, all.

I'm trying to cancel query that i'm executing. In the first thread i'm
execute query through PQexec function. Then i'm trying to break it's
execution. From the second thread i'm execute PQgetCancel, PQcancel,
PQfreeCancel. The execution of PQexec get interrupted, however PQcancel
never return control to program.

The execution of PQexec in the first thread get interrupted, however in the
second thread no code executed beyond this line:

Result:=ZPlainPostgreSql8.PQCancel(Cancel,lpszErrBuf,BufSize)=1;

PQCancel never return control to caller. Is it supposed to work at all?

Code sample (Delphi - ZeosDBO):

function TZPostgreSQL8PlainDriver.RequestCancelEx(Handle:
PZPostgreSQLConnect;
out ErrorMessage: String): Boolean;
const
BufSize=256;
var
Cancel:PPGCancel; {actually Pointer}
lpszErrBuf:PAnsiChar;
begin
Result:=FALSE;
ErrorMessage:='';
Cancel:=ZPlainPostgreSql8.PQgetCancel(Handle);
if Cancel=NIL then Exit;
try
lpszErrBuf:=StrAlloc(BufSize);
try
FillChar(lpszErrBuf^,BufSize,0);
Result:=ZPlainPostgreSql8.PQCancel(Cancel,lpszErrBuf,BufSize)=1;
if not Result then
ErrorMessage:=StrPas(lpszErrBuf);
finally
StrDispose(lpszErrBuf);
end;
finally
ZPlainPostgreSql8.PQfreeCancel(Cancel);
end;
end;

Browse pgsql-interfaces by date

  From Date Subject
Next Message JLT 2007-07-27 19:49:02 postgresql-tcl
Previous Message Koen Vermeer 2007-07-12 15:52:50 libpq: Specify pass phrase for SSL key