mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 00:46:02 +02:00
* Merging revisions r45503 from trunk:
------------------------------------------------------------------------ r45503 | michael | 2020-05-26 09:20:44 +0200 (Tue, 26 May 2020) | 1 line * Expose status vector in interbase code, adapted patch by Joeny Ang. bug ID #0037143 ------------------------------------------------------------------------ git-svn-id: branches/fixes_3_2@46593 -
This commit is contained in:
parent
f80252e809
commit
e0febe8a29
@ -26,16 +26,23 @@ type
|
|||||||
ServerVersionString : string; //Complete version string, including name, platform
|
ServerVersionString : string; //Complete version string, including name, platform
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TStatusVector = array [0..19] of ISC_STATUS;
|
||||||
|
|
||||||
|
{ EIBDatabaseError }
|
||||||
|
|
||||||
EIBDatabaseError = class(ESQLDatabaseError)
|
EIBDatabaseError = class(ESQLDatabaseError)
|
||||||
public
|
private
|
||||||
property GDSErrorCode: integer read ErrorCode; deprecated 'Please use ErrorCode instead of GDSErrorCode'; // Nov 2014
|
FStatusVector: TStatusVector;
|
||||||
|
public
|
||||||
|
Property StatusVector: TStatusVector Read FStatusVector Write FStatusVector;
|
||||||
|
property GDSErrorCode: integer read ErrorCode; deprecated 'Please use ErrorCode instead of GDSErrorCode'; // Nov 2014
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIBCursor }
|
{ TIBCursor }
|
||||||
|
|
||||||
TIBCursor = Class(TSQLCursor)
|
TIBCursor = Class(TSQLCursor)
|
||||||
protected
|
protected
|
||||||
Status : array [0..19] of ISC_STATUS;
|
Status : TStatusVector;
|
||||||
TransactionHandle : pointer;
|
TransactionHandle : pointer;
|
||||||
StatementHandle : pointer;
|
StatementHandle : pointer;
|
||||||
SQLDA : PXSQLDA;
|
SQLDA : PXSQLDA;
|
||||||
@ -48,7 +55,7 @@ type
|
|||||||
protected
|
protected
|
||||||
TransactionHandle : pointer;
|
TransactionHandle : pointer;
|
||||||
TPB : string; // Transaction parameter buffer
|
TPB : string; // Transaction parameter buffer
|
||||||
Status : array [0..19] of ISC_STATUS;
|
Status : TStatusVector;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIBConnection }
|
{ TIBConnection }
|
||||||
@ -57,7 +64,7 @@ type
|
|||||||
private
|
private
|
||||||
FCheckTransactionParams: Boolean;
|
FCheckTransactionParams: Boolean;
|
||||||
FDatabaseHandle : pointer;
|
FDatabaseHandle : pointer;
|
||||||
FStatus : array [0..19] of ISC_STATUS;
|
FStatus : TStatusVector;
|
||||||
FDatabaseInfo : TDatabaseInfo;
|
FDatabaseInfo : TDatabaseInfo;
|
||||||
FDialect : integer;
|
FDialect : integer;
|
||||||
FBlobSegmentSize : word; //required for backward compatibilty; not used
|
FBlobSegmentSize : word; //required for backward compatibilty; not used
|
||||||
@ -159,16 +166,17 @@ const
|
|||||||
SQL_BOOLEAN_FIREBIRD = 32764;
|
SQL_BOOLEAN_FIREBIRD = 32764;
|
||||||
INVALID_DATA = -1;
|
INVALID_DATA = -1;
|
||||||
|
|
||||||
|
|
||||||
procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
|
procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
|
||||||
var
|
var
|
||||||
ErrorCode : longint;
|
i,ErrorCode : longint;
|
||||||
Msg, SQLState : string;
|
Msg, SQLState : string;
|
||||||
Buf : array [0..1023] of char;
|
Buf : array [0..1023] of char;
|
||||||
|
aStatusVector: TStatusVector;
|
||||||
|
Exc : EIBDatabaseError;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if ((Status[0] = 1) and (Status[1] <> 0)) then
|
if ((Status[0] = 1) and (Status[1] <> 0)) then
|
||||||
begin
|
begin
|
||||||
ErrorCode := Status[1];
|
ErrorCode := Status[1];
|
||||||
{$IFDEF LinkDynamically}
|
{$IFDEF LinkDynamically}
|
||||||
if assigned(fb_sqlstate) then // >= Firebird 2.5
|
if assigned(fb_sqlstate) then // >= Firebird 2.5
|
||||||
@ -177,11 +185,16 @@ begin
|
|||||||
SQLState := StrPas(Buf);
|
SQLState := StrPas(Buf);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{ get a local copy of status vector }
|
||||||
|
for i := 0 to 19 do
|
||||||
|
aStatusVector[i] := Status[i];
|
||||||
Msg := '';
|
Msg := '';
|
||||||
while isc_interprete(Buf, @Status) > 0 do
|
while isc_interprete(Buf, @Status) > 0 do
|
||||||
Msg := Msg + LineEnding + ' -' + StrPas(Buf);
|
Msg := Msg + LineEnding + ' -' + StrPas(Buf);
|
||||||
raise EIBDatabaseError.CreateFmt('%s : %s', [ProcName,Msg], Self, ErrorCode, SQLState);
|
Exc:=EIBDatabaseError.CreateFmt('%s : %s', [ProcName,Msg], Self, ErrorCode, SQLState);
|
||||||
end;
|
Exc.StatusVector:=aStatusVector;
|
||||||
|
raise Exc;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user