--- ibx/trunk/fbintf/client/3.0/FB30Attachment.pas 2020/04/17 10:26:08 291 +++ ibx/trunk/fbintf/client/3.0/FB30Attachment.pas 2021/02/25 11:56:36 315 @@ -37,7 +37,8 @@ unit FB30Attachment; interface uses - Classes, SysUtils, FBAttachment, FB30ClientAPI, Firebird, IB, FBActivityMonitor, FBParamBlock; + Classes, SysUtils, FBAttachment, FBClientAPI, FB30ClientAPI, Firebird, IB, + FBActivityMonitor, FBParamBlock; type @@ -47,6 +48,9 @@ type private FAttachmentIntf: Firebird.IAttachment; FFirebird30ClientAPI: TFB30ClientAPI; + FTimeZoneServices: ITimeZoneServices; + FUsingRemoteICU: boolean; + procedure SetUseRemoteICU(aValue: boolean); protected procedure CheckHandle; override; public @@ -96,12 +100,17 @@ type function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData; override; function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData; override; procedure getFBVersion(version: TStrings); + function HasDecFloatSupport: boolean; override; + + {Time Zone Support} + function GetTimeZoneServices: ITimeZoneServices; override; + function HasTimeZoneSupport: boolean; override; end; implementation uses FB30Transaction, FB30Statement, FB30Array, FB30Blob, FBMessages, - FBOutputBlock, FB30Events, IBUtils; + FBOutputBlock, FB30Events, IBUtils, FB30TimeZoneServices; type { TVersionCallback } @@ -109,27 +118,52 @@ type TVersionCallback = class(Firebird.IVersionCallbackImpl) private FOutput: TStrings; + FFirebirdClientAPI: TFBClientAPI; public - constructor Create(output: TStrings); + constructor Create(FirebirdClientAPI: TFBClientAPI; output: TStrings); procedure callback(status: Firebird.IStatus; text: PAnsiChar); override; end; { TVersionCallback } -constructor TVersionCallback.Create(output: TStrings); +constructor TVersionCallback.Create(FirebirdClientAPI: TFBClientAPI; + output: TStrings); begin inherited Create; + FFirebirdClientAPI := FirebirdClientAPI; FOutput := output; end; procedure TVersionCallback.callback(status: Firebird.IStatus; text: PAnsiChar); +var StatusObj: TFB30StatusObject; begin + if ((status.getState and status.STATE_ERRORS) <> 0) then + begin + StatusObj := TFB30StatusObject.Create(FFirebirdClientAPI,status); + try + raise EIBInterBaseError.Create(StatusObj); + finally + StatusObj.Free; + end; + end; FOutput.Add(text); end; { TFB30Attachment } +procedure TFB30Attachment.SetUseRemoteICU(aValue: boolean); +begin + if (FUsingRemoteICU <> aValue) and (GetODSMajorVersion >= 13) then + begin + if aValue then + ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_concurrency],'SET BIND OF TIME ZONE TO EXTENDED') + else + ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_concurrency],'SET BIND OF TIME ZONE TO NATIVE'); + FUsingRemoteICU := aValue; + end; +end; + procedure TFB30Attachment.CheckHandle; begin if FAttachmentIntf = nil then @@ -235,6 +269,7 @@ begin FAttachmentIntf := nil else GetODSAndConnectionInfo; + end; end; @@ -251,6 +286,7 @@ begin FHasDefaultCharSet := false; FCodePage := CP_NONE; FCharSetID := 0; + FTimeZoneServices := nil; end; end; @@ -380,7 +416,7 @@ procedure TFB30Attachment.getFBVersion(v var bufferObj: TVersionCallback; begin version.Clear; - bufferObj := TVersionCallback.Create(version); + bufferObj := TVersionCallback.Create(Firebird30ClientAPI,version); try with FFirebird30ClientAPI do begin @@ -392,5 +428,27 @@ begin end; end; +function TFB30Attachment.HasDecFloatSupport: boolean; +begin + Result := (FFirebird30ClientAPI.GetClientMajor >= 4) and + (GetODSMajorVersion >= 13); +end; + +function TFB30Attachment.GetTimeZoneServices: ITimeZoneServices; +begin + if not HasTimeZoneSupport then + IBError(ibxeNotSupported,[]); + + if FTimeZoneServices = nil then + FTimeZoneServices := TFB30TimeZoneServices.Create(self); + Result := FTimeZoneServices; +end; + +function TFB30Attachment.HasTimeZoneSupport: boolean; +begin + Result := (FFirebird30ClientAPI.GetClientMajor >= 4) and + (GetODSMajorVersion >= 13); +end; + end.