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 263 by tony, Thu Dec 6 15:55:01 2018 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   {$DEFINE USEFIREBIRD3API}
# Line 103 | Line 106 | unit IB;
106  
107    5. Straightforward progammatic access to the Firebird API from Pascal programs.
108  
109 +  6. FPC and Delphi Support.
110 +
111    String Types
112    ============
113  
# Line 117 | Line 122 | unit IB;
122   interface
123  
124   uses
125 <  Classes, SysUtils, DB, FBMessages, IBExternals;
125 >  Classes,
126 >  {$IFDEF WINDOWS}Windows, {$ENDIF}
127 >  {$IFDEF FPC} Dynlibs, {$ENDIF}
128 >  SysUtils, DB, FBMessages, IBExternals;
129 >
130 > const
131 >  {Interface version information}
132 >  FBIntf_Major = 1;
133 >  FBIntf_Minor = 1;
134 >  FBIntf_Release = 3;
135 >  FBIntf_Version = '1.1.3';
136  
137   {These include files are converted from the 'C' originals in the Firebird API
138   and define the various constants used by the API}
139  
140 < {$I consts_pub.inc}
141 < {$I inf_pub.inc}
142 < {$I configkeys.inc}
140 > {$I 'include/consts_pub.inc'}
141 > {$I 'include/inf_pub.inc'}
142 > {$I 'include/configkeys.inc'}
143  
144   {The following constants define the values return by calls to the GetSQLType
145   methods provided by several of the interfaces defined below.}
# Line 160 | Line 175 | type
175     PGDS__QUAD           = ^TGDS__QUAD;
176     PISC_QUAD            = ^TISC_QUAD;
177  
178 + {$IFNDEF FPC}
179 + {Delphi missing definitions}
180 + type
181 +  TLibHandle = THandle;
182 +
183 + const
184 +  NilHandle = 0;
185 +  DirectorySeparator = '\';
186 +
187 + {Delphi only seems to define CP_UTF8 and CP_UTF16}
188 + const
189 +  CP_ACP     = 0;     // default to ANSI code page
190 +  CP_OEMCP   = 1;     // default to OEM (console) code page
191 +  CP_UTF16BE = 1201;  // unicodeFFFE
192 +  CP_UTF7    = 65000; // utf-7
193 +  CP_ASCII   = 20127; // us-ascii
194 +  CP_NONE    = $FFFF; // rawbytestring encoding
195 +
196 + {$ENDIF}
197 +
198 + type
199 + {$IF not declared(TSystemCodePage)}
200 +  TSystemCodePage = word; {not defined in Delphi}
201 + {$IFEND}
202 +
203    TIBSQLStatementTypes =
204                   (SQLUnknown, SQLSelect, SQLInsert,
205                    SQLUpdate, SQLDelete, SQLDDL,
# Line 171 | Line 211 | type
211    TFBStatusCode = cardinal;
212    TByteArray = array of byte;
213  
214 +  IFirebirdAPI = interface;
215    IAttachment = interface;
216    ITransaction = interface;
217  
218 <  {The IParameterBlock generic interface provides the template for all parameter
218 >  {The IParameterBlock interface provides the template for all parameter
219     block interfaces}
220  
221 <  generic IParameterBlock<_IItem> = interface
221 >  IParameterBlock<_IItem> = interface
222      function getCount: integer;
223      function Add(ParamType: byte): _IItem;
224      function getItems(index: integer): _IItem;
# Line 191 | Line 232 | type
232     different parameter block items }
233  
234    IParameterBlockItem = interface
235 +    ['{53b23f7b-abda-46a5-9aa5-07bd5e723266}']
236      function getParamType: byte;
237      function getAsInteger: integer;
238 <    function getAsString: string;
238 >    function getAsString: AnsiString;
239      function getAsByte: byte;
240 <    procedure setAsString(aValue: string);
240 >    procedure setAsString(aValue: AnsiString);
241      procedure setAsByte(aValue: byte);
242      procedure SetAsInteger(aValue: integer);
243 <    property AsString: string read getAsString write setAsString;
243 >    property AsString: AnsiString read getAsString write setAsString;
244      property AsByte: byte read getAsByte write setAsByte;
245      property AsInteger: integer read getAsInteger write SetAsInteger;
246    end;
# Line 212 | Line 254 | type
254     }
255  
256    IStatus = interface
257 +    ['{34167722-af38-4831-b08a-93162d58ede3}']
258      function GetIBErrorCode: Long;
259      function Getsqlcode: Long;
260 <    function GetMessage: string;
260 >    function GetMessage: AnsiString;
261      function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean;
262      function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages;
263      procedure SetIBDataBaseErrorMessages(Value: TIBDataBaseErrorMessages);
# Line 231 | Line 274 | type
274    TArrayBounds = array of TArrayBound;
275  
276    IArrayMetaData = interface
277 +    ['{7dd0aea4-59af-4c2a-b958-565d5025c489}']
278      function GetSQLType: cardinal;
279 <    function GetSQLTypeName: string;
279 >    function GetSQLTypeName: AnsiString;
280      function GetScale: integer;
281      function GetSize: cardinal;
282      function GetCharSetID: cardinal;
283 <    function GetTableName: string;
284 <    function GetColumnName: string;
283 >    function GetTableName: AnsiString;
284 >    function GetColumnName: AnsiString;
285      function GetDimensions: integer;
286      function GetBounds: TArrayBounds;
287    end;
# Line 262 | Line 306 | type
306    TArrayEventHandler = procedure(Sender: IArray; Reason: TArrayEventReason) of object;
307  
308    IArray = interface(IArrayMetaData)
309 +    ['{631c6bb1-fb49-44fb-a64a-c49859632b88}']
310      function GetArrayID: TISC_QUAD;
311      procedure Clear;
312      function IsEmpty: boolean;
# Line 277 | Line 322 | type
322      function GetAsFloat(index: array of integer): Float;
323      function GetAsLong(index: array of integer): Long;
324      function GetAsShort(index: array of integer): Short;
325 <    function GetAsString(index: array of integer): String;
325 >    function GetAsString(index: array of integer): AnsiString;
326      function GetAsVariant(index: array of integer): Variant;
327      procedure SetAsInteger(index: array of integer; AValue: integer);
328      procedure SetAsBoolean(index: array of integer; AValue: boolean);
# Line 290 | Line 335 | type
335      procedure SetAsDouble(index: array of integer; Value: Double);
336      procedure SetAsFloat(index: array of integer; Value: Float);
337      procedure SetAsShort(index: array of integer; Value: Short);
338 <    procedure SetAsString(index: array of integer; Value: String);
338 >    procedure SetAsString(index: array of integer; Value: AnsiString);
339      procedure SetAsVariant(index: array of integer; Value: Variant);
340      procedure SetBounds(dim, UpperBound, LowerBound: integer);
341      function GetAttachment: IAttachment;
# Line 304 | Line 349 | type
349    }
350  
351    IBlobMetaData = interface
352 +    ['{575f3c61-bb33-46a5-8975-bb7d1b6e37cc}']
353      function GetSubType: integer;
354      function GetCharSetID: cardinal;
355      function GetCodePage: TSystemCodePage;
356      function GetSegmentSize: cardinal;
357 <    function GetRelationName: string;
358 <    function GetColumnName: string;
357 >    function GetRelationName: AnsiString;
358 >    function GetColumnName: AnsiString;
359    end;
360  
361    {The Blob Parameter block is used to select a Blob Filter}
362  
363 <  IBPBItem = interface (IParameterBlockItem) end;
363 >  IBPBItem = interface (IParameterBlockItem)
364 >    ['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}']
365 >  end;
366  
367 <  IBPB = specialize IParameterBlock<IBPBItem>;
367 >  IBPB = interface (IParameterBlock<IBPBItem>)
368 >    ['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}']
369 >  end;
370  
371    { The Blob Interface provides access to a blob data item.
372  
# Line 330 | Line 380 | type
380    TBlobType = (btSegmented,btStream);
381  
382    IBlob = interface(IBlobMetaData)
383 +    ['{3090a145-7780-442b-b15b-efd4568b8611}']
384      function GetBPB: IBPB;
385      procedure Cancel;
386      procedure Close;
# Line 340 | Line 391 | type
391                        TotalSize: Int64; var BlobType: TBlobType);
392      function Read(var Buffer; Count: Longint): Longint;
393      function Write(const Buffer; Count: Longint): Longint;
394 <    function LoadFromFile(Filename: string): IBlob;
394 >    function LoadFromFile(Filename: AnsiString): IBlob;
395      function LoadFromStream(S: TStream) : IBlob;
396 <    function SaveToFile(Filename: string): IBlob;
396 >    function SaveToFile(Filename: AnsiString): IBlob;
397      function SaveToStream(S: TStream): IBlob;
398      function GetAsString: rawbytestring;
399      procedure SetAsString(aValue: rawbytestring);
# Line 359 | Line 410 | type
410    { IColumnMetaData }
411  
412    IColumnMetaData = interface
413 +    ['{c222e6c3-53c1-469f-9e05-0a5c3ef232d8}']
414      function GetIndex: integer;
415      function GetSQLType: cardinal;
416 <    function GetSQLTypeName: string;
416 >    function GetSQLTypeName: AnsiString;
417      function getSubtype: integer;
418 <    function getRelationName: string;
419 <    function getOwnerName: string;
420 <    function getSQLName: string;    {Name of the column}
421 <    function getAliasName: string;  {Alias Name of column or Column Name if no alias}
422 <    function getName: string;       {Disambiguated uppercase Field Name}
418 >    function getRelationName: AnsiString;
419 >    function getOwnerName: AnsiString;
420 >    function getSQLName: AnsiString;    {Name of the column}
421 >    function getAliasName: AnsiString;  {Alias Name of column or Column Name if no alias}
422 >    function getName: AnsiString;       {Disambiguated uppercase Field Name}
423      function getScale: integer;
424      function getCharSetID: cardinal;
425      function getCodePage: TSystemCodePage;
# Line 375 | Line 427 | type
427      function GetSize: cardinal;
428      function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
429      function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
430 <    property Name: string read GetName;
430 >    property Name: AnsiString read GetName;
431      property Size: cardinal read GetSize;
432      property SQLType: cardinal read GetSQLType;
433      property Scale: integer read getScale;
# Line 391 | Line 443 | type
443    { IMetaData }
444  
445    IMetaData = interface
446 +    ['{4dafdbb6-0d36-4f1f-9c95-8b132804b965}']
447      function getCount: integer;
448      function getColumnMetaData(index: integer): IColumnMetaData;
449 <    function GetUniqueRelationName: string; {Non empty if all columns come from the same table}
450 <    function ByName(Idx: String): IColumnMetaData;
449 >    function GetUniqueRelationName: AnsiString; {Non empty if all columns come from the same table}
450 >    function ByName(Idx: AnsiString): IColumnMetaData;
451      property ColMetaData[index: integer]: IColumnMetaData read getColumnMetaData; default;
452      property Count: integer read getCount;
453    end;
# Line 414 | Line 467 | type
467  
468  
469    ISQLData = interface(IColumnMetaData)
470 +    ['{3f493e31-7e3f-4606-a07c-b210b9e3619d}']
471      function GetAsBoolean: boolean;
472      function GetAsCurrency: Currency;
473      function GetAsInt64: Int64;
# Line 424 | Line 478 | type
478      function GetAsPointer: Pointer;
479      function GetAsQuad: TISC_QUAD;
480      function GetAsShort: short;
481 <    function GetAsString: String;
481 >    function GetAsString: AnsiString;
482      function GetIsNull: Boolean;
483      function GetAsVariant: Variant;
484      function GetAsBlob: IBlob; overload;
# Line 443 | Line 497 | type
497      property AsPointer: Pointer read GetAsPointer;
498      property AsQuad: TISC_QUAD read GetAsQuad;
499      property AsShort: short read GetAsShort;
500 <    property AsString: String read GetAsString;
500 >    property AsString: AnsiString read GetAsString;
501      property AsVariant: Variant read GetAsVariant ;
502      property AsBlob: IBlob read GetAsBlob;
503      property AsArray: IArray read GetAsArray;
# Line 458 | Line 512 | type
512    }
513  
514    IResults = interface
515 +    ['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}']
516     function getCount: integer;
517     function GetTransaction: ITransaction;
518 <   function ByName(Idx: String): ISQLData;
518 >   function ByName(Idx: AnsiString): ISQLData;
519     function getSQLData(index: integer): ISQLData;
520 <   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar);
520 >   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
521     procedure SetRetainInterfaces(aValue: boolean);
522     property Data[index: integer]: ISQLData read getSQLData; default;
523     property Count: integer read getCount;
# Line 474 | Line 529 | type
529      in turn, used to access the data returned by each field of the current row.
530    }
531    IResultSet = interface(IResults)
532 +    ['{0ae4979b-7857-4e8c-8918-ec6f155b51a0}']
533      function FetchNext: boolean;
534 <    function GetCursorName: string;
534 >    function GetCursorName: AnsiString;
535      function IsEof: boolean;
536      procedure Close;
537    end;
# Line 496 | Line 552 | type
552    }
553  
554    ISQLParam = interface
555 +    ['{b22b4578-6d41-4807-a9a9-d2ec8d1d5a14}']
556      function GetIndex: integer;
557      function GetSQLType: cardinal;
558 <    function GetSQLTypeName: string;
558 >    function GetSQLTypeName: AnsiString;
559      function getSubtype: integer;
560 <    function getName: string;
560 >    function getName: AnsiString;
561      function getScale: integer;
562      function getCharSetID: cardinal;
563      function getCodePage: TSystemCodePage;
# Line 516 | Line 573 | type
573      function GetAsPointer: Pointer;
574      function GetAsQuad: TISC_QUAD;
575      function GetAsShort: short;
576 <    function GetAsString: String;
576 >    function GetAsString: AnsiString;
577      function GetIsNull: boolean;
578      function GetAsVariant: Variant;
579      function GetAsBlob: IBlob;
# Line 534 | Line 591 | type
591      procedure SetAsFloat(aValue: Float);
592      procedure SetAsPointer(aValue: Pointer);
593      procedure SetAsShort(aValue: Short);
594 <    procedure SetAsString(aValue: String);
594 >    procedure SetAsString(aValue: AnsiString);
595      procedure SetAsVariant(aValue: Variant);
596      procedure SetIsNull(aValue: Boolean);
597      procedure SetAsBlob(aValue: IBlob);
# Line 553 | Line 610 | type
610      property AsLong: Long read GetAsLong write SetAsLong;
611      property AsPointer: Pointer read GetAsPointer write SetAsPointer;
612      property AsShort: Short read GetAsShort write SetAsShort;
613 <    property AsString: String read GetAsString write SetAsString;
613 >    property AsString: AnsiString read GetAsString write SetAsString;
614      property AsVariant: Variant read GetAsVariant write SetAsVariant;
615      property AsBlob: IBlob read GetAsBlob write SetAsBlob;
616      property AsArray: IArray read GetAsArray write SetAsArray;
# Line 562 | Line 619 | type
619      property IsNull: Boolean read GetIsNull write SetIsNull;
620      property IsNullable: Boolean read GetIsNullable;
621      property Modified: Boolean read getModified;
622 <    property Name: string read GetName;
622 >    property Name: AnsiString read GetName;
623      property SQLType: cardinal read GetSQLType;
624    end;
625  
# Line 572 | Line 629 | type
629    }
630  
631    ISQLParams = interface
632 +    ['{c6d95ac7-b2b7-461b-b890-afef0acbb077}']
633      function getCount: integer;
634      function getSQLParam(index: integer): ISQLParam;
635 <    function ByName(Idx: String): ISQLParam ;
635 >    function ByName(Idx: AnsiString): ISQLParam ;
636      function GetModified: Boolean;
637      property Modified: Boolean read GetModified;
638      property Params[index: integer]: ISQLParam read getSQLParam; default;
639      property Count: integer read getCount;
640    end;
641  
642 +
643 +  TPerfStats = (psCurrentMemory, psMaxMemory,
644 +                psRealTime, psUserTime, psBuffers,
645 +                psReads, psWrites, psFetches,psDeltaMemory);
646 +
647 +  TPerfCounters = array[TPerfStats] of Int64;
648 +
649    {The IStatement interface provides access to an SQL Statement once it has been
650     initially prepared. The interface is returned from the IAttachment interface.
651     }
652  
653    IStatement = interface
654 +    ['{a260576d-a07d-4a66-b02d-1b72543fd7cf}']
655      function GetMetaData: IMetaData;  {Output Metadata}
656      function GetSQLParams: ISQLParams;{Statement Parameters}
657 <    function GetPlan: String;
657 >    function GetPlan: AnsiString;
658      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
659      function GetSQLStatementType: TIBSQLStatementTypes;
660 <    function GetSQLText: string;
660 >    function GetSQLText: AnsiString;
661 >    function GetProcessedSQLText: AnsiString;
662      function GetSQLDialect: integer;
663      function IsPrepared: boolean;
664      procedure Prepare(aTransaction: ITransaction=nil);
# Line 600 | Line 667 | type
667      function GetAttachment: IAttachment;
668      function GetTransaction: ITransaction;
669      procedure SetRetainInterfaces(aValue: boolean);
670 +    procedure EnableStatistics(aValue: boolean);
671 +    function GetPerfStatistics(var stats: TPerfCounters): boolean;
672      property MetaData: IMetaData read GetMetaData;
673      property SQLParams: ISQLParams read GetSQLParams;
674      property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType;
# Line 616 | Line 685 | type
685     found in the Interbase 6.0 API Guide.
686    }
687  
688 <  ITPBItem = interface(IParameterBlockItem) end;
688 >  ITPBItem = interface(IParameterBlockItem)
689 >    ['{544c1f2b-7c12-4a87-a4a5-face7ea72671}']
690 >  end;
691  
692 <  ITPB = specialize IParameterBlock<ITPBItem>;
692 >  ITPB = interface(IParameterBlock<ITPBItem>)
693 >    ['{7369b0ff-defe-437b-81fe-19b211d42d25}']
694 >  end;
695  
696    {The ITransactionAction interface provides access to a Transaction once it
697     has been initially started. After a Commit or Rollback, a transaction
# Line 632 | Line 705 | type
705    TTransactionCompletion = TARollback.. TACommit;
706  
707    ITransaction = interface
708 +    ['{30928d0e-a9d7-4c61-b7cf-14f4f38abe2a}']
709      function getTPB: ITPB;
710      procedure Start(DefaultCompletion: TTransactionCompletion=taCommit);
711      function GetInTransaction: boolean;
# Line 659 | Line 733 | type
733    }
734  
735    TEventInfo = record
736 <    EventName: string;
736 >    EventName: AnsiString;
737      Count: integer;
738    end;
739  
# Line 670 | Line 744 | type
744    { IEvents }
745  
746    IEvents = interface
747 +    ['{6a0be233-ed08-4524-889c-2e45d0c20e5f}']
748      procedure GetEvents(EventNames: TStrings);
749      procedure SetEvents(EventNames: TStrings); overload;
750 <    procedure SetEvents(EventName: string); overload;
750 >    procedure SetEvents(EventName: AnsiString); overload;
751      procedure Cancel;
752      function ExtractEventCounts: TEventCounts;
753      procedure WaitForEvent;
# Line 703 | Line 778 | type
778    TDBOperationCounts = array of TDBOperationCount;
779  
780    IDBInfoItem = interface
781 +    ['{eeb97b51-ec0f-473f-9f75-c1721f055fcb}']
782      function getItemType: byte;
783      function getSize: integer;
784      procedure getRawBytes(var Buffer);
785 <    function getAsString: string;
785 >    function getAsString: AnsiString;
786      function getAsInteger: integer;
787 <    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: string);
787 >    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString);
788      function getAsBytes: TByteArray;
789 <    procedure DecodeVersionString(var Version: byte; var VersionString: string);
789 >    function getAsDateTime: TDateTime;
790 >    procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
791      function getOperationCounts: TDBOperationCounts;
792      procedure DecodeUserNames(UserNames: TStrings);
793  
# Line 719 | Line 796 | type
796      function GetItem(index: integer): IDBInfoItem;
797      function Find(ItemType: byte): IDBInfoItem;
798      property AsInteger: integer read getAsInteger;
799 <    property AsString: string read GetAsString;
799 >    property AsString: AnsiString read GetAsString;
800      property Count: integer read GetCount;
801      property Items[index: integer]: IDBInfoItem read getItem; default;
802    end;
# Line 727 | Line 804 | type
804    { IDBInformation }
805  
806    IDBInformation = interface
807 +    ['{7ac6777f-f0a9-498a-9f5c-4a57a554df81}']
808      function GetCount: integer;
809      function GetItem(index: integer): IDBInfoItem;
810      function Find(ItemType: byte): IDBInfoItem;
# Line 735 | Line 813 | type
813      property Items[index: integer]: IDBInfoItem read getItem; default;
814    end;
815  
816 +  {The Database Information Request Block is used to pass requests for
817 +   database information where at least one item requested has a parameter.
818 +   At present, this is only fb_info_page_contents which has a single
819 +   integer parameter.}
820 +
821 +  IDIRBItem = interface(IParameterBlockItem)
822 +    ['{d34a7511-8435-4a24-81a7-5103d218d234}']
823 +  end;
824 +
825 +  IDIRB = interface(IParameterBlock<IDIRBItem>)
826 +    ['{1010e5ac-0a8f-403b-a302-91625e9d9579}']
827 +  end;
828 +
829 +
830    {The Database Parameter Block (DPB).
831  
832     The DPB provides the parameters used when connecting to a database. It is allocated
# Line 746 | Line 838 | type
838     found in the Interbase 6.0 API Guide.
839     }
840  
841 <  IDPBItem = interface(IParameterBlockItem) end;
841 >  IDPBItem = interface(IParameterBlockItem)
842 >    ['{123d4ad0-087a-4cd1-a344-1b3d03b30673}']
843 >  end;
844  
845 <  IDPB = specialize IParameterBlock<IDPBItem>;
845 >  IDPB = interface(IParameterBlock<IDPBItem>)
846 >    ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
847 >  end;
848  
849    {The IAttachment interface provides access to a Database Connection. It may be
850     used to:
# Line 778 | Line 874 | type
874    { IAttachment }
875  
876    IAttachment = interface
877 +    ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
878 +    function getFirebirdAPI: IFirebirdAPI;
879      function getDPB: IDPB;
880      function AllocateBPB: IBPB;
881 +    function AllocateDIRB: IDIRB;
882      procedure Connect;
883      procedure Disconnect(Force: boolean=false);
884      function IsConnected: boolean;
885      procedure DropDatabase;
886      function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
887      function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
888 <    procedure ExecImmediate(transaction: ITransaction; sql: string; SQLDialect: integer); overload;
889 <    procedure ExecImmediate(TPB: array of byte; sql: string; SQLDialect: integer); overload;
890 <    procedure ExecImmediate(transaction: ITransaction; sql: string); overload;
891 <    procedure ExecImmediate(TPB: array of byte; sql: string); overload;
892 <    function ExecuteSQL(TPB: array of byte; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
893 <    function ExecuteSQL(transaction: ITransaction; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
894 <    function ExecuteSQL(TPB: array of byte; sql: string; params: array of const): IResults; overload;
895 <    function ExecuteSQL(transaction: ITransaction; sql: string; params: array of const): IResults; overload;
896 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
897 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer;
888 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; SQLDialect: integer); overload;
889 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString; SQLDialect: integer); overload;
890 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload;
891 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload;
892 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
893 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
894 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload;
895 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload;
896 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
897 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
898                               params: array of const): IResultSet; overload;
899 <    function OpenCursor(transaction: ITransaction; sql: string): IResultSet; overload;
900 <    function OpenCursor(transaction: ITransaction; sql: string;
899 >    function OpenCursor(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
900 >    function OpenCursor(transaction: ITransaction; sql: AnsiString;
901                               params: array of const): IResultSet; overload;
902 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
903 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer;
902 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
903 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
904                               params: array of const): IResultSet; overload;
905 <    function OpenCursorAtStart(transaction: ITransaction; sql: string): IResultSet; overload;
906 <    function OpenCursorAtStart(transaction: ITransaction; sql: string;
905 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
906 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString;
907                               params: array of const): IResultSet; overload;
908 <    function OpenCursorAtStart(sql: string): IResultSet; overload;
909 <    function OpenCursorAtStart(sql: string;
908 >    function OpenCursorAtStart(sql: AnsiString): IResultSet; overload;
909 >    function OpenCursorAtStart(sql: AnsiString;
910                               params: array of const): IResultSet; overload;
911 <    function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; overload;
912 <    function Prepare(transaction: ITransaction; sql: string): IStatement; overload;
913 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
911 >    function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload;
912 >    function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload;
913 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
914                         aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload;
915 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
915 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
916                         GenerateParamNames: boolean=false): IStatement; overload;
917  
918      {Events}
919      function GetEventHandler(Events: TStrings): IEvents; overload;
920 <    function GetEventHandler(Event: string): IEvents; overload;
920 >    function GetEventHandler(Event: AnsiString): IEvents; overload;
921  
922      {Blob - may use to open existing Blobs. However, ISQLData.AsBlob is preferred}
923  
924 <    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: string; BPB: IBPB=nil): IBlob; overload;
924 >    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
925      function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
926      function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
927 <    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
927 >    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
928  
929      {Array - may use to open existing arrays. However, ISQLData.AsArray is preferred}
930  
931 <    function OpenArray(transaction: ITransaction; RelationName, ColumnName: string; ArrayID: TISC_QUAD): IArray;
932 <    function CreateArray(transaction: ITransaction; RelationName, ColumnName: string): IArray; overload;
931 >    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray;
932 >    function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload;
933      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
934 +    function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
935 +                  Scale: integer; size: cardinal; charSetID: cardinal; dimensions: cardinal;
936 +                  bounds: TArrayBounds): IArrayMetaData;
937  
938      {Database Information}
939      function GetSQLDialect: integer;
940 <    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: string): IBlobMetaData;
941 <    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: string): IArrayMetaData;
940 >    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData;
941 >    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
942      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
943      function GetDBInformation(Request: byte): IDBInformation; overload;
944 +    function GetDBInformation(Requests: IDIRB): IDBInformation; overload;
945 +    function GetConnectString: AnsiString;
946 +    function GetRemoteProtocol: AnsiString;
947 +    function GetAuthenticationMethod: AnsiString;
948 +    function GetSecurityDatabase: AnsiString;
949 +    function GetODSMajorVersion: integer;
950 +    function GetODSMinorVersion: integer;
951      function HasActivity: boolean;
952 +
953 +    {Character Sets}
954 +    function HasDefaultCharSet: boolean;
955 +    function GetDefaultCharSetID: integer;
956 +    function GetCharsetName(CharSetID: integer): AnsiString;
957 +    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
958 +    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
959 +    function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean;
960 +    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
961 +    procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
962 +      AllowReverseLookup:boolean; out CharSetID: integer);
963    end;
964  
965 <  TProtocol = (TCP, SPX, NamedPipe, Local);
965 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
966 >  TProtocol = TCP..xnet;
967  
968    {Service Parameter Block (SPB).
969  
# Line 856 | Line 977 | type
977  
978    }
979  
980 <  ISPBItem = interface(IParameterBlockItem) end;
980 >  ISPBItem = interface(IParameterBlockItem)
981 >    ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
982 >  end;
983  
984 <  ISPB = specialize IParameterBlock<ISPBItem>;
984 >  ISPB = interface(IParameterBlock<ISPBItem>)
985 >    ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
986 >  end;
987  
988    {Service Query Parameter Block (SQPB).
989  
# Line 867 | Line 992 | type
992    }
993  
994    ISQPBItem = interface(IParameterBlockItem)
995 +    ['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}']
996      function CopyFrom(source: TStream; count: integer): integer;
997    end;
998  
999 <  ISQPB = specialize IParameterBlock<ISQPBItem>;
999 >  ISQPB = interface(IParameterBlock<ISQPBItem>)
1000 >    ['{8553e66b-ee62-498b-8431-dff030211447}']
1001 >  end;
1002  
1003    {Service Request Block (SRB).
1004  
# Line 884 | Line 1012 | type
1012  
1013    }
1014  
1015 <  ISRBItem = interface(IParameterBlockItem) end;
1015 >  ISRBItem = interface(IParameterBlockItem)
1016 >    ['{47ec790e-f265-4b30-9dcd-261e51677245}']
1017 >   end;
1018  
1019 <  ISRB = specialize IParameterBlock<ISRBItem>;
1019 >  ISRB = interface(IParameterBlock<ISRBItem>)
1020 >    ['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}']
1021 >  end;
1022  
1023    {The Service Query Results Interface.
1024  
# Line 904 | Line 1036 | type
1036    }
1037  
1038    IServiceQueryResultSubItem = interface
1039 +    ['{8a4c381e-9923-4cc9-a96b-553729248640}']
1040      function getItemType: byte;
1041      function getSize: integer;
1042      procedure getRawBytes(var Buffer);
1043 <    function getAsString: string;
1043 >    function getAsString: AnsiString;
1044      function getAsInteger: integer;
1045      function getAsByte: byte;
1046      function CopyTo(stream: TStream; count: integer): integer;
1047 <    property AsString: string read getAsString;
1047 >    property AsString: AnsiString read getAsString;
1048      property AsInteger: integer read getAsInteger;
1049      property AsByte: byte read getAsByte;
1050    end;
1051  
1052    IServiceQueryResultItem = interface(IServiceQueryResultSubItem)
1053 +    ['{b2806886-206c-4024-8df9-5fe0a7630a5e}']
1054      function getCount: integer;
1055      function getItem(index: integer): IServiceQueryResultSubItem;
1056      function find(ItemType: byte): IServiceQueryResultSubItem;
# Line 925 | Line 1059 | type
1059    end;
1060  
1061    IServiceQueryResults = interface
1062 +    ['{8fbbef7d-fe03-4409-828a-a787d34ef531}']
1063      function getCount: integer;
1064      function getItem(index: integer): IServiceQueryResultItem;
1065      function find(ItemType: byte): IServiceQueryResultItem;
# Line 933 | Line 1068 | type
1068      property Count: integer read getCount;
1069    end;
1070  
1071 +  IFirebirdLibrary = interface;
1072 +
1073    {The IServiceManager interface provides access to a service manager. It can
1074     used to Detach and re-attach to Service Manager, to start services and to
1075     query the service manager.
# Line 943 | Line 1080 | type
1080    { IServiceManager }
1081  
1082    IServiceManager = interface
1083 +    ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1084 +    function getFirebirdAPI: IFirebirdAPI;
1085      function getSPB: ISPB;
1086 <    function getServerName: string;
1086 >    function getServerName: AnsiString;
1087 >    function getProtocol: TProtocol;
1088 >    function getPortNo: AnsiString;
1089      procedure Attach;
1090      procedure Detach(Force: boolean=false);
1091      function IsAttached: boolean;
1092      function AllocateSRB: ISRB;
1093      function AllocateSQPB: ISQPB;
1094 <    procedure Start(Request: ISRB);
1095 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1096 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1094 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1095 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1096 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1097 >  end;
1098 >
1099 >  {Tbe Firebird Library API used to get information about the Firebird library}
1100 >
1101 >
1102 >  IFirebirdLibrary = interface
1103 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1104 >    function GetHandle: TLibHandle;
1105 >    function GetLibraryName: string;
1106 >    function GetLibraryFilePath: string;
1107 >    function GetFirebirdAPI: IFirebirdAPI;
1108    end;
1109  
1110    {The Firebird API.
# Line 964 | Line 1116 | type
1116    }
1117  
1118    IFirebirdAPI = interface
1119 +    ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1120      {Database connections}
1121      function AllocateDPB: IDPB;
1122 <    function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1123 <    function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment;
1122 >    function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1123 >    function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1124 >    function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1125  
1126      {Start Transaction against multiple databases}
1127      function AllocateTPB: ITPB;
# Line 979 | Line 1133 | type
1133      {Service Manager}
1134      function HasServiceAPI: boolean;
1135      function AllocateSPB: ISPB;
1136 <    function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager;
1136 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1137 >    function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1138  
1139      {Information}
1140      function GetStatus: IStatus;
986    function GetLibraryName: string;
1141      function HasRollbackRetaining: boolean;
1142      function IsEmbeddedServer: boolean;
1143 <    function GetImplementationVersion: string;
1143 >    function GetImplementationVersion: AnsiString;
1144  
1145      {Firebird 3 API}
1146      function HasMasterIntf: boolean;
1147      function GetIMaster: TObject;
1148 <
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;
1148 >    function GetFBLibrary: IFirebirdLibrary;
1149   end;
1150  
1151   type
# Line 1014 | Line 1162 | type
1162     private
1163       FSQLCode: Long;
1164     public
1165 <     constructor Create(ASQLCode: Long; Msg: string);
1165 >     constructor Create(ASQLCode: Long; Msg: AnsiString);
1166       property SQLCode: Long read FSQLCode;
1167     end;
1168  
# Line 1025 | Line 1173 | type
1173       FIBErrorCode: Long;
1174     public
1175       constructor Create(Status: IStatus); overload;
1176 <     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: string); overload;
1176 >     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload;
1177       property IBErrorCode: Long read FIBErrorCode;
1178     end;
1179  
# Line 1050 | Line 1198 | function FirebirdAPI: IFirebirdAPI;
1198   function TryIBLoad: Boolean;
1199   procedure CheckIBLoaded;
1200  
1201 + {If you want to explicitly load the Firebird library from a
1202 + non-default location then use this function and its GetFirebirdAPI function
1203 + to get the API.}
1204 +
1205 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1206 +
1207   implementation
1208  
1209   uses FBClientAPI
1210    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1211    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1212  
1213 < var FFirebirdAPI: IFirebirdAPI;
1213 > var FDefaultFBLibrary: IFirebirdLibrary;
1214 >
1215 > type
1216 >
1217 >  { TFBLibrary }
1218 >
1219 >  TFBLibraryImpl = class(TFBLibrary)
1220 >  protected
1221 >    function GetFirebird3API: IFirebirdAPI; override;
1222 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1223 >  end;
1224 >
1225 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1226 > begin
1227 > {$IFDEF USEFIREBIRD3API}
1228 > Result := TFB30ClientAPI.Create(self);
1229 > {$ELSE}
1230 > Result := nil;
1231 > {$ENDIF}
1232 > end;
1233 >
1234 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1235 > begin
1236 >  {$IFDEF USELEGACYFIREBIRDAPI}
1237 >  Result := TFB25ClientAPI.Create(self);
1238 >  {$ELSE}
1239 >  Result := nil;
1240 >  {$ENDIF}
1241 > end;
1242  
1243   function FirebirdAPI: IFirebirdAPI;
1244   begin
1245 <  if FFirebirdAPI = nil then
1245 >  if FDefaultFBLibrary = nil then
1246      CheckIBLoaded;
1247 <  Result := FFirebirdAPI;
1247 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1248   end;
1249  
1250   function TryIBLoad: Boolean;
1251 + var fblib: IFirebirdLibrary;
1252   begin
1253 < Result := FFirebirdAPI <> nil;
1253 > Result := FDefaultFBLibrary <> nil;
1254   try
1072  {$IFDEF USEFIREBIRD3API}
1073  if not Result then
1074  begin
1075    FFirebirdAPI := TFB30ClientAPI.Create;
1076    Result := FFirebirdAPI.HasMasterIntf;
1077  end;
1078  {$ENDIF}
1079  {$IFDEF USELEGACYFIREBIRDAPI}
1255    if not Result then
1256    begin
1257 <    FFirebirdAPI := nil;
1258 <    FFirebirdAPI := TFB25ClientAPI.Create;
1259 <    Result := true;
1260 <  end;
1086 <  {$ENDIF}
1087 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1088 <  begin
1089 <    Result := false;
1090 <    FFirebirdAPI := nil;
1257 >    fblib := TFBLibraryImpl.Create;
1258 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1259 >      FDefaultFBLibrary := fblib;
1260 >    Result := FDefaultFBLibrary <> nil;
1261    end;
1262   except
1263     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1101 | Line 1271 | begin
1271      IBError(ibxeInterBaseMissing, [nil]);
1272   end;
1273  
1274 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1275 + var fblib: IFirebirdLibrary;
1276 + begin
1277 +  if trim(aLibPathName) = '' then
1278 +  begin
1279 +    CheckIBLoaded;
1280 +    Result := FDefaultFBLibrary;
1281 +  end
1282 +  else
1283 +  begin
1284 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1285 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1286 +      IBError(ibxeInterBaseMissing, [nil]);
1287 +    Result := fblib;
1288 +  end;
1289 + end;
1290 +
1291   { EIBError }
1292  
1293 < constructor EIBError.Create(ASQLCode: Long; Msg: string);
1293 > constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
1294   begin
1295    inherited Create(Msg);
1296    FSQLCode := ASQLCode;
# Line 1118 | Line 1305 | begin
1305   end;
1306  
1307   constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long;
1308 <  Msg: string);
1308 >  Msg: AnsiString);
1309   begin
1310    inherited Create(ASQLCode,Msg);
1311    FIBErrorCode := AIBErrorCode;
# Line 1131 | Line 1318 | begin
1318   end;
1319  
1320   initialization
1321 <  FFirebirdAPI := nil;
1321 >  FDefaultFBLibrary := nil;
1322  
1323 + finalization
1324 +  FDefaultFBLibrary := nil;
1325  
1326   end.
1327  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines