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 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
ibx/branches/udr/client/IB.pas (file contents), Revision 391 by tony, Thu Jan 27 16:34:24 2022 UTC

# Line 60 | Line 60
60   {                                                                        }
61   {************************************************************************}
62   unit IB;
63 + {$IFDEF MSWINDOWS}
64 + {$DEFINE WINDOWS}
65 + {$ENDIF}
66  
67   {$IFDEF FPC}
68 < {$mode objfpc}{$H+}
68 > {$mode delphi}
69   {$codepage UTF8}
70   {$interfaces COM}
71 < {$IF FPC_FULLVERSION < 30000 }
71 > {$IF defined(FPC) and (FPC_FULLVERSION < 30000) }
72   {$ERROR FPC Version 3.0.0 or later is required}
73 < {$ENDIF}
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 103 | Line 110 | unit IB;
110  
111    5. Straightforward progammatic access to the Firebird API from Pascal programs.
112  
113 +  6. FPC and Delphi Support.
114 +
115    String Types
116    ============
117  
# Line 117 | 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 = 4;
138 >  FBIntf_Release = 0;
139 >  FBIntf_Version = '1.4.0';
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 consts_pub.inc}
160 < {$I inf_pub.inc}
161 < {$I configkeys.inc}
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 146 | Line 182 | uses
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 160 | Line 205 | type
205     PGDS__QUAD           = ^TGDS__QUAD;
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
220 +  CP_OEMCP   = 1;     // default to OEM (console) code page
221 +  CP_UTF16BE = 1201;  // unicodeFFFE
222 +  CP_UTF7    = 65000; // utf-7
223 +  CP_ASCII   = 20127; // us-ascii
224 +  CP_NONE    = $FFFF; // rawbytestring encoding
225 +
226 + {$ENDIF}
227 +
228 + type
229 + {$IF not declared(TSystemCodePage)}
230 +  TSystemCodePage = word; {not defined in Delphi}
231 + {$IFEND}
232 +
233    TIBSQLStatementTypes =
234                   (SQLUnknown, SQLSelect, SQLInsert,
235                    SQLUpdate, SQLDelete, SQLDDL,
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 generic interface provides the template for all parameter
251 >  {The IFBNumeric interface provides a managed type for Fixed Point integers
252 >   used to hold Firebird Numeric(m,n) types}
253 >
254 >  IFBNumeric = interface
255 >    ['{8bdccfe9-d552-446b-bd82-844ca264455d}']
256 >    function getRawValue: Int64;
257 >    function getScale: integer;
258 >    function AdjustScaleTo(aNewScale: integer): IFBNumeric;
259 >    function getAsString: AnsiString;
260 >    function getAsDouble: double;
261 >    function getAsBCD: TBCD;
262 >    function getAsInt64: Int64; {scaled}
263 >    function getAsInteger: integer; {scaled - may be truncated}
264 >    function getAsSmallInt: SmallInt; {scaled - may be truncated}
265 >    function getAsCurrency: Currency;
266 >  end;
267 >
268 >  {The IParameterBlock interface provides the template for all parameter
269     block interfaces}
270  
271 <  generic IParameterBlock<_IItem> = interface
271 >  IParameterBlock<_IItem> = interface
272      function getCount: integer;
273      function Add(ParamType: byte): _IItem;
274      function getItems(index: integer): _IItem;
# Line 187 | Line 278 | type
278      property Items[index: integer]: _IItem read getItems; default;
279    end;
280  
281 +  IParameterBlockWithTypeNames<_IItem> = interface(IParameterBlock<_IItem>)
282 +    function AddByTypeName(ParamTypeName: AnsiString): _IItem;
283 +    function GetDPBParamTypeName(ParamType: byte): Ansistring; deprecated 'Use Get ParamTypeName';
284 +    function GetParamTypeName(ParamType: byte): Ansistring;
285 +  end;
286 +
287    {IParameterBlockItem is not used on its own but instead provides a base type for
288     different parameter block items }
289  
290    IParameterBlockItem = interface
291 +    ['{53b23f7b-abda-46a5-9aa5-07bd5e723266}']
292      function getParamType: byte;
293      function getAsInteger: integer;
294 <    function getAsString: string;
294 >    function getAsString: AnsiString;
295      function getAsByte: byte;
296 <    procedure setAsString(aValue: string);
296 >    procedure setAsString(aValue: AnsiString);
297      procedure setAsByte(aValue: byte);
298      procedure SetAsInteger(aValue: integer);
299 <    property AsString: string read getAsString write setAsString;
299 >    property AsString: AnsiString read getAsString write setAsString;
300      property AsByte: byte read getAsByte write setAsByte;
301      property AsInteger: integer read getAsInteger write SetAsInteger;
302    end;
303  
304 +  IParameterBlockItemWithTypeName = interface(IParameterBlockItem)
305 +    function getParamTypeName: AnsiString;
306 +  end;
307  
308    {The IStatus interface provides access to error information, if any, returned
309     by the last API call. It can also be used to customise the error message
# Line 211 | Line 312 | type
312     This interface can be accessed from IFirebirdAPI.
313     }
314  
315 +   TIBDataBaseErrorMessage    = (ShowSQLCode,
316 +                                   ShowIBMessage,
317 +                                   ShowSQLMessage);
318 +
319 +   TIBDataBaseErrorMessages   = set of TIBDataBaseErrorMessage;
320 +
321 +   TStatusCode = long;
322 +
323    IStatus = interface
324 <    function GetIBErrorCode: Long;
325 <    function Getsqlcode: Long;
326 <    function GetMessage: string;
324 >    ['{34167722-af38-4831-b08a-93162d58ede3}']
325 >    function InErrorState: boolean;
326 >    function GetIBErrorCode: TStatusCode;
327 >    function Getsqlcode: TStatusCode;
328 >    function GetMessage: AnsiString;
329      function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean;
330      function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages;
331 +    function Clone: IStatus;
332      procedure SetIBDataBaseErrorMessages(Value: TIBDataBaseErrorMessages);
333    end;
334  
# Line 231 | Line 343 | type
343    TArrayBounds = array of TArrayBound;
344  
345    IArrayMetaData = interface
346 +    ['{7dd0aea4-59af-4c2a-b958-565d5025c489}']
347      function GetSQLType: cardinal;
348 <    function GetSQLTypeName: string;
348 >    function GetSQLTypeName: AnsiString;
349      function GetScale: integer;
350      function GetSize: cardinal;
351 +    function GetCharSetWidth: integer;
352      function GetCharSetID: cardinal;
353 <    function GetTableName: string;
354 <    function GetColumnName: string;
353 >    function GetTableName: AnsiString;
354 >    function GetColumnName: AnsiString;
355      function GetDimensions: integer;
356      function GetBounds: TArrayBounds;
357    end;
# Line 262 | Line 376 | type
376    TArrayEventHandler = procedure(Sender: IArray; Reason: TArrayEventReason) of object;
377  
378    IArray = interface(IArrayMetaData)
379 +    ['{631c6bb1-fb49-44fb-a64a-c49859632b88}']
380      function GetArrayID: TISC_QUAD;
381      procedure Clear;
382      function IsEmpty: boolean;
# Line 272 | Line 387 | type
387      function GetAsBoolean(index: array of integer): boolean;
388      function GetAsCurrency(index: array of integer): Currency;
389      function GetAsInt64(index: array of integer): Int64;
390 <    function GetAsDateTime(index: array of integer): TDateTime;
390 >    function GetAsDateTime(index: array of integer): TDateTime; overload;
391 >    procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
392 >    procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
393 >    procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
394 >    procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
395 >    function GetAsUTCDateTime(index: array of integer): TDateTime;
396      function GetAsDouble(index: array of integer): Double;
397      function GetAsFloat(index: array of integer): Float;
398      function GetAsLong(index: array of integer): Long;
399      function GetAsShort(index: array of integer): Short;
400 <    function GetAsString(index: array of integer): String;
400 >    function GetAsString(index: array of integer): AnsiString;
401      function GetAsVariant(index: array of integer): Variant;
402 +    function GetAsBCD(index: array of integer): tBCD;
403      procedure SetAsInteger(index: array of integer; AValue: integer);
404      procedure SetAsBoolean(index: array of integer; AValue: boolean);
405      procedure SetAsCurrency(index: array of integer; Value: Currency);
406      procedure SetAsInt64(index: array of integer; Value: Int64);
407      procedure SetAsDate(index: array of integer; Value: TDateTime);
408 +    procedure SetAsDateTime(index: array of integer; Value: TDateTime); overload;
409 +    procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
410 +    procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZone: AnsiString); overload;
411 +    procedure SetAsTime(index: array of integer; Value: TDateTime); overload;
412 +    procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
413 +    procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
414 +    procedure SetAsUTCDateTime(index: array of integer; aUTCTime: TDateTime);
415      procedure SetAsLong(index: array of integer; Value: Long);
288    procedure SetAsTime(index: array of integer; Value: TDateTime);
289    procedure SetAsDateTime(index: array of integer; Value: TDateTime);
416      procedure SetAsDouble(index: array of integer; Value: Double);
417      procedure SetAsFloat(index: array of integer; Value: Float);
418      procedure SetAsShort(index: array of integer; Value: Short);
419 <    procedure SetAsString(index: array of integer; Value: String);
419 >    procedure SetAsString(index: array of integer; Value: AnsiString);
420      procedure SetAsVariant(index: array of integer; Value: Variant);
421 +    procedure SetAsBcd(index: array of integer; aValue: tBCD);
422      procedure SetBounds(dim, UpperBound, LowerBound: integer);
423      function GetAttachment: IAttachment;
424      function GetTransaction: ITransaction;
# Line 304 | Line 431 | type
431    }
432  
433    IBlobMetaData = interface
434 +    ['{575f3c61-bb33-46a5-8975-bb7d1b6e37cc}']
435      function GetSubType: integer;
436      function GetCharSetID: cardinal;
437      function GetCodePage: TSystemCodePage;
438      function GetSegmentSize: cardinal;
439 <    function GetRelationName: string;
440 <    function GetColumnName: string;
439 >    function GetRelationName: AnsiString;
440 >    function GetColumnName: AnsiString;
441    end;
442  
443    {The Blob Parameter block is used to select a Blob Filter}
444  
445 <  IBPBItem = interface (IParameterBlockItem) end;
445 >  IBPBItem = interface (IParameterBlockItem)
446 >    ['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}']
447 >  end;
448  
449 <  IBPB = specialize IParameterBlock<IBPBItem>;
449 >  IBPB = interface (IParameterBlock<IBPBItem>)
450 >    ['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}']
451 >  end;
452  
453    { The Blob Interface provides access to a blob data item.
454  
# Line 330 | Line 462 | type
462    TBlobType = (btSegmented,btStream);
463  
464    IBlob = interface(IBlobMetaData)
465 +    ['{3090a145-7780-442b-b15b-efd4568b8611}']
466      function GetBPB: IBPB;
467      procedure Cancel;
468      procedure Close;
# Line 340 | Line 473 | type
473                        TotalSize: Int64; var BlobType: TBlobType);
474      function Read(var Buffer; Count: Longint): Longint;
475      function Write(const Buffer; Count: Longint): Longint;
476 <    function LoadFromFile(Filename: string): IBlob;
476 >    function LoadFromFile(Filename: AnsiString): IBlob;
477      function LoadFromStream(S: TStream) : IBlob;
478 <    function SaveToFile(Filename: string): IBlob;
478 >    function SaveToFile(Filename: AnsiString): IBlob;
479      function SaveToStream(S: TStream): IBlob;
480      function GetAsString: rawbytestring;
481      procedure SetAsString(aValue: rawbytestring);
# Line 356 | Line 489 | type
489      the output of an SQL Statement.
490    }
491  
492 +  TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP}
493 +                        dfDateTime,   {SQL DATETIME}
494 +                        dfTime,      {SQL TIME}
495 +                        dfTimestampTZ, {SQL_TIMESTAMP_TZ}
496 +                        dfTimeTZ);       {SQLTIME_TZ
497 +
498    { IColumnMetaData }
499  
500    IColumnMetaData = interface
501 +    ['{c222e6c3-53c1-469f-9e05-0a5c3ef232d8}']
502      function GetIndex: integer;
503      function GetSQLType: cardinal;
504 <    function GetSQLTypeName: string;
504 >    function GetSQLTypeName: AnsiString;
505      function getSubtype: integer;
506 <    function getRelationName: string;
507 <    function getOwnerName: string;
508 <    function getSQLName: string;    {Name of the column}
509 <    function getAliasName: string;  {Alias Name of column or Column Name if no alias}
510 <    function getName: string;       {Disambiguated uppercase Field Name}
506 >    function getRelationName: AnsiString;
507 >    function getOwnerName: AnsiString;
508 >    function getSQLName: AnsiString;    {Name of the column}
509 >    function getAliasName: AnsiString;  {Alias Name of column or Column Name if no alias}
510 >    function getName: AnsiString;       {Disambiguated uppercase Field Name}
511      function getScale: integer;
512      function getCharSetID: cardinal;
513      function getCodePage: TSystemCodePage;
514 +    function GetCharSetWidth: integer;
515      function getIsNullable: boolean;
516      function GetSize: cardinal;
517      function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
518      function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
519 <    property Name: string read GetName;
519 >    function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer;
520 >    function GetStatement: IStatement;
521 >    function GetTransaction: ITransaction;
522 >    function GetAttachment: IAttachment;
523 >    property Name: AnsiString read GetName;
524      property Size: cardinal read GetSize;
525      property SQLType: cardinal read GetSQLType;
526      property Scale: integer read getScale;
# Line 391 | Line 536 | type
536    { IMetaData }
537  
538    IMetaData = interface
539 +    ['{4dafdbb6-0d36-4f1f-9c95-8b132804b965}']
540      function getCount: integer;
541      function getColumnMetaData(index: integer): IColumnMetaData;
542 <    function GetUniqueRelationName: string; {Non empty if all columns come from the same table}
543 <    function ByName(Idx: String): IColumnMetaData;
542 >    function GetUniqueRelationName: AnsiString; {Non empty if all columns come from the same table}
543 >    function ByName(Idx: AnsiString): IColumnMetaData;
544      property ColMetaData[index: integer]: IColumnMetaData read getColumnMetaData; default;
545      property Count: integer read getCount;
546    end;
# Line 414 | Line 560 | type
560  
561  
562    ISQLData = interface(IColumnMetaData)
563 +    ['{3f493e31-7e3f-4606-a07c-b210b9e3619d}']
564 +    function GetStrDataLength: short;
565      function GetAsBoolean: boolean;
566      function GetAsCurrency: Currency;
567      function GetAsInt64: Int64;
568 <    function GetAsDateTime: TDateTime;
568 >    function GetAsDateTime: TDateTime; overload;
569 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
570 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
571 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
572 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
573 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
574 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
575 >    function GetAsUTCDateTime: TDateTime;
576      function GetAsDouble: Double;
577      function GetAsFloat: Float;
578      function GetAsLong: Long;
579      function GetAsPointer: Pointer;
580      function GetAsQuad: TISC_QUAD;
581      function GetAsShort: short;
582 <    function GetAsString: String;
582 >    function GetAsString: AnsiString;
583      function GetIsNull: Boolean;
584      function GetAsVariant: Variant;
585      function GetAsBlob: IBlob; overload;
586      function GetAsBlob(BPB: IBPB): IBlob; overload;
587      function GetAsArray: IArray;
588 +    function GetAsBCD: tBCD;
589 +    function GetAsNumeric: IFBNumeric;
590      property AsDate: TDateTime read GetAsDateTime;
591      property AsBoolean:boolean read GetAsBoolean;
592      property AsTime: TDateTime read GetAsDateTime;
# Line 443 | Line 600 | type
600      property AsPointer: Pointer read GetAsPointer;
601      property AsQuad: TISC_QUAD read GetAsQuad;
602      property AsShort: short read GetAsShort;
603 <    property AsString: String read GetAsString;
603 >    property AsString: AnsiString read GetAsString;
604      property AsVariant: Variant read GetAsVariant ;
605      property AsBlob: IBlob read GetAsBlob;
606      property AsArray: IArray read GetAsArray;
607 +    property AsBCD: tBCD read GetAsBCD;
608 +    property AsNumeric: IFBNumeric read GetAsNumeric;
609      property IsNull: Boolean read GetIsNull;
610      property Value: Variant read GetAsVariant;
611    end;
# Line 458 | Line 617 | type
617    }
618  
619    IResults = interface
620 +    ['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}']
621     function getCount: integer;
622 +   function GetStatement: IStatement;
623     function GetTransaction: ITransaction;
624 <   function ByName(Idx: String): ISQLData;
624 >   function GetAttachment: IAttachment;
625 >   function FieldExists(Idx: AnsiString): boolean;
626 >   function ByName(Idx: AnsiString): ISQLData;
627     function getSQLData(index: integer): ISQLData;
628 <   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar);
628 >   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
629     procedure SetRetainInterfaces(aValue: boolean);
630     property Data[index: integer]: ISQLData read getSQLData; default;
631     property Count: integer read getCount;
# Line 474 | Line 637 | type
637      in turn, used to access the data returned by each field of the current row.
638    }
639    IResultSet = interface(IResults)
640 <    function FetchNext: boolean;
641 <    function GetCursorName: string;
640 >    ['{0ae4979b-7857-4e8c-8918-ec6f155b51a0}']
641 >    function FetchNext: boolean; {fetch next record}
642 >    function FetchPrior: boolean; {fetch previous record}
643 >    function FetchFirst:boolean; {fetch first record}
644 >    function FetchLast: boolean; {fetch last record}
645 >    function FetchAbsolute(position: Integer): boolean; {fetch record by its absolute position in result set}
646 >    function FetchRelative(offset: Integer): boolean; {fetch record by position relative to current}
647 >    function GetCursorName: AnsiString;
648 >    function IsBof: boolean;
649      function IsEof: boolean;
650      procedure Close;
651    end;
652  
653    {The ISQLParam interface is used to provide access to each parameter in a
654 <   parametised SQL Statement. It subclasses IColumnMetaData and this part of
485 <   the interface may be used to access information on the expected SQL Type, etc.
486 <
487 <   It also subclasses ISQLData and this part of the interface may be used to access
488 <   current values for each parameter.
489 <
490 <   Otherwise, the interface comprises the Setter Methods and properties used to
654 >   parametised SQL Statement. The interface comprises the Setter Methods and properties used to
655     set the value of each parameter.
656  
657     Automatic conversion is provided to and from strings. That is GetAsString and
658     SetAsString are safe to use for sql types other than boolean - provided automatic
659     conversion is possible.
660 +
661 +   ISQLParam is subclassed from the IParamMetaData interface. This interface provides
662 +   access to the parameter metadata. This metadata is mutable and can change after
663 +   a parameter is set to a given value. This is acceptable as long as the parameter
664 +   metadata is type compatible with the underlying column metadata and hence the
665 +   parameter value can be converted by Firebird into a value acceptable by the
666 +   underlying column. The column metadata, which is unmutable, can be obtained
667 +   by the ISQLParam.getColMetadata interface. When a statement is prepared, the
668 +   parameter metadata is always initialised to the column metadata.
669    }
670  
671 <  ISQLParam = interface
672 <    function GetIndex: integer;
671 >  IParamMetaData = interface
672 >  ['{4e148c4e-2d48-4991-a263-f66eca05c6aa}']
673      function GetSQLType: cardinal;
674 <    function GetSQLTypeName: string;
674 >    function GetSQLTypeName: AnsiString;
675      function getSubtype: integer;
503    function getName: string;
676      function getScale: integer;
677      function getCharSetID: cardinal;
678      function getCodePage: TSystemCodePage;
679      function getIsNullable: boolean;
680      function GetSize: cardinal;
681 +    property SQLType: cardinal read GetSQLType;
682 +  end;
683 +
684 +  ISQLParam = interface(IParamMetaData)
685 +    ['{b22b4578-6d41-4807-a9a9-d2ec8d1d5a14}']
686 +    function getColMetadata: IParamMetaData;
687 +    function GetStatement: IStatement;
688 +    function GetTransaction: ITransaction;
689 +    function GetAttachment: IAttachment;
690 +    function GetIndex: integer;
691 +    function getName: AnsiString;
692      function GetAsBoolean: boolean;
693      function GetAsCurrency: Currency;
694      function GetAsInt64: Int64;
695 <    function GetAsDateTime: TDateTime;
695 >    function GetAsDateTime: TDateTime; overload;
696 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
697 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
698 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
699 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
700 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
701 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
702 >    function GetAsUTCDateTime: TDateTime;
703      function GetAsDouble: Double;
704      function GetAsFloat: Float;
705      function GetAsLong: Long;
706      function GetAsPointer: Pointer;
707      function GetAsQuad: TISC_QUAD;
708      function GetAsShort: short;
709 <    function GetAsString: String;
709 >    function GetAsString: AnsiString;
710      function GetIsNull: boolean;
711      function GetAsVariant: Variant;
712      function GetAsBlob: IBlob;
713      function GetAsArray: IArray;
714 +    function GetAsBCD: tBCD;
715 +    function GetAsNumeric: IFBNumeric;
716      procedure Clear;
717      function GetModified: boolean;
718      procedure SetAsBoolean(AValue: boolean);
# Line 528 | Line 720 | type
720      procedure SetAsInt64(aValue: Int64);
721      procedure SetAsDate(aValue: TDateTime);
722      procedure SetAsLong(aValue: Long);
723 <    procedure SetAsTime(aValue: TDateTime);
724 <    procedure SetAsDateTime(aValue: TDateTime);
723 >    procedure SetAsTime(aValue: TDateTime); overload;
724 >    procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
725 >    procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
726 >    procedure SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
727 >    procedure SetAsTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
728 >    procedure SetAsDateTime(aValue: TDateTime); overload;
729 >    procedure SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
730 >    procedure SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
731 >    procedure SetAsUTCDateTime(aUTCTime: TDateTime);
732      procedure SetAsDouble(aValue: Double);
733      procedure SetAsFloat(aValue: Float);
734      procedure SetAsPointer(aValue: Pointer);
735      procedure SetAsShort(aValue: Short);
736 <    procedure SetAsString(aValue: String);
736 >    procedure SetAsString(aValue: AnsiString);
737      procedure SetAsVariant(aValue: Variant);
738      procedure SetIsNull(aValue: Boolean);
739      procedure SetAsBlob(aValue: IBlob);
740      procedure SetAsArray(anArray: IArray);
741      procedure SetAsQuad(aValue: TISC_QUAD);
742      procedure SetCharSetID(aValue: cardinal);
743 +    procedure SetAsBcd(aValue: tBCD);
744 +    procedure SetAsNumeric(Value: IFBNumeric);
745      property AsDate: TDateTime read GetAsDateTime write SetAsDate;
746      property AsBoolean:boolean read GetAsBoolean write SetAsBoolean;
747      property AsTime: TDateTime read GetAsDateTime write SetAsTime;
# Line 553 | Line 754 | type
754      property AsLong: Long read GetAsLong write SetAsLong;
755      property AsPointer: Pointer read GetAsPointer write SetAsPointer;
756      property AsShort: Short read GetAsShort write SetAsShort;
757 <    property AsString: String read GetAsString write SetAsString;
757 >    property AsString: AnsiString read GetAsString write SetAsString;
758      property AsVariant: Variant read GetAsVariant write SetAsVariant;
759      property AsBlob: IBlob read GetAsBlob write SetAsBlob;
760      property AsArray: IArray read GetAsArray write SetAsArray;
761 +    property AsBCD: tBCD read GetAsBCD write SetAsBCD;
762 +    property AsNumeric: IFBNumeric read GetAsNumeric write SetAsNumeric;
763      property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad;
764      property Value: Variant read GetAsVariant write SetAsVariant;
765      property IsNull: Boolean read GetIsNull write SetIsNull;
766      property IsNullable: Boolean read GetIsNullable;
767      property Modified: Boolean read getModified;
768 <    property Name: string read GetName;
566 <    property SQLType: cardinal read GetSQLType;
768 >    property Name: AnsiString read GetName;
769    end;
770  
771     {
# Line 571 | Line 773 | type
773     for the input to an SQL Statement
774    }
775  
776 +  { ISQLParams }
777 +
778    ISQLParams = interface
779 +    ['{c6d95ac7-b2b7-461b-b890-afef0acbb077}']
780      function getCount: integer;
781      function getSQLParam(index: integer): ISQLParam;
782 <    function ByName(Idx: String): ISQLParam ;
782 >    function ParamExists(Idx: AnsiString): boolean;
783 >    function ByName(Idx: AnsiString): ISQLParam ;
784      function GetModified: Boolean;
785 +    function GetHasCaseSensitiveParams: Boolean;
786 +    function GetStatement: IStatement;
787 +    function GetTransaction: ITransaction;
788 +    function GetAttachment: IAttachment;
789 +    procedure Clear;
790      property Modified: Boolean read GetModified;
791      property Params[index: integer]: ISQLParam read getSQLParam; default;
792      property Count: integer read getCount;
793    end;
794  
795 +
796 +  TPerfStats = (psCurrentMemory, psMaxMemory,
797 +                psRealTime, psUserTime, psBuffers,
798 +                psReads, psWrites, psFetches,psDeltaMemory);
799 +
800 +  TPerfCounters = array[TPerfStats] of Int64;
801 +
802 +  {Batch Query Execution Support}
803 +
804 +  TBatchCompletionState = (bcExecuteFailed, bcSuccessNoInfo, bcNoMoreErrors);
805 +
806 +  IBatchCompletion = interface
807 +  ['{9bc3d49d-16d9-4606-94e5-ee987103ad92}']
808 +    function getTotalProcessed: cardinal;
809 +    function getState(updateNo: cardinal): TBatchCompletionState;
810 +    function getStatusMessage(updateNo: cardinal): AnsiString;
811 +    function getUpdated: integer;
812 +    function getErrorStatus(var RowNo: integer; var status: IStatus): boolean;
813 +    end;
814 +
815    {The IStatement interface provides access to an SQL Statement once it has been
816     initially prepared. The interface is returned from the IAttachment interface.
817     }
818  
819 +  TStatementFlag = (stHasCursor,stRepeatExecute,stScrollable);
820 +  TStatementFlags = set of TStatementFlag;
821 +
822    IStatement = interface
823 +    ['{a260576d-a07d-4a66-b02d-1b72543fd7cf}']
824      function GetMetaData: IMetaData;  {Output Metadata}
825      function GetSQLParams: ISQLParams;{Statement Parameters}
826 <    function GetPlan: String;
826 >    function GetPlan: AnsiString;
827      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
828      function GetSQLStatementType: TIBSQLStatementTypes;
829 <    function GetSQLText: string;
829 >    function GetSQLStatementTypeName: AnsiString;
830 >    function GetSQLText: AnsiString;
831 >    function GetProcessedSQLText: AnsiString;
832      function GetSQLDialect: integer;
833 +    function GetFlags: TStatementFlags;
834      function IsPrepared: boolean;
835 <    procedure Prepare(aTransaction: ITransaction=nil);
835 >    function HasBatchMode: boolean;
836 >    function IsInBatchMode: boolean;
837 >    procedure Prepare(aTransaction: ITransaction=nil); overload;
838 >    procedure Prepare(CursorName: AnsiString; aTransaction: ITransaction=nil); overload;
839      function Execute(aTransaction: ITransaction=nil): IResults;
840 <    function OpenCursor(aTransaction: ITransaction=nil): IResultSet;
840 >    function OpenCursor(aTransaction: ITransaction=nil): IResultSet; overload;
841 >    function OpenCursor(Scrollable: boolean; aTransaction: ITransaction=nil): IResultSet; overload;
842      function GetAttachment: IAttachment;
843      function GetTransaction: ITransaction;
844      procedure SetRetainInterfaces(aValue: boolean);
845 +    procedure EnableStatistics(aValue: boolean);
846 +    function GetPerfStatistics(var stats: TPerfCounters): boolean;
847 +    {IBatch interface support}
848 +    procedure AddToBatch;
849 +    function ExecuteBatch(aTransaction: ITransaction=nil): IBatchCompletion;
850 +    procedure CancelBatch;
851 +    function GetBatchCompletion: IBatchCompletion;
852 +    function GetBatchRowLimit: integer;
853 +    procedure SetBatchRowLimit(aLimit: integer);
854 +    {Stale Reference Check}
855 +    procedure SetStaleReferenceChecks(Enable:boolean); {default true}
856 +    function GetStaleReferenceChecks: boolean;
857 +
858      property MetaData: IMetaData read GetMetaData;
859      property SQLParams: ISQLParams read GetSQLParams;
860      property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType;
861    end;
862  
863 +  ITrInfoItem = interface
864 +    ['{41455e1a-f84e-4e26-aff0-1a78e8b69cfe}']
865 +    function getItemType: byte;
866 +    function getSize: integer;
867 +    function getAsString: AnsiString;
868 +    function getAsInteger: int64;
869 +    procedure DecodeTraIsolation(var IsolationType, RecVersion: byte);
870 +  end;
871 +
872 +  { ITrInformation }
873 +
874 +  ITrInformation = interface
875 +    ['{e6ea4a52-c1a1-44ba-9609-c8bcc7cba7b2}']
876 +    function GetCount: integer;
877 +    function GetItem(index: integer): ITrInfoItem;
878 +    function Find(ItemType: byte): ITrInfoItem;
879 +    procedure PrintBuf; {can be used to print buffer in hex for debugging}
880 +    property Count: integer read GetCount;
881 +    property Items[index: integer]: ITrInfoItem read getItem; default;
882 +  end;
883 +
884    {Transaction Parameter Block: (TPB)
885  
886     The TPB provides the parameters used when starting a transaction. It is allocated
# Line 616 | Line 892 | type
892     found in the Interbase 6.0 API Guide.
893    }
894  
895 <  ITPBItem = interface(IParameterBlockItem) end;
895 >  ITPBItem = interface(IParameterBlockItemWithTypeName)
896 >    ['{544c1f2b-7c12-4a87-a4a5-face7ea72671}']
897 >  end;
898  
899 <  ITPB = specialize IParameterBlock<ITPBItem>;
899 >  ITPB = interface(IParameterBlockWithTypeNames<ITPBItem>)
900 >    ['{7369b0ff-defe-437b-81fe-19b211d42d25}']
901 >    function AsText: AnsiString;
902 >  end;
903  
904    {The ITransactionAction interface provides access to a Transaction once it
905     has been initially started. After a Commit or Rollback, a transaction
# Line 630 | Line 911 | type
911  
912    TTransactionAction  = (TARollback, TACommit, TACommitRetaining, TARollbackRetaining);
913    TTransactionCompletion = TARollback.. TACommit;
914 +  TTrCompletionState = (trCommitted, trRolledback, trCommitFailed, trRollbackFailed);
915 +
916  
917    ITransaction = interface
918 +    ['{30928d0e-a9d7-4c61-b7cf-14f4f38abe2a}']
919      function getTPB: ITPB;
920      procedure Start(DefaultCompletion: TTransactionCompletion=taCommit);
921      function GetInTransaction: boolean;
922 +    function GetIsReadOnly: boolean;
923 +    function GetTransactionID: integer;
924 +    function GetJournalingActive(attachment: IAttachment): boolean;
925 +    function GetDefaultCompletion: TTransactionCompletion;
926      procedure PrepareForCommit; {Two phase commit - stage 1}
927 <    procedure Commit(Force: boolean=false);
927 >    function Commit(Force: boolean=false): TTrCompletionState;
928      procedure CommitRetaining;
929      function HasActivity: boolean;
930 <    procedure Rollback(Force: boolean=false);
930 >    function Rollback(Force: boolean=false): TTrCompletionState;
931      procedure RollbackRetaining;
932      function GetAttachmentCount: integer;
933      function GetAttachment(index: integer): IAttachment;
934 +    function GetTrInformation(Requests: array of byte): ITrInformation; overload;
935 +    function GetTrInformation(Request: byte): ITrInformation; overload;
936 +    function GetTransactionName: AnsiString;
937 +    procedure SetTransactionName(aValue: AnsiString);
938      property InTransaction: boolean read GetInTransaction;
939 +    property TransactionName: AnsiString read GetTransactionName write SetTransactionName;
940    end;
941  
942    { The IEvents Interface is used to handle events from a single database. The
# Line 659 | Line 952 | type
952    }
953  
954    TEventInfo = record
955 <    EventName: string;
955 >    EventName: AnsiString;
956      Count: integer;
957    end;
958  
# Line 670 | Line 963 | type
963    { IEvents }
964  
965    IEvents = interface
966 +    ['{6a0be233-ed08-4524-889c-2e45d0c20e5f}']
967      procedure GetEvents(EventNames: TStrings);
968      procedure SetEvents(EventNames: TStrings); overload;
969      procedure SetEvents(EventName: string); overload;
# Line 680 | Line 974 | type
974      function GetAttachment: IAttachment;
975    end;
976  
977 +  TTZTextOptions = (tzOffset,      {Time Zone Rendered as an offset to GMT}
978 +                    tzGMT,         {No Time Zone. Time part is always rendered in GMT}
979 +                    tzOriginalID); {Time Zone shown as originally entered}
980 +
981 +  {The ITimeZoneServices interface provides access to the time zone database
982 +   used for the attachment. It may be used in support of TIMESTAMP WITH TIME ZONE
983 +   and TIME WITH TIME ZONE data types.}
984 +
985 +  ITimeZoneServices = interface
986 +    ['{163821f5-ebef-42b9-ac60-8ac4b5c09954}']
987 +    {utility functions}
988 +    function TimeZoneID2TimeZoneName(aTimeZoneID: TFBTimeZoneID): AnsiString;
989 +    function TimeZoneName2TimeZoneID(aTimeZone: AnsiString): TFBTimeZoneID;
990 +    function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
991 +    function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
992 +    function GMTToLocalTime(aGMTTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
993 +    function GMTToLocalTime(aGMTTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
994 +    function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZone: AnsiString): integer; overload;
995 +    function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): integer; overload;
996 +
997 +    {Time Zone DB Information}
998 +    function UsingRemoteTZDB: boolean;
999 +    procedure SetUseLocalTZDB(useLocalTZDB: boolean);
1000 +    function GetLocalTimeZoneName: AnsiString;
1001 +    function GetLocalTimeZoneID: TFBTimeZoneID;
1002 +    procedure GetTimeZoneInfo(aTimeZone: AnsiString; OnDate: TDateTime;
1003 +                           var ZoneOffset, DSTOffset, EffectiveOffset: integer);
1004 +    {Configurable Options}
1005 +    function GetTimeTZDate: TDateTime;
1006 +    procedure SetTimeTZDate(aDate: TDateTime);
1007 +    function GetTZTextOption: TTZTextOptions;
1008 +    procedure SetTZTextOption(aOptionValue: TTZTextOptions);
1009 +  end;
1010 +
1011    {The IDBInformation Interface.
1012  
1013     An IDBInformation interface is returned by the  IAttachment GetDBInformation
# Line 703 | Line 1031 | type
1031    TDBOperationCounts = array of TDBOperationCount;
1032  
1033    IDBInfoItem = interface
1034 +    ['{eeb97b51-ec0f-473f-9f75-c1721f055fcb}']
1035      function getItemType: byte;
1036      function getSize: integer;
1037      procedure getRawBytes(var Buffer);
1038 <    function getAsString: string;
1039 <    function getAsInteger: integer;
1040 <    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: string);
1038 >    function getAsString: AnsiString;
1039 >    function getAsInteger: int64;
1040 >    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString);
1041      function getAsBytes: TByteArray;
1042 <    procedure DecodeVersionString(var Version: byte; var VersionString: string);
1042 >    function getAsDateTime: TDateTime;
1043 >    procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
1044      function getOperationCounts: TDBOperationCounts;
1045      procedure DecodeUserNames(UserNames: TStrings);
1046  
# Line 718 | Line 1048 | type
1048      function GetCount: integer;
1049      function GetItem(index: integer): IDBInfoItem;
1050      function Find(ItemType: byte): IDBInfoItem;
1051 <    property AsInteger: integer read getAsInteger;
1052 <    property AsString: string read GetAsString;
1051 >    property AsInteger: int64 read getAsInteger;
1052 >    property AsString: AnsiString read GetAsString;
1053      property Count: integer read GetCount;
1054      property Items[index: integer]: IDBInfoItem read getItem; default;
1055    end;
# Line 727 | Line 1057 | type
1057    { IDBInformation }
1058  
1059    IDBInformation = interface
1060 +    ['{7ac6777f-f0a9-498a-9f5c-4a57a554df81}']
1061      function GetCount: integer;
1062      function GetItem(index: integer): IDBInfoItem;
1063      function Find(ItemType: byte): IDBInfoItem;
# Line 735 | Line 1066 | type
1066      property Items[index: integer]: IDBInfoItem read getItem; default;
1067    end;
1068  
1069 +  {The Database Information Request Block is used to pass requests for
1070 +   database information where at least one item requested has a parameter.
1071 +   At present, this is only fb_info_page_contents which has a single
1072 +   integer parameter.}
1073 +
1074 +  IDIRBItem = interface(IParameterBlockItem)
1075 +    ['{d34a7511-8435-4a24-81a7-5103d218d234}']
1076 +  end;
1077 +
1078 +  IDIRB = interface(IParameterBlock<IDIRBItem>)
1079 +    ['{1010e5ac-0a8f-403b-a302-91625e9d9579}']
1080 +  end;
1081 +
1082 +
1083    {The Database Parameter Block (DPB).
1084  
1085     The DPB provides the parameters used when connecting to a database. It is allocated
# Line 746 | Line 1091 | type
1091     found in the Interbase 6.0 API Guide.
1092     }
1093  
1094 <  IDPBItem = interface(IParameterBlockItem) end;
1094 >  IDPBItem = interface(IParameterBlockItemWithTypeName)
1095 >    ['{123d4ad0-087a-4cd1-a344-1b3d03b30673}']
1096 >  end;
1097 >
1098 >   IDPB = interface(IParameterBlockWithTypeNames<IDPBItem>)
1099 >     ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
1100 >   end;
1101 >
1102 >   {Journaling options. Default is [joReadWriteTransactions,joModifyQueries] }
1103  
1104 <  IDPB = specialize IParameterBlock<IDPBItem>;
1104 >   TJournalOption = (joReadOnlyTransactions, joReadWriteTransactions,
1105 >                     joModifyQueries, joReadOnlyQueries,joNoServerTable);
1106 >
1107 >   TJournalOptions = set of TJournalOption;
1108  
1109    {The IAttachment interface provides access to a Database Connection. It may be
1110     used to:
# Line 778 | Line 1134 | type
1134    { IAttachment }
1135  
1136    IAttachment = interface
1137 +    ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
1138 +    function getFirebirdAPI: IFirebirdAPI;
1139      function getDPB: IDPB;
1140      function AllocateBPB: IBPB;
1141 +    function AllocateDIRB: IDIRB;
1142      procedure Connect;
1143      procedure Disconnect(Force: boolean=false);
1144      function IsConnected: boolean;
1145      procedure DropDatabase;
1146 <    function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
1147 <    function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
1148 <    procedure ExecImmediate(transaction: ITransaction; sql: string; SQLDialect: integer); overload;
1149 <    procedure ExecImmediate(TPB: array of byte; sql: string; SQLDialect: integer); overload;
1150 <    procedure ExecImmediate(transaction: ITransaction; sql: string); overload;
1151 <    procedure ExecImmediate(TPB: array of byte; sql: string); overload;
1152 <    function ExecuteSQL(TPB: array of byte; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
1153 <    function ExecuteSQL(transaction: ITransaction; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
1154 <    function ExecuteSQL(TPB: array of byte; sql: string; params: array of const): IResults; overload;
1155 <    function ExecuteSQL(transaction: ITransaction; sql: string; params: array of const): IResults; overload;
1156 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
1157 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer;
1146 >    function StartTransaction(TPB: array of byte;
1147 >                              DefaultCompletion: TTransactionCompletion=taCommit;
1148 >                              aName: AnsiString=''): ITransaction; overload;
1149 >    function StartTransaction(TPB: ITPB;
1150 >                              DefaultCompletion: TTransactionCompletion=taCommit;
1151 >                              aName: AnsiString=''): ITransaction; overload;
1152 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; SQLDialect: integer); overload;
1153 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString; SQLDialect: integer); overload;
1154 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload;
1155 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload;
1156 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
1157 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
1158 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload;
1159 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload;
1160 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1161 >                             Scrollable: boolean=false): IResultSet; overload;
1162 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1163 >                             params: array of const): IResultSet; overload;
1164 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; Scrollable: boolean=false): IResultSet; overload;
1165 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; Scrollable: boolean;
1166 >                             params: array of const): IResultSet; overload;
1167 >    function OpenCursor(transaction: ITransaction; sql: AnsiString;
1168 >                             params: array of const): IResultSet; overload;
1169 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; Scrollable: boolean;
1170 >                             params: array of const): IResultSet; overload;
1171 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1172 >                             Scrollable: boolean=false): IResultSet; overload;
1173 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1174                               params: array of const): IResultSet; overload;
1175 <    function OpenCursor(transaction: ITransaction; sql: string): IResultSet; overload;
801 <    function OpenCursor(transaction: ITransaction; sql: string;
1175 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; Scrollable: boolean;
1176                               params: array of const): IResultSet; overload;
1177 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
1178 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer;
1177 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; Scrollable: boolean=false): IResultSet; overload;
1178 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString;
1179                               params: array of const): IResultSet; overload;
1180 <    function OpenCursorAtStart(transaction: ITransaction; sql: string): IResultSet; overload;
807 <    function OpenCursorAtStart(transaction: ITransaction; sql: string;
1180 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; Scrollable: boolean;
1181                               params: array of const): IResultSet; overload;
1182 <    function OpenCursorAtStart(sql: string): IResultSet; overload;
1183 <    function OpenCursorAtStart(sql: string;
1182 >    function OpenCursorAtStart(sql: AnsiString; Scrollable: boolean=false): IResultSet; overload;
1183 >    function OpenCursorAtStart(sql: AnsiString; Scrollable: boolean;
1184                               params: array of const): IResultSet; overload;
1185 <    function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; overload;
1186 <    function Prepare(transaction: ITransaction; sql: string): IStatement; overload;
1187 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
1188 <                       aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload;
1189 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
1190 <                       GenerateParamNames: boolean=false): IStatement; overload;
1185 >    function OpenCursorAtStart(sql: AnsiString;
1186 >                             params: array of const): IResultSet; overload;
1187 >    function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; CursorName: AnsiString=''): IStatement; overload;
1188 >    function Prepare(transaction: ITransaction; sql: AnsiString; CursorName: AnsiString=''): IStatement; overload;
1189 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1190 >                       aSQLDialect: integer; GenerateParamNames: boolean=false;
1191 >                       CaseSensitiveParams: boolean = false; CursorName: AnsiString=''): IStatement; overload;
1192 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1193 >                       GenerateParamNames: boolean=false;
1194 >                       CaseSensitiveParams: boolean = false; CursorName: AnsiString=''): IStatement; overload;
1195  
1196      {Events}
1197      function GetEventHandler(Events: TStrings): IEvents; overload;
1198 <    function GetEventHandler(Event: string): IEvents; overload;
1198 >    function GetEventHandler(Event: AnsiString): IEvents; overload;
1199  
1200      {Blob - may use to open existing Blobs. However, ISQLData.AsBlob is preferred}
1201  
1202 <    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: string; BPB: IBPB=nil): IBlob; overload;
1202 >    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
1203      function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
1204      function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
1205 <    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
1205 >    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
1206 >    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;  overload;
1207 >    function GetInlineBlobLimit: integer;
1208 >    procedure SetInlineBlobLimit(limit: integer);
1209  
1210      {Array - may use to open existing arrays. However, ISQLData.AsArray is preferred}
1211  
1212 <    function OpenArray(transaction: ITransaction; RelationName, ColumnName: string; ArrayID: TISC_QUAD): IArray;
1213 <    function CreateArray(transaction: ITransaction; RelationName, ColumnName: string): IArray; overload;
1212 >    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload;
1213 >    function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload;
1214 >    function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload;
1215      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
1216 +    function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
1217 +                  Scale: integer; size: cardinal; charSetID: cardinal; dimensions: cardinal;
1218 +                  bounds: TArrayBounds): IArrayMetaData;
1219  
1220      {Database Information}
1221      function GetSQLDialect: integer;
1222 <    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: string): IBlobMetaData;
1223 <    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: string): IArrayMetaData;
1222 >    function GetAttachmentID: integer;
1223 >    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData;
1224 >    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
1225      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
1226      function GetDBInformation(Request: byte): IDBInformation; overload;
1227 +    function GetDBInformation(Requests: IDIRB): IDBInformation; overload;
1228 +    function GetConnectString: AnsiString;
1229 +    function GetRemoteProtocol: AnsiString;
1230 +    function GetAuthenticationMethod: AnsiString;
1231 +    function GetSecurityDatabase: AnsiString;
1232 +    function GetODSMajorVersion: integer;
1233 +    function GetODSMinorVersion: integer;
1234 +    procedure getFBVersion(version: TStrings);
1235      function HasActivity: boolean;
1236 <  end;
1236 >    function HasDecFloatSupport: boolean;
1237 >    function HasBatchMode: boolean;
1238 >    function HasScollableCursors: boolean;
1239 >    function HasTable(aTableName: AnsiString): boolean;  {case sensitive}
1240 >    function HasFunction(aFunctionName: AnsiString): boolean; {case sensitive}
1241 >    function HasProcedure(aProcName: AnsiString): boolean; {case sensitive}
1242 >
1243 >    {Character Sets}
1244 >    function GetCharSetID: integer; {connection character set}
1245 >    function HasDefaultCharSet: boolean;
1246 >    function GetDefaultCharSetID: integer;
1247 >    function GetCharsetName(CharSetID: integer): AnsiString;
1248 >    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
1249 >    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
1250 >    function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean;
1251 >    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
1252 >    procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
1253 >      AllowReverseLookup:boolean; out CharSetID: integer);
1254 >
1255 >    {Time Zone Database}
1256 >    function GetTimeZoneServices: ITimeZoneServices;
1257 >    function HasTimeZoneSupport: boolean;
1258 >
1259 >    {Client side Journaling}
1260 >    function JournalingActive: boolean;
1261 >    function GetJournalOptions: TJournalOptions;
1262 >    function StartJournaling(aJournalLogFile: AnsiString): integer; overload;
1263 >    function StartJournaling(aJournalLogFile: AnsiString; Options: TJournalOptions): integer; overload;
1264 >    function StartJournaling(S: TStream; Options: TJournalOptions): integer; overload;
1265 >    procedure StopJournaling(RetainJournal: boolean);
1266 > end;
1267  
1268 <  TProtocol = (TCP, SPX, NamedPipe, Local);
1268 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
1269 >  TProtocol = TCP..xnet;
1270  
1271    {Service Parameter Block (SPB).
1272  
# Line 856 | Line 1280 | type
1280  
1281    }
1282  
1283 <  ISPBItem = interface(IParameterBlockItem) end;
1283 >  ISPBItem = interface(IParameterBlockItemWithTypeName)
1284 >    ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
1285 >  end;
1286  
1287 <  ISPB = specialize IParameterBlock<ISPBItem>;
1287 >  ISPB = interface(IParameterBlockWithTypeNames<ISPBItem>)
1288 >    ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
1289 >  end;
1290  
1291    {Service Query Parameter Block (SQPB).
1292  
# Line 867 | Line 1295 | type
1295    }
1296  
1297    ISQPBItem = interface(IParameterBlockItem)
1298 +    ['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}']
1299      function CopyFrom(source: TStream; count: integer): integer;
1300    end;
1301  
1302 <  ISQPB = specialize IParameterBlock<ISQPBItem>;
1302 >  ISQPB = interface(IParameterBlock<ISQPBItem>)
1303 >    ['{8553e66b-ee62-498b-8431-dff030211447}']
1304 >  end;
1305  
1306    {Service Request Block (SRB).
1307  
# Line 884 | Line 1315 | type
1315  
1316    }
1317  
1318 <  ISRBItem = interface(IParameterBlockItem) end;
1318 >  ISRBItem = interface(IParameterBlockItem)
1319 >    ['{47ec790e-f265-4b30-9dcd-261e51677245}']
1320 >   end;
1321  
1322 <  ISRB = specialize IParameterBlock<ISRBItem>;
1322 >  ISRB = interface(IParameterBlock<ISRBItem>)
1323 >    ['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}']
1324 >  end;
1325  
1326    {The Service Query Results Interface.
1327  
# Line 904 | Line 1339 | type
1339    }
1340  
1341    IServiceQueryResultSubItem = interface
1342 +    ['{8a4c381e-9923-4cc9-a96b-553729248640}']
1343      function getItemType: byte;
1344      function getSize: integer;
1345      procedure getRawBytes(var Buffer);
1346 <    function getAsString: string;
1347 <    function getAsInteger: integer;
1346 >    function getAsString: AnsiString;
1347 >    function getAsInteger: int64;
1348      function getAsByte: byte;
1349      function CopyTo(stream: TStream; count: integer): integer;
1350 <    property AsString: string read getAsString;
1351 <    property AsInteger: integer read getAsInteger;
1350 >    property AsString: AnsiString read getAsString;
1351 >    property AsInteger: int64 read getAsInteger;
1352      property AsByte: byte read getAsByte;
1353    end;
1354  
1355    IServiceQueryResultItem = interface(IServiceQueryResultSubItem)
1356 +    ['{b2806886-206c-4024-8df9-5fe0a7630a5e}']
1357      function getCount: integer;
1358      function getItem(index: integer): IServiceQueryResultSubItem;
1359      function find(ItemType: byte): IServiceQueryResultSubItem;
# Line 925 | Line 1362 | type
1362    end;
1363  
1364    IServiceQueryResults = interface
1365 +    ['{8fbbef7d-fe03-4409-828a-a787d34ef531}']
1366      function getCount: integer;
1367      function getItem(index: integer): IServiceQueryResultItem;
1368      function find(ItemType: byte): IServiceQueryResultItem;
# Line 933 | Line 1371 | type
1371      property Count: integer read getCount;
1372    end;
1373  
1374 +  IFirebirdLibrary = interface;
1375 +
1376    {The IServiceManager interface provides access to a service manager. It can
1377     used to Detach and re-attach to Service Manager, to start services and to
1378     query the service manager.
# Line 943 | Line 1383 | type
1383    { IServiceManager }
1384  
1385    IServiceManager = interface
1386 +    ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1387 +    function getFirebirdAPI: IFirebirdAPI;
1388      function getSPB: ISPB;
1389 <    function getServerName: string;
1389 >    function getServerName: AnsiString;
1390 >    function getProtocol: TProtocol;
1391 >    function getPortNo: AnsiString;
1392      procedure Attach;
1393      procedure Detach(Force: boolean=false);
1394      function IsAttached: boolean;
1395      function AllocateSRB: ISRB;
1396      function AllocateSQPB: ISQPB;
1397 <    procedure Start(Request: ISRB);
1398 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1399 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1397 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1398 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1399 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1400 >  end;
1401 >
1402 >  {Tbe Firebird Library API used to get information about the Firebird library}
1403 >
1404 >
1405 >  IFirebirdLibrary = interface
1406 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1407 >    function GetHandle: TLibHandle;
1408 >    function GetLibraryName: string;
1409 >    function GetLibraryFilePath: string;
1410 >    function GetFirebirdAPI: IFirebirdAPI;
1411    end;
1412  
1413    {The Firebird API.
# Line 963 | Line 1418 | type
1418     The interface is returned by the FirebirdAPI function.
1419    }
1420  
1421 +  { IFirebirdAPI }
1422 +
1423    IFirebirdAPI = interface
1424 +    ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1425      {Database connections}
1426      function AllocateDPB: IDPB;
1427 <    function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1428 <    function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment;
1427 >    function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1428 >    function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1429 >    function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1430  
1431      {Start Transaction against multiple databases}
1432      function AllocateTPB: ITPB;
1433      function StartTransaction(Attachments: array of IAttachment;
1434 <             TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
1434 >             TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit;
1435 >             aName: AnsiString=''): ITransaction; overload;
1436      function StartTransaction(Attachments: array of IAttachment;
1437 <             TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
1437 >             TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit;
1438 >             aName: AnsiString=''): ITransaction; overload;
1439  
1440      {Service Manager}
1441      function HasServiceAPI: boolean;
1442      function AllocateSPB: ISPB;
1443 <    function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager;
1443 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1444 >    function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1445  
1446      {Information}
1447      function GetStatus: IStatus;
986    function GetLibraryName: string;
1448      function HasRollbackRetaining: boolean;
1449      function IsEmbeddedServer: boolean;
1450 <    function GetImplementationVersion: string;
1450 >    function GetImplementationVersion: AnsiString;
1451 >    function GetClientMajor: integer;
1452 >    function GetClientMinor: integer;
1453 >    function HasDecFloatSupport: boolean;
1454 >    function HasLocalTZDB: boolean;
1455 >    function HasTimeZoneSupport: boolean;
1456 >    function HasExtendedTZSupport: boolean;
1457  
1458      {Firebird 3 API}
1459      function HasMasterIntf: boolean;
1460 <    function GetIMaster: TObject;
1461 <
995 <    {utility}
996 <    function GetCharsetName(CharSetID: integer): string;
997 <    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
998 <    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
999 <    function CharSetName2CharSetID(CharSetName: string; var CharSetID: integer): boolean;
1000 <    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
1460 >    function GetIMaster: TObject;  deprecated 'Use FirebirdAPI.QueryInterface and FBClientLib.pas IFBIMasterProvider instead';
1461 >    function GetFBLibrary: IFirebirdLibrary;
1462   end;
1463  
1464   type
# Line 1014 | Line 1475 | type
1475     private
1476       FSQLCode: Long;
1477     public
1478 <     constructor Create(ASQLCode: Long; Msg: string);
1478 >     constructor Create(ASQLCode: Long; Msg: AnsiString);
1479       property SQLCode: Long read FSQLCode;
1480     end;
1481  
# Line 1023 | Line 1484 | type
1484     EIBInterBaseError = class(EIBError)
1485     private
1486       FIBErrorCode: Long;
1487 +     FStatus: IStatus;
1488     public
1489 <     constructor Create(Status: IStatus); overload;
1490 <     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: string); overload;
1489 >     constructor Create(aStatus: IStatus); overload;
1490 >     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload;
1491       property IBErrorCode: Long read FIBErrorCode;
1492 +     property Status: IStatus read FStatus;
1493     end;
1494  
1495     {IB Client Exceptions}
1496     EIBClientError = class(EIBError);
1497  
1498 < {IBError is used internally and by IBX to throw an EIBClientError}
1499 <
1037 < procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1498 >   {Used to explicitly report a Batch Buffer overflow}
1499 >   EIBBatchBufferOverflow = class(EIBError);
1500  
1501   {The Firebird API function is used to access the IFirebirdAPI interface.
1502  
# Line 1045 | Line 1507 | procedure IBError(ErrMess: TIBClientErro
1507   function FirebirdAPI: IFirebirdAPI;
1508  
1509   {IBX support functions. Probably best ignored i.e. always used the FirebirdAPI
1510 < functino to load the library and check if it's loaded.}
1510 > function to load the library and check if it's loaded.}
1511  
1512   function TryIBLoad: Boolean;
1513   procedure CheckIBLoaded;
1514  
1515 + {If you want to explicitly load the Firebird library from a
1516 + non-default location then use this function and its GetFirebirdAPI function
1517 + to get the API.}
1518 +
1519 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1520 +
1521 + {$if not declared(Null)} {Needed for Delphi}
1522 + function Null: Variant;       // Null standard constant
1523 + {$define NEEDNULLFUNCTION}
1524 + {$ifend}
1525 +
1526   implementation
1527  
1528 < uses FBClientAPI
1528 > uses FBClientAPI {$if not declared(NULL)}, Variants {$ifend}
1529    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1530    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1531  
1532 < var FFirebirdAPI: IFirebirdAPI;
1532 > var FDefaultFBLibrary: IFirebirdLibrary;
1533 >
1534 > type
1535 >
1536 >  { TFBLibrary }
1537 >
1538 >  TFBLibraryImpl = class(TFBLibrary)
1539 >  protected
1540 >    function GetFirebird3API: IFirebirdAPI; override;
1541 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1542 >  end;
1543 >
1544 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1545 > begin
1546 > {$IFDEF USEFIREBIRD3API}
1547 > Result := TFB30ClientAPI.Create(self);
1548 > {$ELSE}
1549 > Result := nil;
1550 > {$ENDIF}
1551 > end;
1552 >
1553 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1554 > begin
1555 >  {$IFDEF USELEGACYFIREBIRDAPI}
1556 >  Result := TFB25ClientAPI.Create(self);
1557 >  {$ELSE}
1558 >  Result := nil;
1559 >  {$ENDIF}
1560 > end;
1561  
1562   function FirebirdAPI: IFirebirdAPI;
1563   begin
1564 <  if FFirebirdAPI = nil then
1564 >  if FDefaultFBLibrary = nil then
1565      CheckIBLoaded;
1566 <  Result := FFirebirdAPI;
1566 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1567   end;
1568  
1569   function TryIBLoad: Boolean;
1570 + var fblib: IFirebirdLibrary;
1571   begin
1572 < Result := FFirebirdAPI <> nil;
1572 > Result := FDefaultFBLibrary <> nil;
1573   try
1072  {$IFDEF USEFIREBIRD3API}
1574    if not Result then
1575    begin
1576 <    FFirebirdAPI := TFB30ClientAPI.Create;
1577 <    Result := FFirebirdAPI.HasMasterIntf;
1578 <  end;
1579 <  {$ENDIF}
1079 <  {$IFDEF USELEGACYFIREBIRDAPI}
1080 <  if not Result then
1081 <  begin
1082 <    FFirebirdAPI := nil;
1083 <    FFirebirdAPI := TFB25ClientAPI.Create;
1084 <    Result := true;
1085 <  end;
1086 <  {$ENDIF}
1087 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1088 <  begin
1089 <    Result := false;
1090 <    FFirebirdAPI := nil;
1576 >    fblib := TFBLibraryImpl.Create;
1577 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1578 >      FDefaultFBLibrary := fblib;
1579 >    Result := FDefaultFBLibrary <> nil;
1580    end;
1581   except
1582     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1101 | Line 1590 | begin
1590      IBError(ibxeInterBaseMissing, [nil]);
1591   end;
1592  
1593 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1594 + var fblib: IFirebirdLibrary;
1595 + begin
1596 +  if trim(aLibPathName) = '' then
1597 +  begin
1598 +    CheckIBLoaded;
1599 +    Result := FDefaultFBLibrary;
1600 +  end
1601 +  else
1602 +  begin
1603 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1604 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1605 +      IBError(ibxeInterBaseMissing, [nil]);
1606 +    Result := fblib;
1607 +  end;
1608 + end;
1609 +
1610   { EIBError }
1611  
1612 < constructor EIBError.Create(ASQLCode: Long; Msg: string);
1612 > constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
1613   begin
1614    inherited Create(Msg);
1615    FSQLCode := ASQLCode;
# Line 1111 | Line 1617 | end;
1617  
1618   { EIBInterBaseError }
1619  
1620 < constructor EIBInterBaseError.Create(Status: IStatus);
1620 > constructor EIBInterBaseError.Create(aStatus: IStatus);
1621   begin
1622 <  inherited Create(Status.Getsqlcode,Status.GetMessage);
1623 <  FIBErrorCode := Status.GetIBErrorCode;
1622 >  inherited Create(aStatus.Getsqlcode,aStatus.GetMessage);
1623 >  FIBErrorCode := aStatus.GetIBErrorCode;
1624 >  FStatus := aStatus.Clone;
1625   end;
1626  
1627   constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long;
1628 <  Msg: string);
1628 >  Msg: AnsiString);
1629   begin
1630    inherited Create(ASQLCode,Msg);
1631    FIBErrorCode := AIBErrorCode;
1632   end;
1633  
1634 < procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1635 < begin
1636 <  raise EIBClientError.Create(Ord(ErrMess),
1637 <                              Format(GetErrorMessage(ErrMess), Args));
1638 < end;
1634 > {$ifdef NEEDNULLFUNCTION}
1635 > function Null: Variant;       // Null standard constant
1636 >   begin
1637 >     VarClearProc(TVarData(Result));
1638 >     TVarData(Result).VType := varnull;
1639 >   end;
1640 > {$endif}
1641  
1642   initialization
1643 <  FFirebirdAPI := nil;
1643 >  FDefaultFBLibrary := nil;
1644  
1645 + finalization
1646 +  FDefaultFBLibrary := nil;
1647  
1648   end.
1649  

Comparing:
ibx/trunk/fbintf/IB.pas (property svn:eol-style), Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
ibx/branches/udr/client/IB.pas (property svn:eol-style), Revision 391 by tony, Thu Jan 27 16:34:24 2022 UTC

# Line 0 | Line 1
1 + native

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines