Oh, and here's one additional patch to sqldb.pp that improves (ok, ok:
*corrects*) my previous patch. This way FTrans is not freed each time
transaction ends, so properties of FTrans like IsolationLevel are
preserved, e.g. code like
(Transaction.SQLHandle as TIBTrans).IsolationLevel := ilReadCommitted;
Transaction.StartTransaction;
...
Transaction.Commit;
Transaction.StartTransaction;
...
Transaction.Commit;
will create read committed transaction two times.
Michalis.
--- sqldb.pp.2 2005-03-18 13:46:20.640679760 +0100
+++ sqldb.pp 2005-03-18 13:50:49.156859096 +0100
@@ -112,6 +112,10 @@
TSQLTransaction = class (TDBTransaction)
private
+ { FTrans is created if needed in SQLHandle and StartTransaction,
+ and destroyed on Database change and in destructor.
+ The key is that assertion "Active => FTrans is for sure assigned"
+ is satisfied. }
FTrans : TSQLHandle;
FAction : TCommitRollbackAction;
protected
@@ -345,7 +349,6 @@
if (Database as tsqlconnection).commit(FTrans) then
begin
closeTrans;
- FreeAndNil(FTrans);
end;
end;
end;
@@ -364,7 +367,6 @@
if (Database as tsqlconnection).RollBack(FTrans) then
begin
CloseTrans;
- FreeAndNil(FTrans);
end;
end;
end;
@@ -402,6 +404,7 @@
destructor TSQLTransaction.Destroy;
begin
Rollback;
+ FreeAndNil(FTrans);
inherited Destroy;
end;
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel