ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/fbintf/client/3.0/FB30Transaction.pas
(Generate patch)
# Line 48 | Line 48
48    private
49      FTransactionIntf: Firebird.ITransaction;
50      FFirebird30ClientAPI: TFB30ClientAPI;
51    procedure StartMultiple;
51      procedure FreeHandle(Force: boolean);
52    protected
53      function GetActivityIntf(att: IAttachment): IActivityMonitor; override;
54      procedure SetInterface(api: TFBClientAPI); override;
55      function GetTrInfo(ReqBuffer: PByte; ReqBufLen: integer): ITrInformation; override;
56 +    procedure InternalStartSingle(attachment: IAttachment); override;
57 +    procedure InternalStartMultiple; override;
58 +    procedure InternalCommit(Force: boolean); override;
59 +    procedure InternalCommitRetaining; override;
60 +    procedure InternalRollback(Force: boolean); override;
61 +    procedure InternalRollbackRetaining; override;
62    public
63      destructor Destroy; override;
64      property TransactionIntf: Firebird.ITransaction read FTransactionIntf;
65      {ITransaction}
66      function GetInTransaction: boolean; override;
67      procedure PrepareForCommit; override;
63    procedure Commit(Force: boolean=false); override;
64    procedure CommitRetaining; override;
65    procedure Start(DefaultCompletion: TTransactionCompletion=taCommit); overload; override;
66    procedure Rollback(Force: boolean=false); override;
67    procedure RollbackRetaining; override;
68    end;
69  
70  
# Line 74 | Line 74
74  
75   { TFB30Transaction }
76  
77 procedure TFB30Transaction.StartMultiple;
78 var Dtc: IDtc;
79    DtcStart: IDtcStart;
80    i: integer;
81 begin
82  with FFirebird30ClientAPI do
83  begin
84    Dtc := MasterIntf.getDtc;
85    DtcStart := Dtc.startBuilder(StatusIntf);
86    Check4DataBaseError;
87
88    for i := 0 to Length(FAttachments) - 1 do
89    if (FAttachments[i] <> nil)  then
90    begin
91      DTCStart.addWithTpb(StatusIntf,
92                          (FAttachments[i] as TFB30Attachment).AttachmentIntf,
93                          (FTPB as TTPB).getDataLength,
94                          BytePtr((FTPB as TTPB).getBuffer));
95      Check4DataBaseError;
96    end;
97    FTransactionIntf := DtcStart.start(StatusIntf);
98    Check4DataBaseError;
99  end;
100 end;
101
77   procedure TFB30Transaction.FreeHandle(Force: boolean);
78   begin
79    if assigned(FTransactionIntf) then
# Line 134 | Line 109
109    end
110   end;
111  
112 < destructor TFB30Transaction.Destroy;
112 > procedure TFB30Transaction.InternalStartSingle(attachment: IAttachment);
113   begin
114 <  inherited Destroy;
115 <  FreeHandle(true);
116 < end;
117 <
118 < function TFB30Transaction.GetInTransaction: boolean;
119 < begin
120 <  Result := FTransactionIntf <> nil;
114 >  with FFirebird30ClientAPI do
115 >  begin
116 >    FTransactionIntf  := (attachment as TFB30Attachment).AttachmentIntf.startTransaction(StatusIntf,
117 >             (FTPB as TTPB).getDataLength,BytePtr((FTPB as TTPB).getBuffer));
118 >    Check4DataBaseError;
119 >  end;
120 >  SignalActivity;
121   end;
122  
123 < procedure TFB30Transaction.PrepareForCommit;
123 > procedure TFB30Transaction.InternalStartMultiple;
124 > var Dtc: IDtc;
125 >    DtcStart: IDtcStart;
126 >    i: integer;
127   begin
150  if Length(FAttachments) < 2 then
151    IBError(ibxeNotAMultiDatabaseTransaction,[nil]);
152  if FTransactionIntf = nil then
153    Exit;
128    with FFirebird30ClientAPI do
129    begin
130 <    FTransactionIntf.prepare(StatusIntf,0,nil);
130 >    Dtc := MasterIntf.getDtc;
131 >    DtcStart := Dtc.startBuilder(StatusIntf);
132      Check4DataBaseError;
133 +
134 +    for i := 0 to Length(FAttachments) - 1 do
135 +    if (FAttachments[i] <> nil)  then
136 +    begin
137 +      DTCStart.addWithTpb(StatusIntf,
138 +                          (FAttachments[i] as TFB30Attachment).AttachmentIntf,
139 +                          (FTPB as TTPB).getDataLength,
140 +                          BytePtr((FTPB as TTPB).getBuffer));
141 +      Check4DataBaseError;
142 +    end;
143 +
144 +    FTransactionIntf := DtcStart.start(StatusIntf);
145 +    Check4DataBaseError;
146 +    SignalActivity;
147    end;
159  SignalActivity;
148   end;
149  
150 < procedure TFB30Transaction.Commit(Force: boolean);
150 > procedure TFB30Transaction.InternalCommit(Force: boolean);
151   begin
164  if FTransactionIntf = nil then
165    Exit;
152    with FFirebird30ClientAPI do
153    begin
154      FTransactionIntf.commit(StatusIntf);
# Line 173 | Line 159
159    FreeHandle(Force);
160   end;
161  
162 < procedure TFB30Transaction.CommitRetaining;
162 > procedure TFB30Transaction.InternalCommitRetaining;
163   begin
178  if FTransactionIntf = nil then
179    Exit;
164    with FFirebird30ClientAPI do
165    begin
166      FTransactionIntf.commitRetaining(StatusIntf);
# Line 185 | Line 169
169    SignalActivity;
170   end;
171  
172 < procedure TFB30Transaction.Start(DefaultCompletion: TTransactionCompletion);
189 < begin
190 <  if FTransactionIntf <> nil then
191 <    Exit;
192 <  FDefaultCompletion := DefaultCompletion;
193 <
194 <  if Length(FAttachments) = 1 then
195 <    with FFirebird30ClientAPI do
196 <    begin
197 <      FTransactionIntf  := (FAttachments[0] as TFB30Attachment).AttachmentIntf.startTransaction(StatusIntf,
198 <               (FTPB as TTPB).getDataLength,BytePtr((FTPB as TTPB).getBuffer));
199 <      Check4DataBaseError;
200 <    end
201 <  else
202 <    StartMultiple;
203 <  SignalActivity;
204 <  Inc(FSeqNo);
205 < end;
206 <
207 < procedure TFB30Transaction.Rollback(Force: boolean);
172 > procedure TFB30Transaction.InternalRollback(Force: boolean);
173   begin
209  if FTransactionIntf = nil then
210    Exit;
174    with FFirebird30ClientAPI do
175    begin
176      FTransactionIntf.rollback(StatusIntf);
# Line 218 | Line 181
181    FreeHandle(Force);
182   end;
183  
184 < procedure TFB30Transaction.RollbackRetaining;
184 > procedure TFB30Transaction.InternalRollbackRetaining;
185   begin
186 +  with FFirebird30ClientAPI do
187 +  begin
188 +    FTransactionIntf.rollbackRetaining(StatusIntf);
189 +    Check4DataBaseError;
190 +  end;
191 +  SignalActivity;
192 + end;
193 +
194 + destructor TFB30Transaction.Destroy;
195 + begin
196 +  inherited Destroy;
197 +  FreeHandle(true);
198 + end;
199 +
200 + function TFB30Transaction.GetInTransaction: boolean;
201 + begin
202 +  Result := FTransactionIntf <> nil;
203 + end;
204 +
205 + procedure TFB30Transaction.PrepareForCommit;
206 + begin
207 +  if Length(FAttachments) < 2 then
208 +    IBError(ibxeNotAMultiDatabaseTransaction,[nil]);
209    if FTransactionIntf = nil then
210      Exit;
211    with FFirebird30ClientAPI do
212    begin
213 <    FTransactionIntf.rollbackRetaining(StatusIntf);
213 >    FTransactionIntf.prepare(StatusIntf,0,nil);
214      Check4DataBaseError;
215    end;
216    SignalActivity;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines