--- ibx/branches/journaling/fbintf/client/2.5/FB25Transaction.pas 2021/12/07 13:27:39 362 +++ ibx/branches/journaling/fbintf/client/2.5/FB25Transaction.pas 2021/12/07 13:30:05 363 @@ -87,6 +87,12 @@ type function GetActivityIntf(att: IAttachment): IActivityMonitor; override; function GetTrInfo(ReqBuffer: PByte; ReqBufLen: integer): ITrInformation; override; procedure SetInterface(api: TFBClientAPI); override; + procedure InternalStartSingle(attachment: IAttachment); override; + procedure InternalStartMultiple; override; + procedure InternalCommit(Force: boolean); override; + procedure InternalRollback(Force: boolean); override; + procedure InternalCommitRetaining; override; + procedure InternalRollbackRetaining; override; public property Handle: TISC_TR_HANDLE read FHandle; @@ -94,11 +100,6 @@ type {ITransaction} function GetInTransaction: boolean; override; procedure PrepareForCommit; override; - procedure Commit(Force: boolean=false); override; - procedure CommitRetaining; override; - procedure Start(DefaultCompletion: TTransactionCompletion=taCommit); overload; override; - procedure Rollback(Force: boolean=false); override; - procedure RollbackRetaining; override; end; implementation @@ -129,58 +130,26 @@ begin OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError; end; -function TFB25Transaction.GetInTransaction: boolean; -begin - Result := FHandle <> nil; -end; - -procedure TFB25Transaction.PrepareForCommit; -begin - if Length(FAttachments) < 2 then - IBError(ibxeNotAMultiDatabaseTransaction,[nil]); - if FHandle = nil then - Exit; - with FFirebird25ClientAPI do - Call(isc_prepare_transaction(StatusVector, @FHandle)); -end; - -procedure TFB25Transaction.Commit(Force: boolean); +procedure TFB25Transaction.InternalStartSingle(attachment: IAttachment); +var db_handle: TISC_DB_HANDLE; begin - if FHandle = nil then - Exit; with FFirebird25ClientAPI do - Call(isc_commit_transaction(StatusVector, @FHandle),not Force); - FHandle := nil; -end; - -procedure TFB25Transaction.CommitRetaining; -begin - if FHandle = nil then - Exit; - with FFirebird25ClientAPI do - Call(isc_commit_retaining(StatusVector, @FHandle)); -end; - -procedure TFB25Transaction.Start(DefaultCompletion: TTransactionCompletion); -var pteb: PISC_TEB_ARRAY; - i: integer; - db_handle: TISC_DB_HANDLE; -begin - if FHandle <> nil then - Exit; - pteb := nil; - FDefaultCompletion := DefaultCompletion; - with FFirebird25ClientAPI do - if (Length(FAttachments) = 1) then try - db_handle := (FAttachments[0] as TFB25Attachment).Handle; + db_handle := (attachment as TFB25Attachment).Handle; Call(isc_start_transaction(StatusVector, @FHandle,1, @db_handle,(FTPB as TTPB).getDataLength,(FTPB as TTPB).getBuffer)); except FHandle := nil; raise; end - else +end; + +procedure TFB25Transaction.InternalStartMultiple; +var pteb: PISC_TEB_ARRAY; + i: integer; +begin + pteb := nil; + with FFirebird25ClientAPI do begin IBAlloc(pteb, 0, Length(FAttachments) * SizeOf(TISC_TEB)); try @@ -191,6 +160,7 @@ begin pteb^[i].tpb_length := (FTPB as TTPB).getDataLength; pteb^[i].tpb_address := (FTPB as TTPB).getBuffer; end; + try Call(isc_start_multiple(StatusVector, @FHandle, Length(FAttachments), PISC_TEB(pteb))); @@ -202,24 +172,47 @@ begin FreeMem(pteb); end; end; - Inc(FSeqNo); end; -procedure TFB25Transaction.Rollback(Force: boolean); +procedure TFB25Transaction.InternalCommit(Force: boolean); +begin + with FFirebird25ClientAPI do + Call(isc_commit_transaction(StatusVector, @FHandle),not Force); + FHandle := nil; +end; + +procedure TFB25Transaction.InternalRollback(Force: boolean); begin - if FHandle = nil then - Exit; with FFirebird25ClientAPI do Call(isc_rollback_transaction(StatusVector, @FHandle),not Force); FHandle := nil; end; -procedure TFB25Transaction.RollbackRetaining; +procedure TFB25Transaction.InternalCommitRetaining; begin + with FFirebird25ClientAPI do + Call(isc_commit_retaining(StatusVector, @FHandle)); +end; + +procedure TFB25Transaction.InternalRollbackRetaining; +begin + with FFirebird25ClientAPI do + Call(isc_rollback_retaining(StatusVector, @FHandle)); +end; + +function TFB25Transaction.GetInTransaction: boolean; +begin + Result := FHandle <> nil; +end; + +procedure TFB25Transaction.PrepareForCommit; +begin + if Length(FAttachments) < 2 then + IBError(ibxeNotAMultiDatabaseTransaction,[nil]); if FHandle = nil then Exit; with FFirebird25ClientAPI do - Call(isc_rollback_retaining(StatusVector, @FHandle)); + Call(isc_prepare_transaction(StatusVector, @FHandle)); end; end.