720 |
|
property OnProgressEvent: TOnProgressEvent read FOnProgressEvent write FOnProgressEvent; {Progress Bar Support} |
721 |
|
end; |
722 |
|
|
723 |
< |
TJnlEntryType = (jeTransStart, jeTransCommit, jeTransCommitRet, jeTransRollback, |
724 |
< |
jeTransRollbackRet, jeTransEnd, jeQuery,jeUnknown); |
723 |
> |
TJnlEntryType = (jeTransStart, jeTransCommit, jeTransCommitFail, jeTransCommitRet, jeTransRollback, |
724 |
> |
jeTransRollbackFail, jeTransRollbackRet, jeTransEnd, jeQuery,jeUnknown); |
725 |
|
|
726 |
|
TJnlEntry = record |
727 |
|
JnlEntryType: TJnlEntryType; |
728 |
|
Timestamp: TDateTime; |
729 |
< |
SessionID: integer; |
730 |
< |
TransactionID: integer; |
731 |
< |
OldTransactionID: integer; |
729 |
> |
AttachmentID: cardinal; |
730 |
> |
SessionID: cardinal; |
731 |
> |
TransactionID: cardinal; |
732 |
> |
OldTransactionID: cardinal; |
733 |
|
TransactionName: AnsiString; |
734 |
|
TPB: ITPB; |
735 |
|
DefaultCompletion: TTransactionCompletion; |
742 |
|
|
743 |
|
TJournalProcessor = class(TSQLTokeniser) |
744 |
|
private |
745 |
< |
type TLineState = (lsInit, lsJnlFound, lsGotTimestamp, lsGotJnlType, lsGotSessionID, |
745 |
> |
type TLineState = (lsInit, lsJnlFound, lsGotTimestamp, lsGotJnlType, |
746 |
> |
lsGotAttachmentID, lsGotSessionID, |
747 |
|
lsGotTransactionID, lsGotOldTransactionID, lsGotText1Length, |
748 |
|
lsGotText1, lsGotText2Length, lsGotText2); |
749 |
|
private |
795 |
|
function FormatTimeZoneOffset(EffectiveTimeOffsetMins: integer): AnsiString; |
796 |
|
function DecodeTimeZoneOffset(TZOffset: AnsiString; var dstOffset: integer): boolean; |
797 |
|
function StripLeadingZeros(Value: AnsiString): AnsiString; |
796 |
– |
function TryStrToNumeric(S: Ansistring; out Value: int64; out scale: integer): boolean; |
797 |
– |
function NumericToDouble(aValue: Int64; aScale: integer): double; |
798 |
|
function StringToHex(octetString: string; MaxLineLength: integer=0): string; overload; |
799 |
|
procedure StringToHex(octetString: string; TextOut: TStrings; MaxLineLength: integer=0); overload; |
800 |
|
|
2015 |
|
end; |
2016 |
|
end; |
2017 |
|
|
2018 |
– |
function TryStrToNumeric(S: Ansistring; out Value: int64; out scale: integer): boolean; |
2019 |
– |
var i: integer; |
2020 |
– |
ds: integer; |
2021 |
– |
exponent: integer; |
2022 |
– |
begin |
2023 |
– |
Result := false; |
2024 |
– |
ds := 0; |
2025 |
– |
exponent := 0; |
2026 |
– |
S := Trim(S); |
2027 |
– |
Value := 0; |
2028 |
– |
scale := 0; |
2029 |
– |
if Length(S) = 0 then |
2030 |
– |
Exit; |
2031 |
– |
{$IF declared(DefaultFormatSettings)} |
2032 |
– |
with DefaultFormatSettings do |
2033 |
– |
{$ELSE} |
2034 |
– |
{$IF declared(FormatSettings)} |
2035 |
– |
with FormatSettings do |
2036 |
– |
{$IFEND} |
2037 |
– |
{$IFEND} |
2038 |
– |
begin |
2039 |
– |
for i := length(S) downto 1 do |
2040 |
– |
begin |
2041 |
– |
if S[i] = AnsiChar(DecimalSeparator) then |
2042 |
– |
begin |
2043 |
– |
if ds <> 0 then Exit; {only one allowed} |
2044 |
– |
ds := i; |
2045 |
– |
dec(exponent); |
2046 |
– |
system.Delete(S,i,1); |
2047 |
– |
end |
2048 |
– |
else |
2049 |
– |
if S[i] in ['+','-'] then |
2050 |
– |
begin |
2051 |
– |
if (i > 1) and not (S[i-1] in ['e','E']) then |
2052 |
– |
Exit; {malformed} |
2053 |
– |
end |
2054 |
– |
else |
2055 |
– |
if S[i] in ['e','E'] then {scientific notation} |
2056 |
– |
begin |
2057 |
– |
if ds <> 0 then Exit; {not permitted in exponent} |
2058 |
– |
if exponent <> 0 then Exit; {only one allowed} |
2059 |
– |
exponent := i; |
2060 |
– |
end |
2061 |
– |
else |
2062 |
– |
if not (S[i] in ['0'..'9']) then |
2063 |
– |
{Note: ThousandSeparator not allowed by Delphi specs} |
2064 |
– |
Exit; {bad character} |
2065 |
– |
end; |
2066 |
– |
|
2067 |
– |
if exponent > 0 then |
2068 |
– |
begin |
2069 |
– |
Result := TryStrToInt(system.copy(S,exponent+1,maxint),Scale); |
2070 |
– |
if Result then |
2071 |
– |
begin |
2072 |
– |
{adjust scale for decimal point} |
2073 |
– |
if ds <> 0 then |
2074 |
– |
Scale := Scale - (exponent - ds); |
2075 |
– |
Result := TryStrToInt64(system.copy(S,1,exponent-1),Value); |
2076 |
– |
end; |
2077 |
– |
end |
2078 |
– |
else |
2079 |
– |
begin |
2080 |
– |
if ds <> 0 then |
2081 |
– |
scale := ds - Length(S) - 1; |
2082 |
– |
Result := TryStrToInt64(S,Value); |
2083 |
– |
end; |
2084 |
– |
end; |
2085 |
– |
end; |
2086 |
– |
|
2087 |
– |
function NumericToDouble(aValue: Int64; aScale: integer): double; |
2088 |
– |
begin |
2089 |
– |
Result := aValue * IntPower(10,aScale) |
2090 |
– |
end; |
2091 |
– |
|
2092 |
– |
|
2018 |
|
function StringToHex(octetString: string; MaxLineLength: integer): string; overload; |
2019 |
|
|
2020 |
|
function ToHex(aValue: byte): string; |
2795 |
|
end; |
2796 |
|
|
2797 |
|
sqltComma: |
2798 |
< |
if not (LineState in [lsGotTimestamp,lsGotSessionID,lsGotTransactionID,lsGotText1,lsGotText2]) then |
2798 |
> |
if not (LineState in [lsGotTimestamp,lsGotAttachmentID,lsGotSessionID,lsGotTransactionID,lsGotText1,lsGotText2]) then |
2799 |
|
LineState := lsInit; |
2800 |
|
|
2801 |
|
sqltNumberString: |
2802 |
|
case LineState of |
2803 |
|
lsGotTimestamp: |
2804 |
|
begin |
2805 |
+ |
AttachmentID := StrToInt(TokenText); |
2806 |
+ |
LineState := lsGotAttachmentID; |
2807 |
+ |
end; |
2808 |
+ |
|
2809 |
+ |
lsGotAttachmentID: |
2810 |
+ |
begin |
2811 |
|
SessionID := StrToInt(TokenText); |
2812 |
|
LineState := lsGotSessionID; |
2813 |
|
end; |
2815 |
|
lsGotSessionID: |
2816 |
|
begin |
2817 |
|
TransactionID := StrToInt(TokenText); |
2818 |
< |
if JnlEntryType in [jeTransCommit, jeTransRollback] then |
2818 |
> |
if JnlEntryType in [jeTransCommit, jeTransCommitFail, jeTransRollback, jeTransRollbackFail] then |
2819 |
|
begin |
2820 |
|
if assigned(FOnNextJournalEntry) then |
2821 |
|
OnNextJournalEntry(JnlEntry); |
2841 |
|
end; |
2842 |
|
|
2843 |
|
jeTransCommitRet, |
2844 |
+ |
jeTransCommitFail, |
2845 |
+ |
jeTransRollbackFail, |
2846 |
|
jeTransRollbackRet: |
2847 |
|
begin |
2848 |
|
OldTransactionID := StrToInt(TokenText); |
2899 |
|
Result := jeTransEnd; |
2900 |
|
'Q': |
2901 |
|
Result := jeQuery; |
2902 |
+ |
'F': |
2903 |
+ |
Result := jeTransCommitFail; |
2904 |
+ |
'f': |
2905 |
+ |
Result := jeTransRollbackFail; |
2906 |
|
end; |
2907 |
|
end; |
2908 |
|
|
2913 |
|
Result := 'Transaction Start'; |
2914 |
|
jeTransCommit: |
2915 |
|
Result := 'Commit'; |
2916 |
+ |
jeTransCommitFail: |
2917 |
+ |
Result := 'Commit (Failed)'; |
2918 |
|
jeTransCommitRet: |
2919 |
|
Result := 'Commit Retaining'; |
2920 |
|
jeTransRollback: |
2921 |
|
Result := 'Rollback'; |
2922 |
+ |
jeTransRollbackFail: |
2923 |
+ |
Result := 'Rollback (Failed)'; |
2924 |
|
jeTransRollbackRet: |
2925 |
|
Result := 'Rollback Retaining'; |
2926 |
|
jeTransEnd: |