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 47 by tony, Mon Jan 9 15:31:51 2017 UTC vs.
Revision 266 by tony, Wed Dec 26 18:34:32 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 = 0;
134 <  FBIntf_Release = 1;
135 <  FBIntf_Version = '1.0.1';
133 >  FBIntf_Minor = 1;
134 >  FBIntf_Release = 4;
135 >  FBIntf_Version = '1.1.4';
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 167 | 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 178 | 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 198 | 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 219 | 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 238 | 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 269 | 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 284 | 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 297 | 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 311 | 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 337 | 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 347 | 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 366 | 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 382 | 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 398 | 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 421 | 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 431 | 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 450 | 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 465 | 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 481 | 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 503 | 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 523 | 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 541 | 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 560 | 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 569 | 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 579 | 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;
# Line 600 | Line 651 | type
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 632 | 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 648 | 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 675 | Line 733 | type
733    }
734  
735    TEventInfo = record
736 <    EventName: string;
736 >    EventName: AnsiString;
737      Count: integer;
738    end;
739  
# Line 686 | 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 719 | 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 735 | 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 743 | 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 751 | 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 762 | 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 794 | 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: string; columnName: string;
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 +    procedure getFBVersion(version: TStrings);
952      function HasActivity: boolean;
953 +
954 +    {Character Sets}
955 +    function HasDefaultCharSet: boolean;
956 +    function GetDefaultCharSetID: integer;
957 +    function GetCharsetName(CharSetID: integer): AnsiString;
958 +    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
959 +    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
960 +    function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean;
961 +    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
962 +    procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
963 +      AllowReverseLookup:boolean; out CharSetID: integer);
964    end;
965  
966 <  TProtocol = (TCP, SPX, NamedPipe, Local);
966 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
967 >  TProtocol = TCP..xnet;
968  
969    {Service Parameter Block (SPB).
970  
# Line 875 | Line 978 | type
978  
979    }
980  
981 <  ISPBItem = interface(IParameterBlockItem) end;
981 >  ISPBItem = interface(IParameterBlockItem)
982 >    ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
983 >  end;
984  
985 <  ISPB = specialize IParameterBlock<ISPBItem>;
985 >  ISPB = interface(IParameterBlock<ISPBItem>)
986 >    ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
987 >  end;
988  
989    {Service Query Parameter Block (SQPB).
990  
# Line 886 | Line 993 | type
993    }
994  
995    ISQPBItem = interface(IParameterBlockItem)
996 +    ['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}']
997      function CopyFrom(source: TStream; count: integer): integer;
998    end;
999  
1000 <  ISQPB = specialize IParameterBlock<ISQPBItem>;
1000 >  ISQPB = interface(IParameterBlock<ISQPBItem>)
1001 >    ['{8553e66b-ee62-498b-8431-dff030211447}']
1002 >  end;
1003  
1004    {Service Request Block (SRB).
1005  
# Line 903 | Line 1013 | type
1013  
1014    }
1015  
1016 <  ISRBItem = interface(IParameterBlockItem) end;
1016 >  ISRBItem = interface(IParameterBlockItem)
1017 >    ['{47ec790e-f265-4b30-9dcd-261e51677245}']
1018 >   end;
1019  
1020 <  ISRB = specialize IParameterBlock<ISRBItem>;
1020 >  ISRB = interface(IParameterBlock<ISRBItem>)
1021 >    ['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}']
1022 >  end;
1023  
1024    {The Service Query Results Interface.
1025  
# Line 923 | Line 1037 | type
1037    }
1038  
1039    IServiceQueryResultSubItem = interface
1040 +    ['{8a4c381e-9923-4cc9-a96b-553729248640}']
1041      function getItemType: byte;
1042      function getSize: integer;
1043      procedure getRawBytes(var Buffer);
1044 <    function getAsString: string;
1044 >    function getAsString: AnsiString;
1045      function getAsInteger: integer;
1046      function getAsByte: byte;
1047      function CopyTo(stream: TStream; count: integer): integer;
1048 <    property AsString: string read getAsString;
1048 >    property AsString: AnsiString read getAsString;
1049      property AsInteger: integer read getAsInteger;
1050      property AsByte: byte read getAsByte;
1051    end;
1052  
1053    IServiceQueryResultItem = interface(IServiceQueryResultSubItem)
1054 +    ['{b2806886-206c-4024-8df9-5fe0a7630a5e}']
1055      function getCount: integer;
1056      function getItem(index: integer): IServiceQueryResultSubItem;
1057      function find(ItemType: byte): IServiceQueryResultSubItem;
# Line 944 | Line 1060 | type
1060    end;
1061  
1062    IServiceQueryResults = interface
1063 +    ['{8fbbef7d-fe03-4409-828a-a787d34ef531}']
1064      function getCount: integer;
1065      function getItem(index: integer): IServiceQueryResultItem;
1066      function find(ItemType: byte): IServiceQueryResultItem;
# Line 952 | Line 1069 | type
1069      property Count: integer read getCount;
1070    end;
1071  
1072 +  IFirebirdLibrary = interface;
1073 +
1074    {The IServiceManager interface provides access to a service manager. It can
1075     used to Detach and re-attach to Service Manager, to start services and to
1076     query the service manager.
# Line 962 | Line 1081 | type
1081    { IServiceManager }
1082  
1083    IServiceManager = interface
1084 +    ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1085 +    function getFirebirdAPI: IFirebirdAPI;
1086      function getSPB: ISPB;
1087 <    function getServerName: string;
1087 >    function getServerName: AnsiString;
1088 >    function getProtocol: TProtocol;
1089 >    function getPortNo: AnsiString;
1090      procedure Attach;
1091      procedure Detach(Force: boolean=false);
1092      function IsAttached: boolean;
1093      function AllocateSRB: ISRB;
1094      function AllocateSQPB: ISQPB;
1095 <    procedure Start(Request: ISRB);
1096 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1097 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1095 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1096 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1097 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1098 >  end;
1099 >
1100 >  {Tbe Firebird Library API used to get information about the Firebird library}
1101 >
1102 >
1103 >  IFirebirdLibrary = interface
1104 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1105 >    function GetHandle: TLibHandle;
1106 >    function GetLibraryName: string;
1107 >    function GetLibraryFilePath: string;
1108 >    function GetFirebirdAPI: IFirebirdAPI;
1109    end;
1110  
1111    {The Firebird API.
# Line 983 | Line 1117 | type
1117    }
1118  
1119    IFirebirdAPI = interface
1120 +    ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1121      {Database connections}
1122      function AllocateDPB: IDPB;
1123 <    function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1124 <    function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1125 <    function CreateDatabase(sql: string; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1123 >    function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1124 >    function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1125 >    function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1126  
1127      {Start Transaction against multiple databases}
1128      function AllocateTPB: ITPB;
# Line 999 | Line 1134 | type
1134      {Service Manager}
1135      function HasServiceAPI: boolean;
1136      function AllocateSPB: ISPB;
1137 <    function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager;
1137 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1138 >    function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1139  
1140      {Information}
1141      function GetStatus: IStatus;
1006    function GetLibraryName: string;
1142      function HasRollbackRetaining: boolean;
1143      function IsEmbeddedServer: boolean;
1144 <    function GetImplementationVersion: string;
1144 >    function GetImplementationVersion: AnsiString;
1145  
1146      {Firebird 3 API}
1147      function HasMasterIntf: boolean;
1148      function GetIMaster: TObject;
1149 <
1015 <    {utility}
1016 <    function GetCharsetName(CharSetID: integer): string;
1017 <    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
1018 <    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
1019 <    function CharSetName2CharSetID(CharSetName: string; var CharSetID: integer): boolean;
1020 <    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
1149 >    function GetFBLibrary: IFirebirdLibrary;
1150   end;
1151  
1152   type
# Line 1034 | Line 1163 | type
1163     private
1164       FSQLCode: Long;
1165     public
1166 <     constructor Create(ASQLCode: Long; Msg: string);
1166 >     constructor Create(ASQLCode: Long; Msg: AnsiString);
1167       property SQLCode: Long read FSQLCode;
1168     end;
1169  
# Line 1045 | Line 1174 | type
1174       FIBErrorCode: Long;
1175     public
1176       constructor Create(Status: IStatus); overload;
1177 <     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: string); overload;
1177 >     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload;
1178       property IBErrorCode: Long read FIBErrorCode;
1179     end;
1180  
# Line 1070 | Line 1199 | function FirebirdAPI: IFirebirdAPI;
1199   function TryIBLoad: Boolean;
1200   procedure CheckIBLoaded;
1201  
1202 + {If you want to explicitly load the Firebird library from a
1203 + non-default location then use this function and its GetFirebirdAPI function
1204 + to get the API.}
1205 +
1206 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1207 +
1208   implementation
1209  
1210   uses FBClientAPI
1211    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1212    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1213  
1214 < var FFirebirdAPI: IFirebirdAPI;
1214 > var FDefaultFBLibrary: IFirebirdLibrary;
1215 >
1216 > type
1217 >
1218 >  { TFBLibrary }
1219 >
1220 >  TFBLibraryImpl = class(TFBLibrary)
1221 >  protected
1222 >    function GetFirebird3API: IFirebirdAPI; override;
1223 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1224 >  end;
1225 >
1226 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1227 > begin
1228 > {$IFDEF USEFIREBIRD3API}
1229 > Result := TFB30ClientAPI.Create(self);
1230 > {$ELSE}
1231 > Result := nil;
1232 > {$ENDIF}
1233 > end;
1234 >
1235 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1236 > begin
1237 >  {$IFDEF USELEGACYFIREBIRDAPI}
1238 >  Result := TFB25ClientAPI.Create(self);
1239 >  {$ELSE}
1240 >  Result := nil;
1241 >  {$ENDIF}
1242 > end;
1243  
1244   function FirebirdAPI: IFirebirdAPI;
1245   begin
1246 <  if FFirebirdAPI = nil then
1246 >  if FDefaultFBLibrary = nil then
1247      CheckIBLoaded;
1248 <  Result := FFirebirdAPI;
1248 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1249   end;
1250  
1251   function TryIBLoad: Boolean;
1252 + var fblib: IFirebirdLibrary;
1253   begin
1254 < Result := FFirebirdAPI <> nil;
1254 > Result := FDefaultFBLibrary <> nil;
1255   try
1092  {$IFDEF USEFIREBIRD3API}
1256    if not Result then
1257    begin
1258 <    FFirebirdAPI := TFB30ClientAPI.Create;
1259 <    Result := FFirebirdAPI.HasMasterIntf;
1260 <  end;
1261 <  {$ENDIF}
1099 <  {$IFDEF USELEGACYFIREBIRDAPI}
1100 <  if not Result then
1101 <  begin
1102 <    FFirebirdAPI := nil;
1103 <    FFirebirdAPI := TFB25ClientAPI.Create;
1104 <    Result := true;
1105 <  end;
1106 <  {$ENDIF}
1107 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1108 <  begin
1109 <    Result := false;
1110 <    FFirebirdAPI := nil;
1258 >    fblib := TFBLibraryImpl.Create;
1259 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1260 >      FDefaultFBLibrary := fblib;
1261 >    Result := FDefaultFBLibrary <> nil;
1262    end;
1263   except
1264     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1121 | Line 1272 | begin
1272      IBError(ibxeInterBaseMissing, [nil]);
1273   end;
1274  
1275 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1276 + var fblib: IFirebirdLibrary;
1277 + begin
1278 +  if trim(aLibPathName) = '' then
1279 +  begin
1280 +    CheckIBLoaded;
1281 +    Result := FDefaultFBLibrary;
1282 +  end
1283 +  else
1284 +  begin
1285 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1286 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1287 +      IBError(ibxeInterBaseMissing, [nil]);
1288 +    Result := fblib;
1289 +  end;
1290 + end;
1291 +
1292   { EIBError }
1293  
1294 < constructor EIBError.Create(ASQLCode: Long; Msg: string);
1294 > constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
1295   begin
1296    inherited Create(Msg);
1297    FSQLCode := ASQLCode;
# Line 1138 | Line 1306 | begin
1306   end;
1307  
1308   constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long;
1309 <  Msg: string);
1309 >  Msg: AnsiString);
1310   begin
1311    inherited Create(ASQLCode,Msg);
1312    FIBErrorCode := AIBErrorCode;
# Line 1151 | Line 1319 | begin
1319   end;
1320  
1321   initialization
1322 <  FFirebirdAPI := nil;
1322 >  FDefaultFBLibrary := nil;
1323  
1324 + finalization
1325 +  FDefaultFBLibrary := nil;
1326  
1327   end.
1328  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines