Browse Source

fcl-db: postgresql: Fix AV in UnprepareStatement (TPQCursor.tr is nil).
Revealed by TTestTSQLQuery.TestKeepOpenOnCommit.
Commit destroys TPQTrans object, which in destructor sets tr:=nil for all registered cursors. So attempt to Close TSQLQuery after Commit has leading to AV.

git-svn-id: trunk@29507 -

lacak 10 years ago
parent
commit
d8ce1caea3
1 changed files with 1 additions and 1 deletions
  1. 1 1
      packages/fcl-db/src/sqldb/postgres/pqconnection.pp

+ 1 - 1
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -953,7 +953,7 @@ begin
     res:=nil;
     res:=nil;
     if FPrepared then
     if FPrepared then
       begin
       begin
-      if PQtransactionStatus(tr.PGConn) <> PQTRANS_INERROR then
+      if assigned(tr) and (PQtransactionStatus(tr.PGConn) <> PQTRANS_INERROR) then
         begin
         begin
         res := PQexec(tr.PGConn,pchar('deallocate '+StmtName));
         res := PQexec(tr.PGConn,pchar('deallocate '+StmtName));
         CheckResultError(res,nil,SErrUnPrepareFailed);
         CheckResultError(res,nil,SErrUnPrepareFailed);