(cherry picked from commit 27f8f077d53b0bcea6111023f23c40b0fa54bcc3)
@@ -987,6 +987,11 @@ begin
begin
PQclear(res);
res:=nil;
+ if ForcedClose then
+ begin
+ FPrepared := False;
+ exit;
+ end;
if FPrepared then
if assigned(tr) and (PQtransactionStatus(tr.PGConn) <> PQTRANS_INERROR) then