ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/IB.pas
(Generate patch)

Comparing ibx/trunk/fbintf/IB.pas (file contents):
Revision 60 by tony, Mon Mar 27 15:21:02 2017 UTC vs.
Revision 345 by tony, Mon Aug 23 14:22:29 2021 UTC

# Line 73 | Line 73 | unit IB;
73   {$IFEND}
74   {$ENDIF}
75  
76 + {$IFNDEF LEGACYFIREBIRDAPIONLY}
77   {$DEFINE USEFIREBIRD3API}
78 + {$ENDIF}
79 + {$IFNDEF FIREBIRD3APIONLY}
80   {$DEFINE USELEGACYFIREBIRDAPI}
81 + {$ENDIF}
82  
83   {
84    This unit defines the interfaces used to provide the Pascal Language
# Line 122 | Line 126 | unit IB;
126   interface
127  
128   uses
129 <  Classes, SysUtils, DB, FBMessages, IBExternals;
129 >  Classes,
130 >  {$IFDEF WINDOWS}Windows, {$ENDIF}
131 >  {$IFDEF FPC} Dynlibs, {$ENDIF}
132 >  SysUtils, DB, FBMessages, IBExternals, FmtBcd;
133  
134   const
135    {Interface version information}
136    FBIntf_Major = 1;
137 <  FBIntf_Minor = 0;
138 <  FBIntf_Release = 2;
139 <  FBIntf_Version = '1.0.2';
137 >  FBIntf_Minor = 3;
138 >  FBIntf_Release = 1;
139 >  FBIntf_Version = '1.3.1';
140 >
141 > const
142 >  {DPB, TPB and SPB Parameter Block Name Prefixes}
143 >  DPBPrefix = 'isc_dpb_';
144 >  TPBPrefix = 'isc_tpb_';
145 >
146 > const
147 >  {Time Zone ID constraint}
148 >  MaxOffsetTimeZoneID = 2879; {lower values represent a time zone offset between
149 >                               -23:59 and 23:59. Higher values are keys to the
150 >                               Time Zone database.}
151 >
152 >  TimeZoneID_GMT = 23*minsPerHour + 59;
153 >  decimillisecondsPerSecond = 10000;
154 >  TimeZoneDisplacementDelta = 60*23 + 59; {23:59 in minutes}
155  
156   {These include files are converted from the 'C' originals in the Firebird API
157   and define the various constants used by the API}
158  
159   {$I 'include/consts_pub.inc'}
160 + {$I 'include/dyn_consts.inc'}
161   {$I 'include/inf_pub.inc'}
162   {$I 'include/configkeys.inc'}
163 + {$I 'include/blr.inc'}
164  
165   {The following constants define the values return by calls to the GetSQLType
166   methods provided by several of the interfaces defined below.}
# Line 158 | Line 182 | const
182    SQL_TYPE_TIME                  =        560;
183    SQL_TYPE_DATE                  =        570;
184    SQL_INT64                      =        580;
185 +  SQL_TIMESTAMP_TZ_EX            =        32748;
186 +  SQL_TIME_TZ_EX                 =        32750;
187 +  SQL_INT128                     =        32752;
188    SQL_BOOLEAN                    =        32764;
189 +  SQL_TIMESTAMP_TZ               =        32754;
190 +  SQL_TIME_TZ                    =        32756;
191 +  SQL_DEC_FIXED                  =        32758;    {FB4 Beta 1 only}
192 +  SQL_DEC16                      =        32760;
193 +  SQL_DEC34                      =        32762;
194 +  SQL_NULL                       =        32766;
195    SQL_DATE                       =        SQL_TIMESTAMP;
196  
197   type
# Line 173 | Line 206 | type
206     PISC_QUAD            = ^TISC_QUAD;
207  
208   {$IFNDEF FPC}
209 + {Delphi missing definitions}
210 + type
211 +  TLibHandle = THandle;
212 +
213 + const
214 +  NilHandle = 0;
215 +  DirectorySeparator = '\';
216 +
217   {Delphi only seems to define CP_UTF8 and CP_UTF16}
218   const
219    CP_ACP     = 0;     // default to ANSI code page
# Line 195 | Line 236 | type
236                    SQLGetSegment, SQLPutSegment,
237                    SQLExecProcedure, SQLStartTransaction,
238                    SQLCommit, SQLRollback,
239 <                  SQLSelectForUpdate, SQLSetGenerator);
239 >                  SQLSelectForUpdate, SQLSetGenerator,
240 >                  SQLSavePoint);
241  
242    TFBStatusCode = cardinal;
243    TByteArray = array of byte;
244 +  TFBTimeZoneID = ISC_USHORT;
245  
246 +  IFirebirdAPI = interface;
247    IAttachment = interface;
248    ITransaction = interface;
249 +  IStatement = interface;
250  
251    {The IParameterBlock interface provides the template for all parameter
252     block interfaces}
# Line 216 | Line 261 | type
261      property Items[index: integer]: _IItem read getItems; default;
262    end;
263  
264 +  IParameterBlockWithTypeNames<_IItem> = interface(IParameterBlock<_IItem>)
265 +    function AddByTypeName(ParamTypeName: AnsiString): _IItem;
266 +    function GetDPBParamTypeName(ParamType: byte): Ansistring; deprecated 'Use Get ParamTypeName';
267 +    function GetParamTypeName(ParamType: byte): Ansistring;
268 +  end;
269 +
270    {IParameterBlockItem is not used on its own but instead provides a base type for
271     different parameter block items }
272  
# Line 233 | Line 284 | type
284      property AsInteger: integer read getAsInteger write SetAsInteger;
285    end;
286  
287 +  IParameterBlockItemWithTypeName = interface(IParameterBlockItem)
288 +    function getParamTypeName: AnsiString;
289 +  end;
290  
291    {The IStatus interface provides access to error information, if any, returned
292     by the last API call. It can also be used to customise the error message
# Line 241 | Line 295 | type
295     This interface can be accessed from IFirebirdAPI.
296     }
297  
298 +   TIBDataBaseErrorMessage    = (ShowSQLCode,
299 +                                   ShowIBMessage,
300 +                                   ShowSQLMessage);
301 +
302 +   TIBDataBaseErrorMessages   = set of TIBDataBaseErrorMessage;
303 +
304 +   TStatusCode = long;
305 +
306    IStatus = interface
307      ['{34167722-af38-4831-b08a-93162d58ede3}']
308 <    function GetIBErrorCode: Long;
309 <    function Getsqlcode: Long;
308 >    function GetIBErrorCode: TStatusCode;
309 >    function Getsqlcode: TStatusCode;
310      function GetMessage: AnsiString;
311      function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean;
312      function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages;
# Line 267 | Line 329 | type
329      function GetSQLTypeName: AnsiString;
330      function GetScale: integer;
331      function GetSize: cardinal;
332 +    function GetCharSetWidth: integer;
333      function GetCharSetID: cardinal;
334      function GetTableName: AnsiString;
335      function GetColumnName: AnsiString;
# Line 305 | Line 368 | type
368      function GetAsBoolean(index: array of integer): boolean;
369      function GetAsCurrency(index: array of integer): Currency;
370      function GetAsInt64(index: array of integer): Int64;
371 <    function GetAsDateTime(index: array of integer): TDateTime;
371 >    function GetAsDateTime(index: array of integer): TDateTime; overload;
372 >    procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
373 >    procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
374 >    procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
375 >    procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
376 >    function GetAsUTCDateTime(index: array of integer): TDateTime;
377      function GetAsDouble(index: array of integer): Double;
378      function GetAsFloat(index: array of integer): Float;
379      function GetAsLong(index: array of integer): Long;
380      function GetAsShort(index: array of integer): Short;
381      function GetAsString(index: array of integer): AnsiString;
382      function GetAsVariant(index: array of integer): Variant;
383 +    function GetAsBCD(index: array of integer): tBCD;
384      procedure SetAsInteger(index: array of integer; AValue: integer);
385      procedure SetAsBoolean(index: array of integer; AValue: boolean);
386      procedure SetAsCurrency(index: array of integer; Value: Currency);
387      procedure SetAsInt64(index: array of integer; Value: Int64);
388      procedure SetAsDate(index: array of integer; Value: TDateTime);
389 +    procedure SetAsDateTime(index: array of integer; Value: TDateTime); overload;
390 +    procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
391 +    procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZone: AnsiString); overload;
392 +    procedure SetAsTime(index: array of integer; Value: TDateTime); overload;
393 +    procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
394 +    procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
395 +    procedure SetAsUTCDateTime(index: array of integer; aUTCTime: TDateTime);
396      procedure SetAsLong(index: array of integer; Value: Long);
321    procedure SetAsTime(index: array of integer; Value: TDateTime);
322    procedure SetAsDateTime(index: array of integer; Value: TDateTime);
397      procedure SetAsDouble(index: array of integer; Value: Double);
398      procedure SetAsFloat(index: array of integer; Value: Float);
399      procedure SetAsShort(index: array of integer; Value: Short);
400      procedure SetAsString(index: array of integer; Value: AnsiString);
401      procedure SetAsVariant(index: array of integer; Value: Variant);
402 +    procedure SetAsBcd(index: array of integer; aValue: tBCD);
403      procedure SetBounds(dim, UpperBound, LowerBound: integer);
404      function GetAttachment: IAttachment;
405      function GetTransaction: ITransaction;
# Line 352 | Line 427 | type
427      ['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}']
428    end;
429  
430 <  IBPB = interface(IParameterBlock<IBPBItem>)
430 >  IBPB = interface (IParameterBlock<IBPBItem>)
431      ['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}']
432    end;
433  
# Line 395 | Line 470 | type
470      the output of an SQL Statement.
471    }
472  
473 +  TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP}
474 +                        dfDateTime,   {SQL DATETIME}
475 +                        dfTime,      {SQL TIME}
476 +                        dfTimestampTZ, {SQL_TIMESTAMP_TZ}
477 +                        dfTimeTZ);       {SQLTIME_TZ
478 +
479    { IColumnMetaData }
480  
481    IColumnMetaData = interface
# Line 411 | Line 492 | type
492      function getScale: integer;
493      function getCharSetID: cardinal;
494      function getCodePage: TSystemCodePage;
495 +    function GetCharSetWidth: integer;
496      function getIsNullable: boolean;
497      function GetSize: cardinal;
498      function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
499      function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
500 +    function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer;
501 +    function GetStatement: IStatement;
502 +    function GetTransaction: ITransaction;
503      property Name: AnsiString read GetName;
504      property Size: cardinal read GetSize;
505      property SQLType: cardinal read GetSQLType;
# Line 456 | Line 541 | type
541  
542    ISQLData = interface(IColumnMetaData)
543      ['{3f493e31-7e3f-4606-a07c-b210b9e3619d}']
544 +    function GetStrDataLength: short;
545      function GetAsBoolean: boolean;
546      function GetAsCurrency: Currency;
547      function GetAsInt64: Int64;
548 <    function GetAsDateTime: TDateTime;
548 >    function GetAsDateTime: TDateTime; overload;
549 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
550 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
551 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
552 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
553 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
554 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
555 >    function GetAsUTCDateTime: TDateTime;
556      function GetAsDouble: Double;
557      function GetAsFloat: Float;
558      function GetAsLong: Long;
# Line 472 | Line 565 | type
565      function GetAsBlob: IBlob; overload;
566      function GetAsBlob(BPB: IBPB): IBlob; overload;
567      function GetAsArray: IArray;
568 +    function GetAsBCD: tBCD;
569      property AsDate: TDateTime read GetAsDateTime;
570      property AsBoolean:boolean read GetAsBoolean;
571      property AsTime: TDateTime read GetAsDateTime;
# Line 489 | Line 583 | type
583      property AsVariant: Variant read GetAsVariant ;
584      property AsBlob: IBlob read GetAsBlob;
585      property AsArray: IArray read GetAsArray;
586 +    property AsBCD: tBCD read GetAsBCD;
587      property IsNull: Boolean read GetIsNull;
588      property Value: Variant read GetAsVariant;
589    end;
# Line 502 | Line 597 | type
597    IResults = interface
598      ['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}']
599     function getCount: integer;
600 +   function GetStatement: IStatement;
601     function GetTransaction: ITransaction;
602     function ByName(Idx: AnsiString): ISQLData;
603     function getSQLData(index: integer): ISQLData;
# Line 554 | Line 650 | type
650      function GetAsBoolean: boolean;
651      function GetAsCurrency: Currency;
652      function GetAsInt64: Int64;
653 <    function GetAsDateTime: TDateTime;
653 >    function GetAsDateTime: TDateTime; overload;
654 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
655 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
656 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
657 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
658 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
659 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
660 >    function GetAsUTCDateTime: TDateTime;
661      function GetAsDouble: Double;
662      function GetAsFloat: Float;
663      function GetAsLong: Long;
# Line 566 | Line 669 | type
669      function GetAsVariant: Variant;
670      function GetAsBlob: IBlob;
671      function GetAsArray: IArray;
672 +    function GetAsBCD: tBCD;
673 +    function GetStatement: IStatement;
674 +    function GetTransaction: ITransaction;
675      procedure Clear;
676      function GetModified: boolean;
677      procedure SetAsBoolean(AValue: boolean);
# Line 573 | Line 679 | type
679      procedure SetAsInt64(aValue: Int64);
680      procedure SetAsDate(aValue: TDateTime);
681      procedure SetAsLong(aValue: Long);
682 <    procedure SetAsTime(aValue: TDateTime);
683 <    procedure SetAsDateTime(aValue: TDateTime);
682 >    procedure SetAsTime(aValue: TDateTime); overload;
683 >    procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
684 >    procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
685 >    procedure SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
686 >    procedure SetAsTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
687 >    procedure SetAsDateTime(aValue: TDateTime); overload;
688 >    procedure SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
689 >    procedure SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
690 >    procedure SetAsUTCDateTime(aUTCTime: TDateTime);
691      procedure SetAsDouble(aValue: Double);
692      procedure SetAsFloat(aValue: Float);
693      procedure SetAsPointer(aValue: Pointer);
# Line 586 | Line 699 | type
699      procedure SetAsArray(anArray: IArray);
700      procedure SetAsQuad(aValue: TISC_QUAD);
701      procedure SetCharSetID(aValue: cardinal);
702 +    procedure SetAsBcd(aValue: tBCD);
703      property AsDate: TDateTime read GetAsDateTime write SetAsDate;
704      property AsBoolean:boolean read GetAsBoolean write SetAsBoolean;
705      property AsTime: TDateTime read GetAsDateTime write SetAsTime;
# Line 602 | Line 716 | type
716      property AsVariant: Variant read GetAsVariant write SetAsVariant;
717      property AsBlob: IBlob read GetAsBlob write SetAsBlob;
718      property AsArray: IArray read GetAsArray write SetAsArray;
719 +    property AsBCD: tBCD read GetAsBCD write SetAsBCD;
720      property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad;
721      property Value: Variant read GetAsVariant write SetAsVariant;
722      property IsNull: Boolean read GetIsNull write SetIsNull;
# Line 622 | Line 737 | type
737      function getSQLParam(index: integer): ISQLParam;
738      function ByName(Idx: AnsiString): ISQLParam ;
739      function GetModified: Boolean;
740 +    function GetHasCaseSensitiveParams: Boolean;
741      property Modified: Boolean read GetModified;
742      property Params[index: integer]: ISQLParam read getSQLParam; default;
743      property Count: integer read getCount;
# Line 632 | Line 748 | type
748                  psRealTime, psUserTime, psBuffers,
749                  psReads, psWrites, psFetches,psDeltaMemory);
750  
751 <  TPerfCounters = array[TPerfStats] of comp;
751 >  TPerfCounters = array[TPerfStats] of Int64;
752 >
753 >  {Batch Query Execution Support}
754 >
755 >  TBatchCompletionState = (bcExecuteFailed, bcSuccessNoInfo, bcNoMoreErrors);
756 >
757 >  IBatchCompletion = interface
758 >  ['{9bc3d49d-16d9-4606-94e5-ee987103ad92}']
759 >    function getTotalProcessed: cardinal;
760 >    function getState(updateNo: cardinal): TBatchCompletionState;
761 >    function getStatusMessage(updateNo: cardinal): AnsiString;
762 >    function getUpdated: integer;
763 >    function getErrorStatus(var RowNo: integer; var status: IStatus): boolean;
764 >    end;
765  
766    {The IStatement interface provides access to an SQL Statement once it has been
767     initially prepared. The interface is returned from the IAttachment interface.
# Line 645 | Line 774 | type
774      function GetPlan: AnsiString;
775      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
776      function GetSQLStatementType: TIBSQLStatementTypes;
777 +    function GetSQLStatementTypeName: AnsiString;
778      function GetSQLText: AnsiString;
779 +    function GetProcessedSQLText: AnsiString;
780      function GetSQLDialect: integer;
781      function IsPrepared: boolean;
782 +    function HasBatchMode: boolean;
783 +    function IsInBatchMode: boolean;
784      procedure Prepare(aTransaction: ITransaction=nil);
785      function Execute(aTransaction: ITransaction=nil): IResults;
786      function OpenCursor(aTransaction: ITransaction=nil): IResultSet;
# Line 656 | Line 789 | type
789      procedure SetRetainInterfaces(aValue: boolean);
790      procedure EnableStatistics(aValue: boolean);
791      function GetPerfStatistics(var stats: TPerfCounters): boolean;
792 +    {IBatch interface support}
793 +    procedure AddToBatch;
794 +    function ExecuteBatch(aTransaction: ITransaction=nil): IBatchCompletion;
795 +    procedure CancelBatch;
796 +    function GetBatchCompletion: IBatchCompletion;
797 +    function GetBatchRowLimit: integer;
798 +    procedure SetBatchRowLimit(aLimit: integer);
799 +
800      property MetaData: IMetaData read GetMetaData;
801      property SQLParams: ISQLParams read GetSQLParams;
802      property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType;
# Line 672 | Line 813 | type
813     found in the Interbase 6.0 API Guide.
814    }
815  
816 <  ITPBItem = interface(IParameterBlockItem)
816 >  ITPBItem = interface(IParameterBlockItemWithTypeName)
817      ['{544c1f2b-7c12-4a87-a4a5-face7ea72671}']
818 +    function getParamTypeName: AnsiString;
819    end;
820  
821 <  ITPB = interface(IParameterBlock<ITPBItem>)
821 >  ITPB = interface(IParameterBlockWithTypeNames<ITPBItem>)
822      ['{7369b0ff-defe-437b-81fe-19b211d42d25}']
823    end;
824  
# Line 742 | Line 884 | type
884      function GetAttachment: IAttachment;
885    end;
886  
887 +  TTZTextOptions = (tzOffset,      {Time Zone Rendered as an offset to GMT}
888 +                    tzGMT,         {No Time Zone. Time part is always rendered in GMT}
889 +                    tzOriginalID); {Time Zone shown as originally entered}
890 +
891 +  {The ITimeZoneServices interface provides access to the time zone database
892 +   used for the attachment. It may be used in support of TIMESTAMP WITH TIME ZONE
893 +   and TIME WITH TIME ZONE data types.}
894 +
895 +  ITimeZoneServices = interface
896 +    ['{163821f5-ebef-42b9-ac60-8ac4b5c09954}']
897 +    {utility functions}
898 +    function TimeZoneID2TimeZoneName(aTimeZoneID: TFBTimeZoneID): AnsiString;
899 +    function TimeZoneName2TimeZoneID(aTimeZone: AnsiString): TFBTimeZoneID;
900 +    function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
901 +    function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
902 +    function GMTToLocalTime(aGMTTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
903 +    function GMTToLocalTime(aGMTTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
904 +    function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZone: AnsiString): integer; overload;
905 +    function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): integer; overload;
906 +
907 +    {Time Zone DB Information}
908 +    function UsingRemoteTZDB: boolean;
909 +    procedure SetUseLocalTZDB(useLocalTZDB: boolean);
910 +    function GetLocalTimeZoneName: AnsiString;
911 +    function GetLocalTimeZoneID: TFBTimeZoneID;
912 +    procedure GetTimeZoneInfo(aTimeZone: AnsiString; OnDate: TDateTime;
913 +                           var ZoneOffset, DSTOffset, EffectiveOffset: integer);
914 +    {Configurable Options}
915 +    function GetTimeTZDate: TDateTime;
916 +    procedure SetTimeTZDate(aDate: TDateTime);
917 +    function GetTZTextOption: TTZTextOptions;
918 +    procedure SetTZTextOption(aOptionValue: TTZTextOptions);
919 +  end;
920 +
921    {The IDBInformation Interface.
922  
923     An IDBInformation interface is returned by the  IAttachment GetDBInformation
# Line 770 | Line 946 | type
946      function getSize: integer;
947      procedure getRawBytes(var Buffer);
948      function getAsString: AnsiString;
949 <    function getAsInteger: integer;
949 >    function getAsInteger: int64;
950      procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString);
951      function getAsBytes: TByteArray;
952 +    function getAsDateTime: TDateTime;
953      procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
954      function getOperationCounts: TDBOperationCounts;
955      procedure DecodeUserNames(UserNames: TStrings);
# Line 781 | Line 958 | type
958      function GetCount: integer;
959      function GetItem(index: integer): IDBInfoItem;
960      function Find(ItemType: byte): IDBInfoItem;
961 <    property AsInteger: integer read getAsInteger;
961 >    property AsInteger: int64 read getAsInteger;
962      property AsString: AnsiString read GetAsString;
963      property Count: integer read GetCount;
964      property Items[index: integer]: IDBInfoItem read getItem; default;
# Line 799 | Line 976 | type
976      property Items[index: integer]: IDBInfoItem read getItem; default;
977    end;
978  
979 +  {The Database Information Request Block is used to pass requests for
980 +   database information where at least one item requested has a parameter.
981 +   At present, this is only fb_info_page_contents which has a single
982 +   integer parameter.}
983 +
984 +  IDIRBItem = interface(IParameterBlockItem)
985 +    ['{d34a7511-8435-4a24-81a7-5103d218d234}']
986 +  end;
987 +
988 +  IDIRB = interface(IParameterBlock<IDIRBItem>)
989 +    ['{1010e5ac-0a8f-403b-a302-91625e9d9579}']
990 +  end;
991 +
992 +
993    {The Database Parameter Block (DPB).
994  
995     The DPB provides the parameters used when connecting to a database. It is allocated
# Line 810 | Line 1001 | type
1001     found in the Interbase 6.0 API Guide.
1002     }
1003  
1004 <  IDPBItem = interface(IParameterBlockItem)
1004 >  IDPBItem = interface(IParameterBlockItemWithTypeName)
1005      ['{123d4ad0-087a-4cd1-a344-1b3d03b30673}']
1006    end;
1007  
1008 <  IDPB = interface(IParameterBlock<IDPBItem>)
1009 <    ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
1010 <  end;
1008 >   IDPB = interface(IParameterBlockWithTypeNames<IDPBItem>)
1009 >     ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
1010 >   end;
1011  
1012    {The IAttachment interface provides access to a Database Connection. It may be
1013     used to:
# Line 847 | Line 1038 | type
1038  
1039    IAttachment = interface
1040      ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
1041 +    function getFirebirdAPI: IFirebirdAPI;
1042      function getDPB: IDPB;
1043      function AllocateBPB: IBPB;
1044 +    function AllocateDIRB: IDIRB;
1045      procedure Connect;
1046      procedure Disconnect(Force: boolean=false);
1047      function IsConnected: boolean;
# Line 881 | Line 1074 | type
1074      function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload;
1075      function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload;
1076      function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1077 <                       aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload;
1077 >                       aSQLDialect: integer; GenerateParamNames: boolean=false;
1078 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
1079      function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1080 <                       GenerateParamNames: boolean=false): IStatement; overload;
1080 >                       GenerateParamNames: boolean=false;
1081 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
1082  
1083      {Events}
1084      function GetEventHandler(Events: TStrings): IEvents; overload;
# Line 894 | Line 1089 | type
1089      function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
1090      function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
1091      function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
1092 <    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
1092 >    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
1093 >    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;  overload;
1094 >    function GetInlineBlobLimit: integer;
1095 >    procedure SetInlineBlobLimit(limit: integer);
1096  
1097      {Array - may use to open existing arrays. However, ISQLData.AsArray is preferred}
1098  
1099 <    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray;
1099 >    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload;
1100 >    function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload;
1101      function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload;
1102      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
1103      function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
# Line 911 | Line 1110 | type
1110      function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
1111      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
1112      function GetDBInformation(Request: byte): IDBInformation; overload;
1113 +    function GetDBInformation(Requests: IDIRB): IDBInformation; overload;
1114 +    function GetConnectString: AnsiString;
1115 +    function GetRemoteProtocol: AnsiString;
1116 +    function GetAuthenticationMethod: AnsiString;
1117 +    function GetSecurityDatabase: AnsiString;
1118 +    function GetODSMajorVersion: integer;
1119 +    function GetODSMinorVersion: integer;
1120 +    procedure getFBVersion(version: TStrings);
1121      function HasActivity: boolean;
1122 +    function HasDecFloatSupport: boolean;
1123 +    function HasBatchMode: boolean;
1124  
1125      {Character Sets}
1126 +    function HasDefaultCharSet: boolean;
1127 +    function GetDefaultCharSetID: integer;
1128      function GetCharsetName(CharSetID: integer): AnsiString;
1129      function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
1130      function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
# Line 921 | Line 1132 | type
1132      function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
1133      procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
1134        AllowReverseLookup:boolean; out CharSetID: integer);
924  end;
1135  
1136 <  TProtocol = (TCP, SPX, NamedPipe, Local);
1136 >    {Time Zone Database}
1137 >    function GetTimeZoneServices: ITimeZoneServices;
1138 >    function HasTimeZoneSupport: boolean;
1139 > end;
1140 >
1141 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
1142 >  TProtocol = TCP..xnet;
1143  
1144    {Service Parameter Block (SPB).
1145  
# Line 937 | Line 1153 | type
1153  
1154    }
1155  
1156 <  ISPBItem = interface(IParameterBlockItem)
1156 >  ISPBItem = interface(IParameterBlockItemWithTypeName)
1157      ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
1158    end;
1159  
1160 <  ISPB = interface(IParameterBlock<ISPBItem>)
1160 >  ISPB = interface(IParameterBlockWithTypeNames<ISPBItem>)
1161      ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
1162    end;
1163  
# Line 1001 | Line 1217 | type
1217      function getSize: integer;
1218      procedure getRawBytes(var Buffer);
1219      function getAsString: AnsiString;
1220 <    function getAsInteger: integer;
1220 >    function getAsInteger: int64;
1221      function getAsByte: byte;
1222      function CopyTo(stream: TStream; count: integer): integer;
1223      property AsString: AnsiString read getAsString;
1224 <    property AsInteger: integer read getAsInteger;
1224 >    property AsInteger: int64 read getAsInteger;
1225      property AsByte: byte read getAsByte;
1226    end;
1227  
# Line 1028 | Line 1244 | type
1244      property Count: integer read getCount;
1245    end;
1246  
1247 +  IFirebirdLibrary = interface;
1248 +
1249    {The IServiceManager interface provides access to a service manager. It can
1250     used to Detach and re-attach to Service Manager, to start services and to
1251     query the service manager.
# Line 1039 | Line 1257 | type
1257  
1258    IServiceManager = interface
1259      ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1260 +    function getFirebirdAPI: IFirebirdAPI;
1261      function getSPB: ISPB;
1262      function getServerName: AnsiString;
1263 +    function getProtocol: TProtocol;
1264 +    function getPortNo: AnsiString;
1265      procedure Attach;
1266      procedure Detach(Force: boolean=false);
1267      function IsAttached: boolean;
1268      function AllocateSRB: ISRB;
1269      function AllocateSQPB: ISQPB;
1270 <    procedure Start(Request: ISRB);
1271 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1272 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1270 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1271 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1272 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1273 >  end;
1274 >
1275 >  {Tbe Firebird Library API used to get information about the Firebird library}
1276 >
1277 >
1278 >  IFirebirdLibrary = interface
1279 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1280 >    function GetHandle: TLibHandle;
1281 >    function GetLibraryName: string;
1282 >    function GetLibraryFilePath: string;
1283 >    function GetFirebirdAPI: IFirebirdAPI;
1284    end;
1285  
1286    {The Firebird API.
# Line 1059 | Line 1291 | type
1291     The interface is returned by the FirebirdAPI function.
1292    }
1293  
1294 +  { IFirebirdAPI }
1295 +
1296    IFirebirdAPI = interface
1297      ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1298      {Database connections}
# Line 1077 | Line 1311 | type
1311      {Service Manager}
1312      function HasServiceAPI: boolean;
1313      function AllocateSPB: ISPB;
1314 <    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager;
1314 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1315 >    function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1316  
1317      {Information}
1318      function GetStatus: IStatus;
1084    function GetLibraryName: string;
1319      function HasRollbackRetaining: boolean;
1320      function IsEmbeddedServer: boolean;
1321      function GetImplementationVersion: AnsiString;
1322 +    function GetClientMajor: integer;
1323 +    function GetClientMinor: integer;
1324 +    function HasDecFloatSupport: boolean;
1325 +    function HasLocalTZDB: boolean;
1326 +    function HasTimeZoneSupport: boolean;
1327 +    function HasExtendedTZSupport: boolean;
1328  
1329      {Firebird 3 API}
1330      function HasMasterIntf: boolean;
1331 <    function GetIMaster: TObject;
1331 >    function GetIMaster: TObject;  deprecated 'Use FirebirdAPI.QueryInterface and FBClientLib.pas IFBIMasterProvider instead';
1332 >    function GetFBLibrary: IFirebirdLibrary;
1333   end;
1334  
1335   type
# Line 1123 | Line 1364 | type
1364     {IB Client Exceptions}
1365     EIBClientError = class(EIBError);
1366  
1367 < {IBError is used internally and by IBX to throw an EIBClientError}
1368 <
1128 < procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1367 >   {Used to explicitly report a Batch Buffer overflow}
1368 >   EIBBatchBufferOverflow = class(EIBError);
1369  
1370   {The Firebird API function is used to access the IFirebirdAPI interface.
1371  
# Line 1136 | Line 1376 | procedure IBError(ErrMess: TIBClientErro
1376   function FirebirdAPI: IFirebirdAPI;
1377  
1378   {IBX support functions. Probably best ignored i.e. always used the FirebirdAPI
1379 < functino to load the library and check if it's loaded.}
1379 > function to load the library and check if it's loaded.}
1380  
1381   function TryIBLoad: Boolean;
1382   procedure CheckIBLoaded;
1383  
1384 + {If you want to explicitly load the Firebird library from a
1385 + non-default location then use this function and its GetFirebirdAPI function
1386 + to get the API.}
1387 +
1388 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1389 +
1390 +
1391   implementation
1392  
1393   uses FBClientAPI
1394    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1395    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1396  
1397 < var FFirebirdAPI: IFirebirdAPI;
1397 > var FDefaultFBLibrary: IFirebirdLibrary;
1398 >
1399 > type
1400 >
1401 >  { TFBLibrary }
1402 >
1403 >  TFBLibraryImpl = class(TFBLibrary)
1404 >  protected
1405 >    function GetFirebird3API: IFirebirdAPI; override;
1406 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1407 >  end;
1408 >
1409 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1410 > begin
1411 > {$IFDEF USEFIREBIRD3API}
1412 > Result := TFB30ClientAPI.Create(self);
1413 > {$ELSE}
1414 > Result := nil;
1415 > {$ENDIF}
1416 > end;
1417 >
1418 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1419 > begin
1420 >  {$IFDEF USELEGACYFIREBIRDAPI}
1421 >  Result := TFB25ClientAPI.Create(self);
1422 >  {$ELSE}
1423 >  Result := nil;
1424 >  {$ENDIF}
1425 > end;
1426  
1427   function FirebirdAPI: IFirebirdAPI;
1428   begin
1429 <  if FFirebirdAPI = nil then
1429 >  if FDefaultFBLibrary = nil then
1430      CheckIBLoaded;
1431 <  Result := FFirebirdAPI;
1431 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1432   end;
1433  
1434   function TryIBLoad: Boolean;
1435 + var fblib: IFirebirdLibrary;
1436   begin
1437 < Result := FFirebirdAPI <> nil;
1437 > Result := FDefaultFBLibrary <> nil;
1438   try
1163  {$IFDEF USEFIREBIRD3API}
1164  if not Result then
1165  begin
1166    FFirebirdAPI := TFB30ClientAPI.Create;
1167    Result := FFirebirdAPI.HasMasterIntf;
1168  end;
1169  {$ENDIF}
1170  {$IFDEF USELEGACYFIREBIRDAPI}
1439    if not Result then
1440    begin
1441 <    FFirebirdAPI := nil;
1442 <    FFirebirdAPI := TFB25ClientAPI.Create;
1443 <    Result := true;
1444 <  end;
1177 <  {$ENDIF}
1178 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1179 <  begin
1180 <    Result := false;
1181 <    FFirebirdAPI := nil;
1441 >    fblib := TFBLibraryImpl.Create;
1442 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1443 >      FDefaultFBLibrary := fblib;
1444 >    Result := FDefaultFBLibrary <> nil;
1445    end;
1446   except
1447     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1192 | Line 1455 | begin
1455      IBError(ibxeInterBaseMissing, [nil]);
1456   end;
1457  
1458 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1459 + var fblib: IFirebirdLibrary;
1460 + begin
1461 +  if trim(aLibPathName) = '' then
1462 +  begin
1463 +    CheckIBLoaded;
1464 +    Result := FDefaultFBLibrary;
1465 +  end
1466 +  else
1467 +  begin
1468 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1469 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1470 +      IBError(ibxeInterBaseMissing, [nil]);
1471 +    Result := fblib;
1472 +  end;
1473 + end;
1474 +
1475   { EIBError }
1476  
1477   constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
# Line 1215 | Line 1495 | begin
1495    FIBErrorCode := AIBErrorCode;
1496   end;
1497  
1218 procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1219 begin
1220  raise EIBClientError.Create(Ord(ErrMess),
1221                              Format(GetErrorMessage(ErrMess), Args));
1222 end;
1498  
1499   initialization
1500 <  FFirebirdAPI := nil;
1500 >  FDefaultFBLibrary := nil;
1501  
1502 + finalization
1503 +  FDefaultFBLibrary := nil;
1504  
1505   end.
1506  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines