ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/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.
Revision 310 by tony, Tue Jul 21 08:20:03 2020 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;
133 >
134 > const
135 >  {Interface version information}
136 >  FBIntf_Major = 1;
137 >  FBIntf_Minor = 1;
138 >  FBIntf_Release = 6;
139 >  FBIntf_Version = '1.1.6';
140  
141   {These include files are converted from the 'C' originals in the Firebird API
142   and define the various constants used by the API}
143  
144 < {$I consts_pub.inc}
145 < {$I inf_pub.inc}
146 < {$I configkeys.inc}
144 > {$I 'include/consts_pub.inc'}
145 > {$I 'include/inf_pub.inc'}
146 > {$I 'include/configkeys.inc'}
147  
148   {The following constants define the values return by calls to the GetSQLType
149   methods provided by several of the interfaces defined below.}
# Line 160 | Line 179 | type
179     PGDS__QUAD           = ^TGDS__QUAD;
180     PISC_QUAD            = ^TISC_QUAD;
181  
182 + {$IFNDEF FPC}
183 + {Delphi missing definitions}
184 + type
185 +  TLibHandle = THandle;
186 +
187 + const
188 +  NilHandle = 0;
189 +  DirectorySeparator = '\';
190 +
191 + {Delphi only seems to define CP_UTF8 and CP_UTF16}
192 + const
193 +  CP_ACP     = 0;     // default to ANSI code page
194 +  CP_OEMCP   = 1;     // default to OEM (console) code page
195 +  CP_UTF16BE = 1201;  // unicodeFFFE
196 +  CP_UTF7    = 65000; // utf-7
197 +  CP_ASCII   = 20127; // us-ascii
198 +  CP_NONE    = $FFFF; // rawbytestring encoding
199 +
200 + {$ENDIF}
201 +
202 + type
203 + {$IF not declared(TSystemCodePage)}
204 +  TSystemCodePage = word; {not defined in Delphi}
205 + {$IFEND}
206 +
207    TIBSQLStatementTypes =
208                   (SQLUnknown, SQLSelect, SQLInsert,
209                    SQLUpdate, SQLDelete, SQLDDL,
210                    SQLGetSegment, SQLPutSegment,
211                    SQLExecProcedure, SQLStartTransaction,
212                    SQLCommit, SQLRollback,
213 <                  SQLSelectForUpdate, SQLSetGenerator);
213 >                  SQLSelectForUpdate, SQLSetGenerator,
214 >                  SQLSavePoint);
215  
216    TFBStatusCode = cardinal;
217    TByteArray = array of byte;
218  
219 +  IFirebirdAPI = interface;
220    IAttachment = interface;
221    ITransaction = interface;
222 +  IStatement = interface;
223  
224 <  {The IParameterBlock generic interface provides the template for all parameter
224 >  {The IParameterBlock interface provides the template for all parameter
225     block interfaces}
226  
227 <  generic IParameterBlock<_IItem> = interface
227 >  IParameterBlock<_IItem> = interface
228      function getCount: integer;
229      function Add(ParamType: byte): _IItem;
230      function getItems(index: integer): _IItem;
# Line 191 | Line 238 | type
238     different parameter block items }
239  
240    IParameterBlockItem = interface
241 +    ['{53b23f7b-abda-46a5-9aa5-07bd5e723266}']
242      function getParamType: byte;
243      function getAsInteger: integer;
244 <    function getAsString: string;
244 >    function getAsString: AnsiString;
245      function getAsByte: byte;
246 <    procedure setAsString(aValue: string);
246 >    procedure setAsString(aValue: AnsiString);
247      procedure setAsByte(aValue: byte);
248      procedure SetAsInteger(aValue: integer);
249 <    property AsString: string read getAsString write setAsString;
249 >    property AsString: AnsiString read getAsString write setAsString;
250      property AsByte: byte read getAsByte write setAsByte;
251      property AsInteger: integer read getAsInteger write SetAsInteger;
252    end;
# Line 211 | Line 259 | type
259     This interface can be accessed from IFirebirdAPI.
260     }
261  
262 +   TIBDataBaseErrorMessage    = (ShowSQLCode,
263 +                                   ShowIBMessage,
264 +                                   ShowSQLMessage);
265 +
266 +   TIBDataBaseErrorMessages   = set of TIBDataBaseErrorMessage;
267 +
268    IStatus = interface
269 +    ['{34167722-af38-4831-b08a-93162d58ede3}']
270      function GetIBErrorCode: Long;
271      function Getsqlcode: Long;
272 <    function GetMessage: string;
272 >    function GetMessage: AnsiString;
273      function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean;
274      function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages;
275      procedure SetIBDataBaseErrorMessages(Value: TIBDataBaseErrorMessages);
# Line 231 | Line 286 | type
286    TArrayBounds = array of TArrayBound;
287  
288    IArrayMetaData = interface
289 +    ['{7dd0aea4-59af-4c2a-b958-565d5025c489}']
290      function GetSQLType: cardinal;
291 <    function GetSQLTypeName: string;
291 >    function GetSQLTypeName: AnsiString;
292      function GetScale: integer;
293      function GetSize: cardinal;
294 +    function GetCharSetWidth: integer;
295      function GetCharSetID: cardinal;
296 <    function GetTableName: string;
297 <    function GetColumnName: string;
296 >    function GetTableName: AnsiString;
297 >    function GetColumnName: AnsiString;
298      function GetDimensions: integer;
299      function GetBounds: TArrayBounds;
300    end;
# Line 262 | Line 319 | type
319    TArrayEventHandler = procedure(Sender: IArray; Reason: TArrayEventReason) of object;
320  
321    IArray = interface(IArrayMetaData)
322 +    ['{631c6bb1-fb49-44fb-a64a-c49859632b88}']
323      function GetArrayID: TISC_QUAD;
324      procedure Clear;
325      function IsEmpty: boolean;
# Line 277 | Line 335 | type
335      function GetAsFloat(index: array of integer): Float;
336      function GetAsLong(index: array of integer): Long;
337      function GetAsShort(index: array of integer): Short;
338 <    function GetAsString(index: array of integer): String;
338 >    function GetAsString(index: array of integer): AnsiString;
339      function GetAsVariant(index: array of integer): Variant;
340      procedure SetAsInteger(index: array of integer; AValue: integer);
341      procedure SetAsBoolean(index: array of integer; AValue: boolean);
# Line 290 | Line 348 | type
348      procedure SetAsDouble(index: array of integer; Value: Double);
349      procedure SetAsFloat(index: array of integer; Value: Float);
350      procedure SetAsShort(index: array of integer; Value: Short);
351 <    procedure SetAsString(index: array of integer; Value: String);
351 >    procedure SetAsString(index: array of integer; Value: AnsiString);
352      procedure SetAsVariant(index: array of integer; Value: Variant);
353      procedure SetBounds(dim, UpperBound, LowerBound: integer);
354      function GetAttachment: IAttachment;
# Line 304 | Line 362 | type
362    }
363  
364    IBlobMetaData = interface
365 +    ['{575f3c61-bb33-46a5-8975-bb7d1b6e37cc}']
366      function GetSubType: integer;
367      function GetCharSetID: cardinal;
368      function GetCodePage: TSystemCodePage;
369      function GetSegmentSize: cardinal;
370 <    function GetRelationName: string;
371 <    function GetColumnName: string;
370 >    function GetRelationName: AnsiString;
371 >    function GetColumnName: AnsiString;
372    end;
373  
374    {The Blob Parameter block is used to select a Blob Filter}
375  
376 <  IBPBItem = interface (IParameterBlockItem) end;
376 >  IBPBItem = interface (IParameterBlockItem)
377 >    ['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}']
378 >  end;
379  
380 <  IBPB = specialize IParameterBlock<IBPBItem>;
380 >  IBPB = interface (IParameterBlock<IBPBItem>)
381 >    ['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}']
382 >  end;
383  
384    { The Blob Interface provides access to a blob data item.
385  
# Line 330 | Line 393 | type
393    TBlobType = (btSegmented,btStream);
394  
395    IBlob = interface(IBlobMetaData)
396 +    ['{3090a145-7780-442b-b15b-efd4568b8611}']
397      function GetBPB: IBPB;
398      procedure Cancel;
399      procedure Close;
# Line 340 | Line 404 | type
404                        TotalSize: Int64; var BlobType: TBlobType);
405      function Read(var Buffer; Count: Longint): Longint;
406      function Write(const Buffer; Count: Longint): Longint;
407 <    function LoadFromFile(Filename: string): IBlob;
407 >    function LoadFromFile(Filename: AnsiString): IBlob;
408      function LoadFromStream(S: TStream) : IBlob;
409 <    function SaveToFile(Filename: string): IBlob;
409 >    function SaveToFile(Filename: AnsiString): IBlob;
410      function SaveToStream(S: TStream): IBlob;
411      function GetAsString: rawbytestring;
412      procedure SetAsString(aValue: rawbytestring);
# Line 356 | Line 420 | type
420      the output of an SQL Statement.
421    }
422  
423 +  TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP}
424 +                        dfDateTime,   {SQL DATETIME}
425 +                        dfTime);      {SQL TIME}
426 +
427    { IColumnMetaData }
428  
429    IColumnMetaData = interface
430 +    ['{c222e6c3-53c1-469f-9e05-0a5c3ef232d8}']
431      function GetIndex: integer;
432      function GetSQLType: cardinal;
433 <    function GetSQLTypeName: string;
433 >    function GetSQLTypeName: AnsiString;
434      function getSubtype: integer;
435 <    function getRelationName: string;
436 <    function getOwnerName: string;
437 <    function getSQLName: string;    {Name of the column}
438 <    function getAliasName: string;  {Alias Name of column or Column Name if no alias}
439 <    function getName: string;       {Disambiguated uppercase Field Name}
435 >    function getRelationName: AnsiString;
436 >    function getOwnerName: AnsiString;
437 >    function getSQLName: AnsiString;    {Name of the column}
438 >    function getAliasName: AnsiString;  {Alias Name of column or Column Name if no alias}
439 >    function getName: AnsiString;       {Disambiguated uppercase Field Name}
440      function getScale: integer;
441      function getCharSetID: cardinal;
442      function getCodePage: TSystemCodePage;
443 +    function GetCharSetWidth: integer;
444      function getIsNullable: boolean;
445      function GetSize: cardinal;
446      function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
447      function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
448 <    property Name: string read GetName;
448 >    function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer;
449 >    function GetStatement: IStatement;
450 >    function GetTransaction: ITransaction;
451 >    property Name: AnsiString read GetName;
452      property Size: cardinal read GetSize;
453      property SQLType: cardinal read GetSQLType;
454      property Scale: integer read getScale;
# Line 391 | Line 464 | type
464    { IMetaData }
465  
466    IMetaData = interface
467 +    ['{4dafdbb6-0d36-4f1f-9c95-8b132804b965}']
468      function getCount: integer;
469      function getColumnMetaData(index: integer): IColumnMetaData;
470 <    function GetUniqueRelationName: string; {Non empty if all columns come from the same table}
471 <    function ByName(Idx: String): IColumnMetaData;
470 >    function GetUniqueRelationName: AnsiString; {Non empty if all columns come from the same table}
471 >    function ByName(Idx: AnsiString): IColumnMetaData;
472      property ColMetaData[index: integer]: IColumnMetaData read getColumnMetaData; default;
473      property Count: integer read getCount;
474    end;
# Line 414 | Line 488 | type
488  
489  
490    ISQLData = interface(IColumnMetaData)
491 +    ['{3f493e31-7e3f-4606-a07c-b210b9e3619d}']
492 +    function GetStrDataLength: short;
493      function GetAsBoolean: boolean;
494      function GetAsCurrency: Currency;
495      function GetAsInt64: Int64;
# Line 424 | Line 500 | type
500      function GetAsPointer: Pointer;
501      function GetAsQuad: TISC_QUAD;
502      function GetAsShort: short;
503 <    function GetAsString: String;
503 >    function GetAsString: AnsiString;
504      function GetIsNull: Boolean;
505      function GetAsVariant: Variant;
506      function GetAsBlob: IBlob; overload;
# Line 443 | Line 519 | type
519      property AsPointer: Pointer read GetAsPointer;
520      property AsQuad: TISC_QUAD read GetAsQuad;
521      property AsShort: short read GetAsShort;
522 <    property AsString: String read GetAsString;
522 >    property AsString: AnsiString read GetAsString;
523      property AsVariant: Variant read GetAsVariant ;
524      property AsBlob: IBlob read GetAsBlob;
525      property AsArray: IArray read GetAsArray;
# Line 458 | Line 534 | type
534    }
535  
536    IResults = interface
537 +    ['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}']
538     function getCount: integer;
539 +   function GetStatement: IStatement;
540     function GetTransaction: ITransaction;
541 <   function ByName(Idx: String): ISQLData;
541 >   function ByName(Idx: AnsiString): ISQLData;
542     function getSQLData(index: integer): ISQLData;
543 <   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar);
543 >   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
544     procedure SetRetainInterfaces(aValue: boolean);
545     property Data[index: integer]: ISQLData read getSQLData; default;
546     property Count: integer read getCount;
# Line 474 | Line 552 | type
552      in turn, used to access the data returned by each field of the current row.
553    }
554    IResultSet = interface(IResults)
555 +    ['{0ae4979b-7857-4e8c-8918-ec6f155b51a0}']
556      function FetchNext: boolean;
557 <    function GetCursorName: string;
557 >    function GetCursorName: AnsiString;
558      function IsEof: boolean;
559      procedure Close;
560    end;
# Line 496 | Line 575 | type
575    }
576  
577    ISQLParam = interface
578 +    ['{b22b4578-6d41-4807-a9a9-d2ec8d1d5a14}']
579      function GetIndex: integer;
580      function GetSQLType: cardinal;
581 <    function GetSQLTypeName: string;
581 >    function GetSQLTypeName: AnsiString;
582      function getSubtype: integer;
583 <    function getName: string;
583 >    function getName: AnsiString;
584      function getScale: integer;
585      function getCharSetID: cardinal;
586      function getCodePage: TSystemCodePage;
# Line 516 | Line 596 | type
596      function GetAsPointer: Pointer;
597      function GetAsQuad: TISC_QUAD;
598      function GetAsShort: short;
599 <    function GetAsString: String;
599 >    function GetAsString: AnsiString;
600      function GetIsNull: boolean;
601      function GetAsVariant: Variant;
602      function GetAsBlob: IBlob;
# Line 534 | Line 614 | type
614      procedure SetAsFloat(aValue: Float);
615      procedure SetAsPointer(aValue: Pointer);
616      procedure SetAsShort(aValue: Short);
617 <    procedure SetAsString(aValue: String);
617 >    procedure SetAsString(aValue: AnsiString);
618      procedure SetAsVariant(aValue: Variant);
619      procedure SetIsNull(aValue: Boolean);
620      procedure SetAsBlob(aValue: IBlob);
# Line 553 | Line 633 | type
633      property AsLong: Long read GetAsLong write SetAsLong;
634      property AsPointer: Pointer read GetAsPointer write SetAsPointer;
635      property AsShort: Short read GetAsShort write SetAsShort;
636 <    property AsString: String read GetAsString write SetAsString;
636 >    property AsString: AnsiString read GetAsString write SetAsString;
637      property AsVariant: Variant read GetAsVariant write SetAsVariant;
638      property AsBlob: IBlob read GetAsBlob write SetAsBlob;
639      property AsArray: IArray read GetAsArray write SetAsArray;
# Line 562 | Line 642 | type
642      property IsNull: Boolean read GetIsNull write SetIsNull;
643      property IsNullable: Boolean read GetIsNullable;
644      property Modified: Boolean read getModified;
645 <    property Name: string read GetName;
645 >    property Name: AnsiString read GetName;
646      property SQLType: cardinal read GetSQLType;
647    end;
648  
# Line 572 | Line 652 | type
652    }
653  
654    ISQLParams = interface
655 +    ['{c6d95ac7-b2b7-461b-b890-afef0acbb077}']
656      function getCount: integer;
657      function getSQLParam(index: integer): ISQLParam;
658 <    function ByName(Idx: String): ISQLParam ;
658 >    function ByName(Idx: AnsiString): ISQLParam ;
659      function GetModified: Boolean;
660 +    function GetHasCaseSensitiveParams: Boolean;
661      property Modified: Boolean read GetModified;
662      property Params[index: integer]: ISQLParam read getSQLParam; default;
663      property Count: integer read getCount;
664    end;
665  
666 +
667 +  TPerfStats = (psCurrentMemory, psMaxMemory,
668 +                psRealTime, psUserTime, psBuffers,
669 +                psReads, psWrites, psFetches,psDeltaMemory);
670 +
671 +  TPerfCounters = array[TPerfStats] of Int64;
672 +
673    {The IStatement interface provides access to an SQL Statement once it has been
674     initially prepared. The interface is returned from the IAttachment interface.
675     }
676  
677    IStatement = interface
678 +    ['{a260576d-a07d-4a66-b02d-1b72543fd7cf}']
679      function GetMetaData: IMetaData;  {Output Metadata}
680      function GetSQLParams: ISQLParams;{Statement Parameters}
681 <    function GetPlan: String;
681 >    function GetPlan: AnsiString;
682      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
683      function GetSQLStatementType: TIBSQLStatementTypes;
684 <    function GetSQLText: string;
684 >    function GetSQLText: AnsiString;
685 >    function GetProcessedSQLText: AnsiString;
686      function GetSQLDialect: integer;
687      function IsPrepared: boolean;
688      procedure Prepare(aTransaction: ITransaction=nil);
# Line 600 | Line 691 | type
691      function GetAttachment: IAttachment;
692      function GetTransaction: ITransaction;
693      procedure SetRetainInterfaces(aValue: boolean);
694 +    procedure EnableStatistics(aValue: boolean);
695 +    function GetPerfStatistics(var stats: TPerfCounters): boolean;
696      property MetaData: IMetaData read GetMetaData;
697      property SQLParams: ISQLParams read GetSQLParams;
698      property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType;
# Line 616 | Line 709 | type
709     found in the Interbase 6.0 API Guide.
710    }
711  
712 <  ITPBItem = interface(IParameterBlockItem) end;
712 >  ITPBItem = interface(IParameterBlockItem)
713 >    ['{544c1f2b-7c12-4a87-a4a5-face7ea72671}']
714 >  end;
715  
716 <  ITPB = specialize IParameterBlock<ITPBItem>;
716 >  ITPB = interface(IParameterBlock<ITPBItem>)
717 >    ['{7369b0ff-defe-437b-81fe-19b211d42d25}']
718 >  end;
719  
720    {The ITransactionAction interface provides access to a Transaction once it
721     has been initially started. After a Commit or Rollback, a transaction
# Line 632 | Line 729 | type
729    TTransactionCompletion = TARollback.. TACommit;
730  
731    ITransaction = interface
732 +    ['{30928d0e-a9d7-4c61-b7cf-14f4f38abe2a}']
733      function getTPB: ITPB;
734      procedure Start(DefaultCompletion: TTransactionCompletion=taCommit);
735      function GetInTransaction: boolean;
# Line 659 | Line 757 | type
757    }
758  
759    TEventInfo = record
760 <    EventName: string;
760 >    EventName: AnsiString;
761      Count: integer;
762    end;
763  
# Line 670 | Line 768 | type
768    { IEvents }
769  
770    IEvents = interface
771 +    ['{6a0be233-ed08-4524-889c-2e45d0c20e5f}']
772      procedure GetEvents(EventNames: TStrings);
773      procedure SetEvents(EventNames: TStrings); overload;
774 <    procedure SetEvents(EventName: string); overload;
774 >    procedure SetEvents(EventName: AnsiString); overload;
775      procedure Cancel;
776      function ExtractEventCounts: TEventCounts;
777      procedure WaitForEvent;
# Line 703 | Line 802 | type
802    TDBOperationCounts = array of TDBOperationCount;
803  
804    IDBInfoItem = interface
805 +    ['{eeb97b51-ec0f-473f-9f75-c1721f055fcb}']
806      function getItemType: byte;
807      function getSize: integer;
808      procedure getRawBytes(var Buffer);
809 <    function getAsString: string;
809 >    function getAsString: AnsiString;
810      function getAsInteger: integer;
811 <    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: string);
811 >    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString);
812      function getAsBytes: TByteArray;
813 <    procedure DecodeVersionString(var Version: byte; var VersionString: string);
813 >    function getAsDateTime: TDateTime;
814 >    procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
815      function getOperationCounts: TDBOperationCounts;
816      procedure DecodeUserNames(UserNames: TStrings);
817  
# Line 719 | Line 820 | type
820      function GetItem(index: integer): IDBInfoItem;
821      function Find(ItemType: byte): IDBInfoItem;
822      property AsInteger: integer read getAsInteger;
823 <    property AsString: string read GetAsString;
823 >    property AsString: AnsiString read GetAsString;
824      property Count: integer read GetCount;
825      property Items[index: integer]: IDBInfoItem read getItem; default;
826    end;
# Line 727 | Line 828 | type
828    { IDBInformation }
829  
830    IDBInformation = interface
831 +    ['{7ac6777f-f0a9-498a-9f5c-4a57a554df81}']
832      function GetCount: integer;
833      function GetItem(index: integer): IDBInfoItem;
834      function Find(ItemType: byte): IDBInfoItem;
# Line 735 | Line 837 | type
837      property Items[index: integer]: IDBInfoItem read getItem; default;
838    end;
839  
840 +  {The Database Information Request Block is used to pass requests for
841 +   database information where at least one item requested has a parameter.
842 +   At present, this is only fb_info_page_contents which has a single
843 +   integer parameter.}
844 +
845 +  IDIRBItem = interface(IParameterBlockItem)
846 +    ['{d34a7511-8435-4a24-81a7-5103d218d234}']
847 +  end;
848 +
849 +  IDIRB = interface(IParameterBlock<IDIRBItem>)
850 +    ['{1010e5ac-0a8f-403b-a302-91625e9d9579}']
851 +  end;
852 +
853 +
854    {The Database Parameter Block (DPB).
855  
856     The DPB provides the parameters used when connecting to a database. It is allocated
# Line 746 | Line 862 | type
862     found in the Interbase 6.0 API Guide.
863     }
864  
865 <  IDPBItem = interface(IParameterBlockItem) end;
865 >  IDPBItem = interface(IParameterBlockItem)
866 >    ['{123d4ad0-087a-4cd1-a344-1b3d03b30673}']
867 >  end;
868  
869 <  IDPB = specialize IParameterBlock<IDPBItem>;
869 >  IDPB = interface(IParameterBlock<IDPBItem>)
870 >    ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
871 >  end;
872  
873    {The IAttachment interface provides access to a Database Connection. It may be
874     used to:
# Line 778 | Line 898 | type
898    { IAttachment }
899  
900    IAttachment = interface
901 +    ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
902 +    function getFirebirdAPI: IFirebirdAPI;
903      function getDPB: IDPB;
904      function AllocateBPB: IBPB;
905 +    function AllocateDIRB: IDIRB;
906      procedure Connect;
907      procedure Disconnect(Force: boolean=false);
908      function IsConnected: boolean;
909      procedure DropDatabase;
910      function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
911      function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
912 <    procedure ExecImmediate(transaction: ITransaction; sql: string; SQLDialect: integer); overload;
913 <    procedure ExecImmediate(TPB: array of byte; sql: string; SQLDialect: integer); overload;
914 <    procedure ExecImmediate(transaction: ITransaction; sql: string); overload;
915 <    procedure ExecImmediate(TPB: array of byte; sql: string); overload;
916 <    function ExecuteSQL(TPB: array of byte; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
917 <    function ExecuteSQL(transaction: ITransaction; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
918 <    function ExecuteSQL(TPB: array of byte; sql: string; params: array of const): IResults; overload;
919 <    function ExecuteSQL(transaction: ITransaction; sql: string; params: array of const): IResults; overload;
920 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
921 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer;
912 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; SQLDialect: integer); overload;
913 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString; SQLDialect: integer); overload;
914 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload;
915 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload;
916 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
917 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
918 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload;
919 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload;
920 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
921 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
922                               params: array of const): IResultSet; overload;
923 <    function OpenCursor(transaction: ITransaction; sql: string): IResultSet; overload;
924 <    function OpenCursor(transaction: ITransaction; sql: string;
923 >    function OpenCursor(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
924 >    function OpenCursor(transaction: ITransaction; sql: AnsiString;
925                               params: array of const): IResultSet; overload;
926 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
927 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer;
926 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
927 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
928                               params: array of const): IResultSet; overload;
929 <    function OpenCursorAtStart(transaction: ITransaction; sql: string): IResultSet; overload;
930 <    function OpenCursorAtStart(transaction: ITransaction; sql: string;
929 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
930 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString;
931                               params: array of const): IResultSet; overload;
932 <    function OpenCursorAtStart(sql: string): IResultSet; overload;
933 <    function OpenCursorAtStart(sql: string;
932 >    function OpenCursorAtStart(sql: AnsiString): IResultSet; overload;
933 >    function OpenCursorAtStart(sql: AnsiString;
934                               params: array of const): IResultSet; overload;
935 <    function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; overload;
936 <    function Prepare(transaction: ITransaction; sql: string): IStatement; overload;
937 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
938 <                       aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload;
939 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
940 <                       GenerateParamNames: boolean=false): IStatement; overload;
935 >    function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload;
936 >    function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload;
937 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
938 >                       aSQLDialect: integer; GenerateParamNames: boolean=false;
939 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
940 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
941 >                       GenerateParamNames: boolean=false;
942 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
943  
944      {Events}
945      function GetEventHandler(Events: TStrings): IEvents; overload;
946 <    function GetEventHandler(Event: string): IEvents; overload;
946 >    function GetEventHandler(Event: AnsiString): IEvents; overload;
947  
948      {Blob - may use to open existing Blobs. However, ISQLData.AsBlob is preferred}
949  
950 <    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: string; BPB: IBPB=nil): IBlob; overload;
950 >    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
951      function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
952      function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
953 <    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
953 >    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
954 >    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;  overload;
955  
956      {Array - may use to open existing arrays. However, ISQLData.AsArray is preferred}
957  
958 <    function OpenArray(transaction: ITransaction; RelationName, ColumnName: string; ArrayID: TISC_QUAD): IArray;
959 <    function CreateArray(transaction: ITransaction; RelationName, ColumnName: string): IArray; overload;
958 >    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload;
959 >    function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload;
960 >    function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload;
961      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
962 +    function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
963 +                  Scale: integer; size: cardinal; charSetID: cardinal; dimensions: cardinal;
964 +                  bounds: TArrayBounds): IArrayMetaData;
965  
966      {Database Information}
967      function GetSQLDialect: integer;
968 <    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: string): IBlobMetaData;
969 <    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: string): IArrayMetaData;
968 >    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData;
969 >    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
970      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
971      function GetDBInformation(Request: byte): IDBInformation; overload;
972 +    function GetDBInformation(Requests: IDIRB): IDBInformation; overload;
973 +    function GetConnectString: AnsiString;
974 +    function GetRemoteProtocol: AnsiString;
975 +    function GetAuthenticationMethod: AnsiString;
976 +    function GetSecurityDatabase: AnsiString;
977 +    function GetODSMajorVersion: integer;
978 +    function GetODSMinorVersion: integer;
979 +    procedure getFBVersion(version: TStrings);
980      function HasActivity: boolean;
981 +
982 +    {Character Sets}
983 +    function HasDefaultCharSet: boolean;
984 +    function GetDefaultCharSetID: integer;
985 +    function GetCharsetName(CharSetID: integer): AnsiString;
986 +    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
987 +    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
988 +    function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean;
989 +    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
990 +    procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
991 +      AllowReverseLookup:boolean; out CharSetID: integer);
992    end;
993  
994 <  TProtocol = (TCP, SPX, NamedPipe, Local);
994 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
995 >  TProtocol = TCP..xnet;
996  
997    {Service Parameter Block (SPB).
998  
# Line 856 | Line 1006 | type
1006  
1007    }
1008  
1009 <  ISPBItem = interface(IParameterBlockItem) end;
1009 >  ISPBItem = interface(IParameterBlockItem)
1010 >    ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
1011 >  end;
1012  
1013 <  ISPB = specialize IParameterBlock<ISPBItem>;
1013 >  ISPB = interface(IParameterBlock<ISPBItem>)
1014 >    ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
1015 >  end;
1016  
1017    {Service Query Parameter Block (SQPB).
1018  
# Line 867 | Line 1021 | type
1021    }
1022  
1023    ISQPBItem = interface(IParameterBlockItem)
1024 +    ['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}']
1025      function CopyFrom(source: TStream; count: integer): integer;
1026    end;
1027  
1028 <  ISQPB = specialize IParameterBlock<ISQPBItem>;
1028 >  ISQPB = interface(IParameterBlock<ISQPBItem>)
1029 >    ['{8553e66b-ee62-498b-8431-dff030211447}']
1030 >  end;
1031  
1032    {Service Request Block (SRB).
1033  
# Line 884 | Line 1041 | type
1041  
1042    }
1043  
1044 <  ISRBItem = interface(IParameterBlockItem) end;
1044 >  ISRBItem = interface(IParameterBlockItem)
1045 >    ['{47ec790e-f265-4b30-9dcd-261e51677245}']
1046 >   end;
1047  
1048 <  ISRB = specialize IParameterBlock<ISRBItem>;
1048 >  ISRB = interface(IParameterBlock<ISRBItem>)
1049 >    ['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}']
1050 >  end;
1051  
1052    {The Service Query Results Interface.
1053  
# Line 904 | Line 1065 | type
1065    }
1066  
1067    IServiceQueryResultSubItem = interface
1068 +    ['{8a4c381e-9923-4cc9-a96b-553729248640}']
1069      function getItemType: byte;
1070      function getSize: integer;
1071      procedure getRawBytes(var Buffer);
1072 <    function getAsString: string;
1072 >    function getAsString: AnsiString;
1073      function getAsInteger: integer;
1074      function getAsByte: byte;
1075      function CopyTo(stream: TStream; count: integer): integer;
1076 <    property AsString: string read getAsString;
1076 >    property AsString: AnsiString read getAsString;
1077      property AsInteger: integer read getAsInteger;
1078      property AsByte: byte read getAsByte;
1079    end;
1080  
1081    IServiceQueryResultItem = interface(IServiceQueryResultSubItem)
1082 +    ['{b2806886-206c-4024-8df9-5fe0a7630a5e}']
1083      function getCount: integer;
1084      function getItem(index: integer): IServiceQueryResultSubItem;
1085      function find(ItemType: byte): IServiceQueryResultSubItem;
# Line 925 | Line 1088 | type
1088    end;
1089  
1090    IServiceQueryResults = interface
1091 +    ['{8fbbef7d-fe03-4409-828a-a787d34ef531}']
1092      function getCount: integer;
1093      function getItem(index: integer): IServiceQueryResultItem;
1094      function find(ItemType: byte): IServiceQueryResultItem;
# Line 933 | Line 1097 | type
1097      property Count: integer read getCount;
1098    end;
1099  
1100 +  IFirebirdLibrary = interface;
1101 +
1102    {The IServiceManager interface provides access to a service manager. It can
1103     used to Detach and re-attach to Service Manager, to start services and to
1104     query the service manager.
# Line 943 | Line 1109 | type
1109    { IServiceManager }
1110  
1111    IServiceManager = interface
1112 +    ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1113 +    function getFirebirdAPI: IFirebirdAPI;
1114      function getSPB: ISPB;
1115 <    function getServerName: string;
1115 >    function getServerName: AnsiString;
1116 >    function getProtocol: TProtocol;
1117 >    function getPortNo: AnsiString;
1118      procedure Attach;
1119      procedure Detach(Force: boolean=false);
1120      function IsAttached: boolean;
1121      function AllocateSRB: ISRB;
1122      function AllocateSQPB: ISQPB;
1123 <    procedure Start(Request: ISRB);
1124 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1125 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1123 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1124 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1125 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1126 >  end;
1127 >
1128 >  {Tbe Firebird Library API used to get information about the Firebird library}
1129 >
1130 >
1131 >  IFirebirdLibrary = interface
1132 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1133 >    function GetHandle: TLibHandle;
1134 >    function GetLibraryName: string;
1135 >    function GetLibraryFilePath: string;
1136 >    function GetFirebirdAPI: IFirebirdAPI;
1137    end;
1138  
1139    {The Firebird API.
# Line 964 | Line 1145 | type
1145    }
1146  
1147    IFirebirdAPI = interface
1148 +    ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1149      {Database connections}
1150      function AllocateDPB: IDPB;
1151 <    function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1152 <    function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment;
1151 >    function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1152 >    function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1153 >    function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1154  
1155      {Start Transaction against multiple databases}
1156      function AllocateTPB: ITPB;
# Line 979 | Line 1162 | type
1162      {Service Manager}
1163      function HasServiceAPI: boolean;
1164      function AllocateSPB: ISPB;
1165 <    function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager;
1165 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1166 >    function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1167  
1168      {Information}
1169      function GetStatus: IStatus;
986    function GetLibraryName: string;
1170      function HasRollbackRetaining: boolean;
1171      function IsEmbeddedServer: boolean;
1172 <    function GetImplementationVersion: string;
1172 >    function GetImplementationVersion: AnsiString;
1173 >    function GetClientMajor: integer;
1174 >    function GetClientMinor: integer;
1175  
1176      {Firebird 3 API}
1177      function HasMasterIntf: boolean;
1178      function GetIMaster: TObject;
1179 <
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;
1179 >    function GetFBLibrary: IFirebirdLibrary;
1180   end;
1181  
1182   type
# Line 1014 | Line 1193 | type
1193     private
1194       FSQLCode: Long;
1195     public
1196 <     constructor Create(ASQLCode: Long; Msg: string);
1196 >     constructor Create(ASQLCode: Long; Msg: AnsiString);
1197       property SQLCode: Long read FSQLCode;
1198     end;
1199  
# Line 1025 | Line 1204 | type
1204       FIBErrorCode: Long;
1205     public
1206       constructor Create(Status: IStatus); overload;
1207 <     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: string); overload;
1207 >     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload;
1208       property IBErrorCode: Long read FIBErrorCode;
1209     end;
1210  
1211     {IB Client Exceptions}
1212     EIBClientError = class(EIBError);
1213  
1035 {IBError is used internally and by IBX to throw an EIBClientError}
1036
1037 procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1038
1214   {The Firebird API function is used to access the IFirebirdAPI interface.
1215  
1216   It will load the Firebird Client Library if this is not already loaded and
# Line 1050 | Line 1225 | function FirebirdAPI: IFirebirdAPI;
1225   function TryIBLoad: Boolean;
1226   procedure CheckIBLoaded;
1227  
1228 + {If you want to explicitly load the Firebird library from a
1229 + non-default location then use this function and its GetFirebirdAPI function
1230 + to get the API.}
1231 +
1232 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1233 +
1234   implementation
1235  
1236   uses FBClientAPI
1237    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1238    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1239  
1240 < var FFirebirdAPI: IFirebirdAPI;
1240 > var FDefaultFBLibrary: IFirebirdLibrary;
1241 >
1242 > type
1243 >
1244 >  { TFBLibrary }
1245 >
1246 >  TFBLibraryImpl = class(TFBLibrary)
1247 >  protected
1248 >    function GetFirebird3API: IFirebirdAPI; override;
1249 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1250 >  end;
1251 >
1252 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1253 > begin
1254 > {$IFDEF USEFIREBIRD3API}
1255 > Result := TFB30ClientAPI.Create(self);
1256 > {$ELSE}
1257 > Result := nil;
1258 > {$ENDIF}
1259 > end;
1260 >
1261 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1262 > begin
1263 >  {$IFDEF USELEGACYFIREBIRDAPI}
1264 >  Result := TFB25ClientAPI.Create(self);
1265 >  {$ELSE}
1266 >  Result := nil;
1267 >  {$ENDIF}
1268 > end;
1269  
1270   function FirebirdAPI: IFirebirdAPI;
1271   begin
1272 <  if FFirebirdAPI = nil then
1272 >  if FDefaultFBLibrary = nil then
1273      CheckIBLoaded;
1274 <  Result := FFirebirdAPI;
1274 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1275   end;
1276  
1277   function TryIBLoad: Boolean;
1278 + var fblib: IFirebirdLibrary;
1279   begin
1280 < Result := FFirebirdAPI <> nil;
1280 > Result := FDefaultFBLibrary <> nil;
1281   try
1072  {$IFDEF USEFIREBIRD3API}
1282    if not Result then
1283    begin
1284 <    FFirebirdAPI := TFB30ClientAPI.Create;
1285 <    Result := FFirebirdAPI.HasMasterIntf;
1286 <  end;
1287 <  {$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;
1284 >    fblib := TFBLibraryImpl.Create;
1285 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1286 >      FDefaultFBLibrary := fblib;
1287 >    Result := FDefaultFBLibrary <> nil;
1288    end;
1289   except
1290     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1101 | Line 1298 | begin
1298      IBError(ibxeInterBaseMissing, [nil]);
1299   end;
1300  
1301 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1302 + var fblib: IFirebirdLibrary;
1303 + begin
1304 +  if trim(aLibPathName) = '' then
1305 +  begin
1306 +    CheckIBLoaded;
1307 +    Result := FDefaultFBLibrary;
1308 +  end
1309 +  else
1310 +  begin
1311 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1312 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1313 +      IBError(ibxeInterBaseMissing, [nil]);
1314 +    Result := fblib;
1315 +  end;
1316 + end;
1317 +
1318   { EIBError }
1319  
1320 < constructor EIBError.Create(ASQLCode: Long; Msg: string);
1320 > constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
1321   begin
1322    inherited Create(Msg);
1323    FSQLCode := ASQLCode;
# Line 1118 | Line 1332 | begin
1332   end;
1333  
1334   constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long;
1335 <  Msg: string);
1335 >  Msg: AnsiString);
1336   begin
1337    inherited Create(ASQLCode,Msg);
1338    FIBErrorCode := AIBErrorCode;
1339   end;
1340  
1127 procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1128 begin
1129  raise EIBClientError.Create(Ord(ErrMess),
1130                              Format(GetErrorMessage(ErrMess), Args));
1131 end;
1341  
1342   initialization
1343 <  FFirebirdAPI := nil;
1343 >  FDefaultFBLibrary := nil;
1344  
1345 + finalization
1346 +  FDefaultFBLibrary := nil;
1347  
1348   end.
1349  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines