View Issue Details

IDProjectCategoryView StatusLast Update
0038981FPCDatabasepublic2021-06-11 17:00
ReporterDarwin O'Connor Assigned ToMichael Van Canneyt  
Status assignedResolutionopen 
Platformx64OSGentoo Linux 
Product Version3.2.0 
Summary0038981: Executing previously prepared statment fails after commiting transactions for PostgreSQL
DescriptionIf you prepare a statement, and then start and commit a unrelated transaction, all the TPQTrans objects are freed, so an exception occurs when the prepared statement is run again.

It's possible I am miss using transactions.
Steps To Reproduce//This test program takes a database name as a parameter. The password may need to be filled in.
program floatparam;

uses sysutils, db, pqconnection, sqldb;

   Conn : TPQConnection;
   trans : TSQLTransaction;
   q : TSQLQuery;

   q.sql.Add('select :i');
   if not trans.Active then trans.starttransaction;
   q.params[0].asinteger:=2;; //EAccessViolation occurs here
TagsNo tags attached.
Fixed in Revision
Attached Files


Michael Van Canneyt

2021-06-11 15:46

administrator   ~0131260

Your transaction is not unrelated.
It's the transaction q is connected to.
But of course it should not cause a crash, it should prepare the query again..

Darwin O'Connor

2021-06-11 17:00

reporter   ~0131261

I was able to fix it by creating a new transaction by adding this to TPQConnection.Execute

if FStatementType in [stInsert,stUpdate,stDelete,stSelect] then
      if tr=nil then begin
         if not aTransaction.Active then aTransaction.StartTransaction;
         TPQTrans(aTransaction.Handle).RegisterCursor(Cursor as TPQCursor);

Issue History

Date Modified Username Field Change
2021-06-10 01:51 Darwin O'Connor New Issue
2021-06-11 15:45 Michael Van Canneyt Assigned To => Michael Van Canneyt
2021-06-11 15:45 Michael Van Canneyt Status new => assigned
2021-06-11 15:46 Michael Van Canneyt Note Added: 0131260
2021-06-11 17:00 Darwin O'Connor Note Added: 0131261