ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBAttachment.pas
(Generate patch)

Comparing ibx/branches/udr/client/FBAttachment.pas (file contents):
Revision 375 by tony, Sun Jan 9 23:42:58 2022 UTC vs.
Revision 389 by tony, Thu Jan 20 23:33:40 2022 UTC

# Line 96 | Line 96 | type
96      const sQueryJournal          = '*Q:''%s'',%d,%d,%d,%d:%s' + LineEnding;
97      const sTransStartJnl         = '*S:''%s'',%d,%d,%d,%d:%s,%d:%s,%d' + LineEnding;
98      const sTransCommitJnl        = '*C:''%s'',%d,%d,%d' + LineEnding;
99 +    const sTransCommitFailJnl    = '*F:''%s'',%d,%d,%d' + LineEnding;
100      const sTransCommitRetJnl     = '*c:''%s'',%d,%d,%d,%d' + LineEnding;
101      const sTransRollBackJnl      = '*R:''%s'',%d,%d,%d' + LineEnding;
102 +    const sTransRollBackFailJnl  = '*f:''%s'',%d,%d,%d' + LineEnding;
103      const sTransRollBackRetJnl   = '*r:''%s'',%d,%d,%d,%d' + LineEnding;
104    private
105      FOptions: TJournalOptions;
# Line 115 | Line 117 | type
117    public
118      {IJournallingHook}
119      procedure TransactionStart(Tr: ITransaction);
120 <    function TransactionEnd( TransactionID: integer; Action: TTransactionAction): boolean;
120 >    function TransactionEnd( TransactionID: integer; Completion: TTrCompletionState): boolean;
121      procedure TransactionRetained(Tr: ITransaction; OldTransactionID: integer;
122        Action: TTransactionAction);
123      procedure ExecQuery(Stmt: IStatement);
124 +    procedure ExecImmediateJnl(sql: AnsiString; tr: ITransaction);
125    public
126      {Client side Journaling}
127      function JournalingActive: boolean;
# Line 483 | Line 486 | const
486      'process_name',
487      'trusted_role',
488      'org_filename',
489 <    'utf8_ilename',
489 >    'utf8_filename',
490      'ext_call_depth',
491      'auth_block',
492      'client_version',
# Line 647 | Line 650 | procedure TFBJournaling.TransactionStart
650   var LogEntry: AnsiString;
651      TPBText: AnsiString;
652   begin
650  FDoNotJournal := true;
653    if not (joNoServerTable in FOptions) then
654    try
655 +    FDoNotJournal := true;
656      GetAttachment.ExecuteSQL(Tr,sqlRecordJournalEntry,[FSessionID,Tr.GetTransactionID,NULL]);
657    finally
658      FDoNotJournal := false;
# Line 668 | Line 671 | begin
671   end;
672  
673   function TFBJournaling.TransactionEnd(TransactionID: integer;
674 <  Action: TTransactionAction): boolean;
674 >  Completion: TTrCompletionState): boolean;
675  
676   var LogEntry: AnsiString;
677   begin
678    Result := false;
679 <    case Action of
680 <    TARollback:
679 >    case Completion of
680 >    trRolledback:
681        begin
682          LogEntry := Format(sTransRollbackJnl,[FBFormatDateTime(GetDateTimeFmt,Now),
683                                                GetAttachment.GetAttachmentID,
684                                                FSessionID,TransactionID]);
685          Result := true;
686        end;
687 <    TACommit:
687 >
688 >    trRollbackFailed:
689 >      begin
690 >        LogEntry := Format(sTransRollbackFailJnl,[FBFormatDateTime(GetDateTimeFmt,Now),
691 >                                              GetAttachment.GetAttachmentID,
692 >                                              FSessionID,TransactionID]);
693 >        Result := true;
694 >      end;
695 >
696 >    trCommitted:
697        begin
698          LogEntry := Format(sTransCommitJnl,[FBFormatDateTime(GetDateTimeFmt,Now),
699                                              GetAttachment.GetAttachmentID,
700                                              FSessionID,TransactionID]);
701          Result := true;
702        end;
703 +
704 +    trCommitFailed:
705 +      begin
706 +        LogEntry := Format(sTransCommitFailJnl,[FBFormatDateTime(GetDateTimeFmt,Now),
707 +                                            GetAttachment.GetAttachmentID,
708 +                                            FSessionID,TransactionID]);
709 +        Result := true;
710 +      end;
711      end;
712      if assigned(FJournalFileStream) then
713        FJournalFileStream.Write(LogEntry[1],Length(LogEntry));
# Line 710 | Line 730 | begin
730      if assigned(FJournalFileStream) then
731        FJournalFileStream.Write(LogEntry[1],Length(LogEntry));
732  
713    FDoNotJournal := true;
733      if not (joNoServerTable in FOptions) then
734      try
735 +      FDoNotJournal := true;
736        GetAttachment.ExecuteSQL(Tr,sqlRecordJournalEntry,[FSessionID,Tr.GetTransactionID,OldTransactionID]);
737      finally
738        FDoNotJournal := false;
# Line 733 | Line 753 | begin
753      FJournalFileStream.Write(LogEntry[1],Length(LogEntry));
754   end;
755  
756 + procedure TFBJournaling.ExecImmediateJnl(sql: AnsiString; tr: ITransaction);
757 + var LogEntry: AnsiString;
758 + begin
759 +  LogEntry := Format(sQueryJournal,[FBFormatDateTime(GetDateTimeFmt,Now),
760 +                                      GetAttachment.GetAttachmentID,
761 +                                      FSessionID,
762 +                                      tr.GetTransactionID,
763 +                                      Length(sql),sql]);
764 +  if assigned(FJournalFileStream) then
765 +    FJournalFileStream.Write(LogEntry[1],Length(LogEntry));
766 + end;
767 +
768   function TFBJournaling.JournalingActive: boolean;
769   begin
770    Result := (FJournalFileStream <> nil) and not FDoNotJournal;
# Line 1062 | Line 1094 | end;
1094  
1095   procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: AnsiString;
1096    aSQLDialect: integer);
1097 + var tr: ITransaction;
1098   begin
1099 <  ExecImmediate(StartTransaction(TPB,taCommit),sql,aSQLDialect);
1099 >  tr := StartTransaction(TPB,taCommit);
1100 >  try
1101 >    ExecImmediate(tr,sql,aSQLDialect);
1102 >    tr.Commit;
1103 >  except
1104 >    tr.Rollback(true);
1105 >    raise;
1106 >  end;
1107   end;
1108  
1109   procedure TFBAttachment.ExecImmediate(transaction: ITransaction; sql: AnsiString);
# Line 1073 | Line 1113 | end;
1113  
1114   procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: AnsiString);
1115   begin
1116 <  ExecImmediate(StartTransaction(TPB,taCommit),sql,FSQLDialect);
1116 >  ExecImmediate(TPB,sql,FSQLDialect);
1117   end;
1118  
1119   function TFBAttachment.ExecuteSQL(TPB: array of byte; sql: AnsiString;
1120    SQLDialect: integer; params: array of const): IResults;
1121 + var tr: ITransaction;
1122   begin
1123 <  Result := ExecuteSQL(StartTransaction(TPB,taCommit),sql,SQLDialect,params);
1123 >  tr := StartTransaction(TPB,taCommit);
1124 >  try
1125 >    Result := ExecuteSQL(tr,sql,SQLDialect,params);
1126 >  except
1127 >    tr.Rollback(true);
1128 >    raise;
1129 >  end;
1130   end;
1131  
1132   function TFBAttachment.ExecuteSQL(transaction: ITransaction; sql: AnsiString;
# Line 1095 | Line 1142 | end;
1142   function TFBAttachment.ExecuteSQL(TPB: array of byte; sql: AnsiString;
1143    params: array of const): IResults;
1144   begin
1145 <   Result := ExecuteSQL(StartTransaction(TPB,taCommit),sql,params);
1145 >   Result := ExecuteSQL(TPB,sql,FSQLDialect,params);
1146   end;
1147  
1148   function TFBAttachment.ExecuteSQL(transaction: ITransaction; sql: AnsiString;
1149    params: array of const): IResults;
1150   begin
1151 <  with Prepare(transaction,sql,FSQLDialect) do
1105 <  begin
1106 <    SetParameters(SQLParams,params);
1107 <    Result := Execute;
1108 <  end;
1151 >  Result := ExecuteSQL(transaction,sql,FSQLDialect,params);
1152   end;
1153  
1154   function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString;
# Line 1198 | Line 1241 | end;
1241  
1242   function TFBAttachment.OpenCursorAtStart(sql: AnsiString; Scrollable: boolean;
1243    params: array of const): IResultSet;
1244 + var tr: ITransaction;
1245   begin
1246 <  Result := OpenCursorAtStart(StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit),sql,FSQLDialect,
1247 <                   Scrollable,params);
1246 >  tr := StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit);
1247 >  try
1248 >    Result := OpenCursorAtStart(tr,sql,FSQLDialect,Scrollable,params);
1249 >  except
1250 >    tr.Rollback(true);
1251 >    raise;
1252 >  end;
1253   end;
1254  
1255   function TFBAttachment.OpenCursorAtStart(sql: AnsiString;
1256    params: array of const): IResultSet;
1257   begin
1258 <  Result := OpenCursorAtStart(StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit),sql,FSQLDialect,
1210 <                   false,params);
1258 >  Result := OpenCursorAtStart(sql,false,params);
1259   end;
1260  
1261   function TFBAttachment.Prepare(transaction: ITransaction; sql: AnsiString;

Comparing ibx/branches/udr/client/FBAttachment.pas (property svn:eol-style):
Revision 375 by tony, Sun Jan 9 23:42:58 2022 UTC vs.
Revision 389 by tony, Thu Jan 20 23:33:40 2022 UTC

# Line 0 | Line 1
1 + native

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines