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;
constBufSize=256;
varCancel:PPGCancel; {actually Pointer}lpszErrBuf:PAnsiChar;
beginResult:=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;