- some fixes in assignment of transactions and databases

This commit is contained in:
joost 2005-04-24 19:21:28 +00:00
parent 8884d2e079
commit ce319c62c2
4 changed files with 38 additions and 20 deletions

View File

@ -250,9 +250,9 @@ end;
Procedure TDBDataset.SetDatabase (Value : TDatabase); Procedure TDBDataset.SetDatabase (Value : TDatabase);
begin begin
CheckInactive;
If Value<>FDatabase then If Value<>FDatabase then
begin begin
CheckInactive;
If Assigned(FDatabase) then If Assigned(FDatabase) then
FDatabase.UnregisterDataset(Self); FDatabase.UnregisterDataset(Self);
If Value<>Nil Then If Value<>Nil Then
@ -344,9 +344,9 @@ end;
Procedure TDBTransaction.SetDatabase (Value : TDatabase); Procedure TDBTransaction.SetDatabase (Value : TDatabase);
begin begin
CheckInactive;
If Value<>FDatabase then If Value<>FDatabase then
begin begin
CheckInactive;
If Assigned(FDatabase) then If Assigned(FDatabase) then
FDatabase.UnregisterTransaction(Self); FDatabase.UnregisterTransaction(Self);
If Value<>Nil Then If Value<>Nil Then
@ -444,7 +444,10 @@ end;
{ {
$Log$ $Log$
Revision 1.10 2005-02-14 17:13:12 peter Revision 1.11 2005-04-24 19:21:28 joost
- some fixes in assignment of transactions and databases
Revision 1.10 2005/02/14 17:13:12 peter
* truncate log * truncate log
} }

View File

@ -1284,7 +1284,6 @@ type
FDatabase : TDatabase; FDatabase : TDatabase;
FDataSets : TList; FDataSets : TList;
FOpenAfterRead : boolean; FOpenAfterRead : boolean;
Procedure SetDatabase (Value : TDatabase);
Function GetDataSetCount : Longint; Function GetDataSetCount : Longint;
Function GetDataset(Index : longint) : TDBDataset; Function GetDataset(Index : longint) : TDBDataset;
procedure RegisterDataset (DS : TDBDataset); procedure RegisterDataset (DS : TDBDataset);
@ -1292,6 +1291,7 @@ type
procedure RemoveDataSets; procedure RemoveDataSets;
procedure SetActive(Value : boolean); procedure SetActive(Value : boolean);
Protected Protected
Procedure SetDatabase (Value : TDatabase); virtual;
procedure CloseTrans; procedure CloseTrans;
procedure openTrans; procedure openTrans;
Procedure CheckDatabase; Procedure CheckDatabase;
@ -1909,7 +1909,10 @@ end.
{ {
$Log$ $Log$
Revision 1.47 2005-04-13 22:09:15 joost Revision 1.48 2005-04-24 19:21:28 joost
- some fixes in assignment of transactions and databases
Revision 1.47 2005/04/13 22:09:15 joost
- TIndexDefs.Destroy now calls inhedited.Destroy - TIndexDefs.Destroy now calls inhedited.Destroy
Revision 1.46 2005/04/10 22:18:43 joost Revision 1.46 2005/04/10 22:18:43 joost

View File

@ -909,6 +909,9 @@ begin
if not field.getData(@blobId) then if not field.getData(@blobId) then
exit; exit;
if not assigned(Transaction) then
DatabaseError(SErrConnTransactionnSet);
TransactionHandle := transaction.Handle; TransactionHandle := transaction.Handle;
blobHandle := nil; blobHandle := nil;

View File

@ -130,6 +130,7 @@ type
FAction : TCommitRollbackAction; FAction : TCommitRollbackAction;
protected protected
function GetHandle : Pointer; virtual; function GetHandle : Pointer; virtual;
Procedure SetDatabase (Value : TDatabase); override;
public public
procedure Commit; virtual; procedure Commit; virtual;
procedure CommitRetaining; virtual; procedure CommitRetaining; virtual;
@ -260,22 +261,14 @@ end;
procedure TSQLConnection.SetTransaction(Value : TSQLTransaction); procedure TSQLConnection.SetTransaction(Value : TSQLTransaction);
begin begin
if FTransaction = nil then if FTransaction<>value then
begin
FTransaction := Value;
if Assigned(FTransaction) then
FTransaction.Database := Self;
exit;
end;
if (Value <> FTransaction) and (Value <> nil) then
if (not FTransaction.Active) then
begin begin
FTransaction := Value; if Assigned(FTransaction) and FTransaction.Active then
FTransaction.Database := Self;
end
else
DatabaseError(SErrAssTransaction); DatabaseError(SErrAssTransaction);
if Assigned(Value) then
Value.Database := Self;
FTransaction := Value;
end;
end; end;
procedure TSQLConnection.UpdateIndexDefs(var IndexDefs : TIndexDefs;TableName : string); procedure TSQLConnection.UpdateIndexDefs(var IndexDefs : TIndexDefs;TableName : string);
@ -448,6 +441,19 @@ begin
inherited Destroy; inherited Destroy;
end; end;
Procedure TSQLTransaction.SetDatabase(Value : TDatabase);
begin
If Value<>Database then
begin
CheckInactive;
If Assigned(Database) then
with Database as TSqlConnection do
if Transaction = self then Transaction := nil;
inherited SetDatabase(Value);
end;
end;
{ TSQLQuery } { TSQLQuery }
procedure TSQLQuery.OnChangeSQL(Sender : TObject); procedure TSQLQuery.OnChangeSQL(Sender : TObject);
@ -973,7 +979,10 @@ end.
{ {
$Log$ $Log$
Revision 1.17 2005-04-13 22:10:26 joost Revision 1.18 2005-04-24 19:21:28 joost
- some fixes in assignment of transactions and databases
Revision 1.17 2005/04/13 22:10:26 joost
- TSQLQuery now frees FIndexDefs - TSQLQuery now frees FIndexDefs
Revision 1.16 2005/04/10 18:29:26 joost Revision 1.16 2005/04/10 18:29:26 joost