View Issue Details

IDProjectCategoryView StatusLast Update
0037143FPCDatabasepublic2020-08-03 03:09
ReporterJoeny Ang Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037143: [Patch] Expose Status Vector on EIBDatabaseError
DescriptionInterbase/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
TagsNo tags attached.
Fixed in Revision45503
FPCOldBugId
FPCTarget4.0.0
Attached Files

Activities

Joeny Ang

2020-05-26 07:55

reporter  

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;
 

Michael Van Canneyt

2020-05-26 09:22

administrator   ~0123068

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 !

Joeny Ang

2020-05-26 10:52

reporter   ~0123073

Thanks :)

Issue History

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