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

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 387 by tony, Wed Jan 19 13:34:42 2022 UTC

# Line 0 | Line 1
1 + native

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines