* Fix cursor mem leak

git-svn-id: trunk@24732 -
This commit is contained in:
michael 2013-06-01 17:07:52 +00:00
parent f985149163
commit 678fb02f11

View File

@ -225,7 +225,6 @@ type
FTransaction: TSQLTransaction; FTransaction: TSQLTransaction;
FDatasource : TDatasource; FDatasource : TDatasource;
FParseSQL: Boolean; FParseSQL: Boolean;
procedure DoUnPrepare;
procedure OnChangeSQL(Sender : TObject); procedure OnChangeSQL(Sender : TObject);
procedure SetDatabase(AValue: TSQLConnection); procedure SetDatabase(AValue: TSQLConnection);
procedure SetDataSource(AValue: TDatasource); procedure SetDataSource(AValue: TDatasource);
@ -238,6 +237,7 @@ type
Function IsSelectable : Boolean ; virtual; Function IsSelectable : Boolean ; virtual;
Procedure DoExecute; virtual; Procedure DoExecute; virtual;
procedure DoPrepare; virtual; procedure DoPrepare; virtual;
procedure DoUnPrepare; virtual;
Function CreateParams : TParams; virtual; Function CreateParams : TParams; virtual;
Function LogEvent(EventType : TDBEventType) : Boolean; Function LogEvent(EventType : TDBEventType) : Boolean;
Procedure Log(EventType : TDBEventType; Const Msg : String); virtual; Procedure Log(EventType : TDBEventType; Const Msg : String); virtual;
@ -644,7 +644,6 @@ procedure TCustomSQLStatement.SetDatabase(AValue: TSQLConnection);
begin begin
if FDatabase=AValue then Exit; if FDatabase=AValue then Exit;
UnPrepare; UnPrepare;
if assigned(FCursor) then TSQLConnection(DataBase).DeAllocateCursorHandle(FCursor);
If Assigned(FDatabase) then If Assigned(FDatabase) then
FDatabase.RemoveFreeNotification(Self); FDatabase.RemoveFreeNotification(Self);
FDatabase:=AValue; FDatabase:=AValue;
@ -825,8 +824,14 @@ end;
procedure TCustomSQLStatement.DoUnPrepare; procedure TCustomSQLStatement.DoUnPrepare;
begin begin
If Assigned(Database) then If Assigned(FCursor) then
DataBase.UnPrepareStatement(FCursor); If Assigned(Database) then
begin
DataBase.UnPrepareStatement(FCursor);
DataBase.DeAllocateCursorHandle(FCursor);
end
else // this should never happen. It means a cursor handle leaks in the DB itself.
FreeAndNil(FCursor);
end; end;
procedure TCustomSQLStatement.Unprepare; procedure TCustomSQLStatement.Unprepare;