View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037143 | FPC | Database | public | 2020-05-26 07:55 | 2020-08-03 03:09 |
Reporter | Joeny Ang | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 3.3.1 | ||||
Fixed in Version | 3.3.1 | ||||
Summary | 0037143: [Patch] Expose Status Vector on EIBDatabaseError | ||||
Description | Interbase/Firebird stores error information in the status vector. Return this status vector when an EIBDatabaseError occured. How to parse the Status Vector (from Embarcadero): http://docwiki.embarcadero.com/InterBase/2020/en/Parsing_the_Status_Vector | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 45503 | ||||
FPCOldBugId | |||||
FPCTarget | 4.0.0 | ||||
Attached Files |
|
|
fpc-sqldb-interbase-expose-statusvector-on-EIBDatabaseError.patch (2,904 bytes)
--- packages/fcl-db/src/sqldb/interbase/ibconnection.pp +++ packages/fcl-db/src/sqldb/interbase/ibconnection.pp @@ -26,16 +26,22 @@ ServerVersionString : string; //Complete version string, including name, platform end; + TStatusVector = array [0..19] of ISC_STATUS; + EIBDatabaseError = class(ESQLDatabaseError) - public - property GDSErrorCode: integer read ErrorCode; deprecated 'Please use ErrorCode instead of GDSErrorCode'; // Nov 2014 + public + StatusVector: TStatusVector; + constructor CreateFmt(const Fmt: string; const Args: array of const; + Comp: TComponent; AErrorCode: Integer; ASQLState: string; + Status: PISC_STATUS); overload; + property GDSErrorCode: integer read ErrorCode; deprecated 'Please use ErrorCode instead of GDSErrorCode'; // Nov 2014 end; { TIBCursor } TIBCursor = Class(TSQLCursor) protected - Status : array [0..19] of ISC_STATUS; + Status : TStatusVector; TransactionHandle : pointer; StatementHandle : pointer; SQLDA : PXSQLDA; @@ -48,7 +54,7 @@ protected TransactionHandle : pointer; TPB : string; // Transaction parameter buffer - Status : array [0..19] of ISC_STATUS; + Status : TStatusVector; end; { TIBConnection } @@ -57,7 +63,7 @@ private FCheckTransactionParams: Boolean; FDatabaseHandle : pointer; - FStatus : array [0..19] of ISC_STATUS; + FStatus : TStatusVector; FDatabaseInfo : TDatabaseInfo; FDialect : integer; FBlobSegmentSize : word; //required for backward compatibilty; not used @@ -159,13 +165,22 @@ SQL_BOOLEAN_FIREBIRD = 32764; INVALID_DATA = -1; +constructor EIBDatabaseError.CreateFmt(const Fmt: string; const Args: array of const; + Comp: TComponent; AErrorCode: Integer; ASQLState: string; Status: PISC_STATUS); +var + i: Integer; +begin + for i := 0 to 19 do + StatusVector[i] := Status[i]; + CreateFmt(Fmt, Args, Comp, AErrorCode, ASQLState); +end; procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS); var ErrorCode : longint; Msg, SQLState : string; Buf : array [0..1023] of char; - + FStatusVector: PISC_STATUS; begin if ((Status[0] = 1) and (Status[1] <> 0)) then begin @@ -177,10 +192,12 @@ SQLState := StrPas(Buf); end; {$ENDIF} + { get a local reference to status vector } + FStatusVector := Status; Msg := ''; while isc_interprete(Buf, @Status) > 0 do Msg := Msg + LineEnding + ' -' + StrPas(Buf); - raise EIBDatabaseError.CreateFmt('%s : %s', [ProcName,Msg], Self, ErrorCode, SQLState); + raise EIBDatabaseError.CreateFmt('%s : %s', [ProcName,Msg], Self, ErrorCode, SQLState, FStatusVector); end; end; |
|
I changed the patch a little. I removed the extra constructor for the exception (because this form of the constructor is used only once in the check routine) and changed the field to a property. Thank you very much for the patch ! |
|
Thanks :) |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-05-26 07:55 | Joeny Ang | New Issue | |
2020-05-26 07:55 | Joeny Ang | File Added: fpc-sqldb-interbase-expose-statusvector-on-EIBDatabaseError.patch | |
2020-05-26 08:03 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2020-05-26 08:03 | Michael Van Canneyt | Status | new => assigned |
2020-05-26 09:22 | Michael Van Canneyt | Status | assigned => resolved |
2020-05-26 09:22 | Michael Van Canneyt | Resolution | open => fixed |
2020-05-26 09:22 | Michael Van Canneyt | Fixed in Version | => 3.3.1 |
2020-05-26 09:22 | Michael Van Canneyt | Fixed in Revision | => 45503 |
2020-05-26 09:22 | Michael Van Canneyt | FPCTarget | => 4.0.0 |
2020-05-26 09:22 | Michael Van Canneyt | Note Added: 0123068 | |
2020-05-26 10:52 | Joeny Ang | Note Added: 0123073 | |
2020-08-03 03:09 | Joeny Ang | Status | resolved => closed |