ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/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 347 by tony, Mon Sep 20 22:08:20 2021 UTC

# Line 60 | Line 60
60   {                                                                        }
61   {************************************************************************}
62   unit IB;
63 + {$IFDEF MSWINDOWS}
64 + {$DEFINE WINDOWS}
65 + {$ENDIF}
66  
67   {$IFDEF FPC}
68 < {$mode objfpc}{$H+}
68 > {$mode delphi}
69   {$codepage UTF8}
70   {$interfaces COM}
71 < {$IF FPC_FULLVERSION < 30000 }
71 > {$IF defined(FPC) and (FPC_FULLVERSION < 30000) }
72   {$ERROR FPC Version 3.0.0 or later is required}
73 < {$ENDIF}
73 > {$IFEND}
74   {$ENDIF}
75  
76 + {$IFNDEF LEGACYFIREBIRDAPIONLY}
77   {$DEFINE USEFIREBIRD3API}
78 + {$ENDIF}
79 + {$IFNDEF FIREBIRD3APIONLY}
80   {$DEFINE USELEGACYFIREBIRDAPI}
81 + {$ENDIF}
82  
83   {
84    This unit defines the interfaces used to provide the Pascal Language
# Line 103 | Line 110 | unit IB;
110  
111    5. Straightforward progammatic access to the Firebird API from Pascal programs.
112  
113 +  6. FPC and Delphi Support.
114 +
115    String Types
116    ============
117  
# Line 117 | Line 126 | unit IB;
126   interface
127  
128   uses
129 <  Classes, SysUtils, DB, FBMessages, IBExternals;
129 >  Classes,
130 >  {$IFDEF WINDOWS}Windows, {$ENDIF}
131 >  {$IFDEF FPC} Dynlibs, {$ENDIF}
132 >  SysUtils, DB, FBMessages, IBExternals, FmtBcd;
133  
134   const
135    {Interface version information}
136    FBIntf_Major = 1;
137 <  FBIntf_Minor = 0;
138 <  FBIntf_Release = 1;
139 <  FBIntf_Version = '1.0.1';
137 >  FBIntf_Minor = 3;
138 >  FBIntf_Release = 2;
139 >  FBIntf_Version = '1.3.2';
140 >
141 > const
142 >  {DPB, TPB and SPB Parameter Block Name Prefixes}
143 >  DPBPrefix = 'isc_dpb_';
144 >  TPBPrefix = 'isc_tpb_';
145 >
146 > const
147 >  {Time Zone ID constraint}
148 >  MaxOffsetTimeZoneID = 2879; {lower values represent a time zone offset between
149 >                               -23:59 and 23:59. Higher values are keys to the
150 >                               Time Zone database.}
151 >
152 >  TimeZoneID_GMT = 23*minsPerHour + 59;
153 >  decimillisecondsPerSecond = 10000;
154 >  TimeZoneDisplacementDelta = 60*23 + 59; {23:59 in minutes}
155  
156   {These include files are converted from the 'C' originals in the Firebird API
157   and define the various constants used by the API}
158  
159 < {$I consts_pub.inc}
160 < {$I inf_pub.inc}
161 < {$I configkeys.inc}
159 > {$I 'include/consts_pub.inc'}
160 > {$I 'include/dyn_consts.inc'}
161 > {$I 'include/inf_pub.inc'}
162 > {$I 'include/configkeys.inc'}
163 > {$I 'include/blr.inc'}
164  
165   {The following constants define the values return by calls to the GetSQLType
166   methods provided by several of the interfaces defined below.}
# Line 153 | Line 182 | const
182    SQL_TYPE_TIME                  =        560;
183    SQL_TYPE_DATE                  =        570;
184    SQL_INT64                      =        580;
185 +  SQL_TIMESTAMP_TZ_EX            =        32748;
186 +  SQL_TIME_TZ_EX                 =        32750;
187 +  SQL_INT128                     =        32752;
188    SQL_BOOLEAN                    =        32764;
189 +  SQL_TIMESTAMP_TZ               =        32754;
190 +  SQL_TIME_TZ                    =        32756;
191 +  SQL_DEC_FIXED                  =        32758;    {FB4 Beta 1 only}
192 +  SQL_DEC16                      =        32760;
193 +  SQL_DEC34                      =        32762;
194 +  SQL_NULL                       =        32766;
195    SQL_DATE                       =        SQL_TIMESTAMP;
196  
197   type
# Line 167 | Line 205 | type
205     PGDS__QUAD           = ^TGDS__QUAD;
206     PISC_QUAD            = ^TISC_QUAD;
207  
208 + {$IFNDEF FPC}
209 + {Delphi missing definitions}
210 + type
211 +  TLibHandle = THandle;
212 +
213 + const
214 +  NilHandle = 0;
215 +  DirectorySeparator = '\';
216 +
217 + {Delphi only seems to define CP_UTF8 and CP_UTF16}
218 + const
219 +  CP_ACP     = 0;     // default to ANSI code page
220 +  CP_OEMCP   = 1;     // default to OEM (console) code page
221 +  CP_UTF16BE = 1201;  // unicodeFFFE
222 +  CP_UTF7    = 65000; // utf-7
223 +  CP_ASCII   = 20127; // us-ascii
224 +  CP_NONE    = $FFFF; // rawbytestring encoding
225 +
226 + {$ENDIF}
227 +
228 + type
229 + {$IF not declared(TSystemCodePage)}
230 +  TSystemCodePage = word; {not defined in Delphi}
231 + {$IFEND}
232 +
233    TIBSQLStatementTypes =
234                   (SQLUnknown, SQLSelect, SQLInsert,
235                    SQLUpdate, SQLDelete, SQLDDL,
236                    SQLGetSegment, SQLPutSegment,
237                    SQLExecProcedure, SQLStartTransaction,
238                    SQLCommit, SQLRollback,
239 <                  SQLSelectForUpdate, SQLSetGenerator);
239 >                  SQLSelectForUpdate, SQLSetGenerator,
240 >                  SQLSavePoint);
241  
242    TFBStatusCode = cardinal;
243    TByteArray = array of byte;
244 +  TFBTimeZoneID = ISC_USHORT;
245  
246 +  IFirebirdAPI = interface;
247    IAttachment = interface;
248    ITransaction = interface;
249 +  IStatement = interface;
250  
251 <  {The IParameterBlock generic interface provides the template for all parameter
251 >  {The IParameterBlock interface provides the template for all parameter
252     block interfaces}
253  
254 <  generic IParameterBlock<_IItem> = interface
254 >  IParameterBlock<_IItem> = interface
255      function getCount: integer;
256      function Add(ParamType: byte): _IItem;
257      function getItems(index: integer): _IItem;
# Line 194 | Line 261 | type
261      property Items[index: integer]: _IItem read getItems; default;
262    end;
263  
264 +  IParameterBlockWithTypeNames<_IItem> = interface(IParameterBlock<_IItem>)
265 +    function AddByTypeName(ParamTypeName: AnsiString): _IItem;
266 +    function GetDPBParamTypeName(ParamType: byte): Ansistring; deprecated 'Use Get ParamTypeName';
267 +    function GetParamTypeName(ParamType: byte): Ansistring;
268 +  end;
269 +
270    {IParameterBlockItem is not used on its own but instead provides a base type for
271     different parameter block items }
272  
273    IParameterBlockItem = interface
274 +    ['{53b23f7b-abda-46a5-9aa5-07bd5e723266}']
275      function getParamType: byte;
276      function getAsInteger: integer;
277 <    function getAsString: string;
277 >    function getAsString: AnsiString;
278      function getAsByte: byte;
279 <    procedure setAsString(aValue: string);
279 >    procedure setAsString(aValue: AnsiString);
280      procedure setAsByte(aValue: byte);
281      procedure SetAsInteger(aValue: integer);
282 <    property AsString: string read getAsString write setAsString;
282 >    property AsString: AnsiString read getAsString write setAsString;
283      property AsByte: byte read getAsByte write setAsByte;
284      property AsInteger: integer read getAsInteger write SetAsInteger;
285    end;
286  
287 +  IParameterBlockItemWithTypeName = interface(IParameterBlockItem)
288 +    function getParamTypeName: AnsiString;
289 +  end;
290  
291    {The IStatus interface provides access to error information, if any, returned
292     by the last API call. It can also be used to customise the error message
# Line 218 | Line 295 | type
295     This interface can be accessed from IFirebirdAPI.
296     }
297  
298 +   TIBDataBaseErrorMessage    = (ShowSQLCode,
299 +                                   ShowIBMessage,
300 +                                   ShowSQLMessage);
301 +
302 +   TIBDataBaseErrorMessages   = set of TIBDataBaseErrorMessage;
303 +
304 +   TStatusCode = long;
305 +
306    IStatus = interface
307 <    function GetIBErrorCode: Long;
308 <    function Getsqlcode: Long;
309 <    function GetMessage: string;
307 >    ['{34167722-af38-4831-b08a-93162d58ede3}']
308 >    function GetIBErrorCode: TStatusCode;
309 >    function Getsqlcode: TStatusCode;
310 >    function GetMessage: AnsiString;
311      function CheckStatusVector(ErrorCodes: array of TFBStatusCode): Boolean;
312      function GetIBDataBaseErrorMessages: TIBDataBaseErrorMessages;
313      procedure SetIBDataBaseErrorMessages(Value: TIBDataBaseErrorMessages);
# Line 238 | Line 324 | type
324    TArrayBounds = array of TArrayBound;
325  
326    IArrayMetaData = interface
327 +    ['{7dd0aea4-59af-4c2a-b958-565d5025c489}']
328      function GetSQLType: cardinal;
329 <    function GetSQLTypeName: string;
329 >    function GetSQLTypeName: AnsiString;
330      function GetScale: integer;
331      function GetSize: cardinal;
332 +    function GetCharSetWidth: integer;
333      function GetCharSetID: cardinal;
334 <    function GetTableName: string;
335 <    function GetColumnName: string;
334 >    function GetTableName: AnsiString;
335 >    function GetColumnName: AnsiString;
336      function GetDimensions: integer;
337      function GetBounds: TArrayBounds;
338    end;
# Line 269 | Line 357 | type
357    TArrayEventHandler = procedure(Sender: IArray; Reason: TArrayEventReason) of object;
358  
359    IArray = interface(IArrayMetaData)
360 +    ['{631c6bb1-fb49-44fb-a64a-c49859632b88}']
361      function GetArrayID: TISC_QUAD;
362      procedure Clear;
363      function IsEmpty: boolean;
# Line 279 | Line 368 | type
368      function GetAsBoolean(index: array of integer): boolean;
369      function GetAsCurrency(index: array of integer): Currency;
370      function GetAsInt64(index: array of integer): Int64;
371 <    function GetAsDateTime(index: array of integer): TDateTime;
371 >    function GetAsDateTime(index: array of integer): TDateTime; overload;
372 >    procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
373 >    procedure GetAsDateTime(index: array of integer; var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
374 >    procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
375 >    procedure GetAsTime(index: array of integer; var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
376 >    function GetAsUTCDateTime(index: array of integer): TDateTime;
377      function GetAsDouble(index: array of integer): Double;
378      function GetAsFloat(index: array of integer): Float;
379      function GetAsLong(index: array of integer): Long;
380      function GetAsShort(index: array of integer): Short;
381 <    function GetAsString(index: array of integer): String;
381 >    function GetAsString(index: array of integer): AnsiString;
382      function GetAsVariant(index: array of integer): Variant;
383 +    function GetAsBCD(index: array of integer): tBCD;
384      procedure SetAsInteger(index: array of integer; AValue: integer);
385      procedure SetAsBoolean(index: array of integer; AValue: boolean);
386      procedure SetAsCurrency(index: array of integer; Value: Currency);
387      procedure SetAsInt64(index: array of integer; Value: Int64);
388      procedure SetAsDate(index: array of integer; Value: TDateTime);
389 +    procedure SetAsDateTime(index: array of integer; Value: TDateTime); overload;
390 +    procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
391 +    procedure SetAsDateTime(index: array of integer; aValue: TDateTime; aTimeZone: AnsiString); overload;
392 +    procedure SetAsTime(index: array of integer; Value: TDateTime); overload;
393 +    procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
394 +    procedure SetAsTime(index: array of integer; aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
395 +    procedure SetAsUTCDateTime(index: array of integer; aUTCTime: TDateTime);
396      procedure SetAsLong(index: array of integer; Value: Long);
295    procedure SetAsTime(index: array of integer; Value: TDateTime);
296    procedure SetAsDateTime(index: array of integer; Value: TDateTime);
397      procedure SetAsDouble(index: array of integer; Value: Double);
398      procedure SetAsFloat(index: array of integer; Value: Float);
399      procedure SetAsShort(index: array of integer; Value: Short);
400 <    procedure SetAsString(index: array of integer; Value: String);
400 >    procedure SetAsString(index: array of integer; Value: AnsiString);
401      procedure SetAsVariant(index: array of integer; Value: Variant);
402 +    procedure SetAsBcd(index: array of integer; aValue: tBCD);
403      procedure SetBounds(dim, UpperBound, LowerBound: integer);
404      function GetAttachment: IAttachment;
405      function GetTransaction: ITransaction;
# Line 311 | Line 412 | type
412    }
413  
414    IBlobMetaData = interface
415 +    ['{575f3c61-bb33-46a5-8975-bb7d1b6e37cc}']
416      function GetSubType: integer;
417      function GetCharSetID: cardinal;
418      function GetCodePage: TSystemCodePage;
419      function GetSegmentSize: cardinal;
420 <    function GetRelationName: string;
421 <    function GetColumnName: string;
420 >    function GetRelationName: AnsiString;
421 >    function GetColumnName: AnsiString;
422    end;
423  
424    {The Blob Parameter block is used to select a Blob Filter}
425  
426 <  IBPBItem = interface (IParameterBlockItem) end;
426 >  IBPBItem = interface (IParameterBlockItem)
427 >    ['{660822a5-3114-4c16-b6cb-c1a7b2aba70d}']
428 >  end;
429  
430 <  IBPB = specialize IParameterBlock<IBPBItem>;
430 >  IBPB = interface (IParameterBlock<IBPBItem>)
431 >    ['{e0cb9eb5-17f7-4416-b7d1-3cddd1dfca76}']
432 >  end;
433  
434    { The Blob Interface provides access to a blob data item.
435  
# Line 337 | Line 443 | type
443    TBlobType = (btSegmented,btStream);
444  
445    IBlob = interface(IBlobMetaData)
446 +    ['{3090a145-7780-442b-b15b-efd4568b8611}']
447      function GetBPB: IBPB;
448      procedure Cancel;
449      procedure Close;
# Line 347 | Line 454 | type
454                        TotalSize: Int64; var BlobType: TBlobType);
455      function Read(var Buffer; Count: Longint): Longint;
456      function Write(const Buffer; Count: Longint): Longint;
457 <    function LoadFromFile(Filename: string): IBlob;
457 >    function LoadFromFile(Filename: AnsiString): IBlob;
458      function LoadFromStream(S: TStream) : IBlob;
459 <    function SaveToFile(Filename: string): IBlob;
459 >    function SaveToFile(Filename: AnsiString): IBlob;
460      function SaveToStream(S: TStream): IBlob;
461      function GetAsString: rawbytestring;
462      procedure SetAsString(aValue: rawbytestring);
# Line 363 | Line 470 | type
470      the output of an SQL Statement.
471    }
472  
473 +  TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP}
474 +                        dfDateTime,   {SQL DATETIME}
475 +                        dfTime,      {SQL TIME}
476 +                        dfTimestampTZ, {SQL_TIMESTAMP_TZ}
477 +                        dfTimeTZ);       {SQLTIME_TZ
478 +
479    { IColumnMetaData }
480  
481    IColumnMetaData = interface
482 +    ['{c222e6c3-53c1-469f-9e05-0a5c3ef232d8}']
483      function GetIndex: integer;
484      function GetSQLType: cardinal;
485 <    function GetSQLTypeName: string;
485 >    function GetSQLTypeName: AnsiString;
486      function getSubtype: integer;
487 <    function getRelationName: string;
488 <    function getOwnerName: string;
489 <    function getSQLName: string;    {Name of the column}
490 <    function getAliasName: string;  {Alias Name of column or Column Name if no alias}
491 <    function getName: string;       {Disambiguated uppercase Field Name}
487 >    function getRelationName: AnsiString;
488 >    function getOwnerName: AnsiString;
489 >    function getSQLName: AnsiString;    {Name of the column}
490 >    function getAliasName: AnsiString;  {Alias Name of column or Column Name if no alias}
491 >    function getName: AnsiString;       {Disambiguated uppercase Field Name}
492      function getScale: integer;
493      function getCharSetID: cardinal;
494      function getCodePage: TSystemCodePage;
495 +    function GetCharSetWidth: integer;
496      function getIsNullable: boolean;
497      function GetSize: cardinal;
498      function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
499      function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
500 <    property Name: string read GetName;
500 >    function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer;
501 >    function GetStatement: IStatement;
502 >    function GetTransaction: ITransaction;
503 >    property Name: AnsiString read GetName;
504      property Size: cardinal read GetSize;
505      property SQLType: cardinal read GetSQLType;
506      property Scale: integer read getScale;
# Line 398 | Line 516 | type
516    { IMetaData }
517  
518    IMetaData = interface
519 +    ['{4dafdbb6-0d36-4f1f-9c95-8b132804b965}']
520      function getCount: integer;
521      function getColumnMetaData(index: integer): IColumnMetaData;
522 <    function GetUniqueRelationName: string; {Non empty if all columns come from the same table}
523 <    function ByName(Idx: String): IColumnMetaData;
522 >    function GetUniqueRelationName: AnsiString; {Non empty if all columns come from the same table}
523 >    function ByName(Idx: AnsiString): IColumnMetaData;
524      property ColMetaData[index: integer]: IColumnMetaData read getColumnMetaData; default;
525      property Count: integer read getCount;
526    end;
# Line 421 | Line 540 | type
540  
541  
542    ISQLData = interface(IColumnMetaData)
543 +    ['{3f493e31-7e3f-4606-a07c-b210b9e3619d}']
544 +    function GetStrDataLength: short;
545      function GetAsBoolean: boolean;
546      function GetAsCurrency: Currency;
547      function GetAsInt64: Int64;
548 <    function GetAsDateTime: TDateTime;
548 >    function GetAsDateTime: TDateTime; overload;
549 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
550 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
551 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
552 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
553 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
554 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
555 >    function GetAsUTCDateTime: TDateTime;
556      function GetAsDouble: Double;
557      function GetAsFloat: Float;
558      function GetAsLong: Long;
559      function GetAsPointer: Pointer;
560      function GetAsQuad: TISC_QUAD;
561      function GetAsShort: short;
562 <    function GetAsString: String;
562 >    function GetAsString: AnsiString;
563      function GetIsNull: Boolean;
564      function GetAsVariant: Variant;
565      function GetAsBlob: IBlob; overload;
566      function GetAsBlob(BPB: IBPB): IBlob; overload;
567      function GetAsArray: IArray;
568 +    function GetAsBCD: tBCD;
569      property AsDate: TDateTime read GetAsDateTime;
570      property AsBoolean:boolean read GetAsBoolean;
571      property AsTime: TDateTime read GetAsDateTime;
# Line 450 | Line 579 | type
579      property AsPointer: Pointer read GetAsPointer;
580      property AsQuad: TISC_QUAD read GetAsQuad;
581      property AsShort: short read GetAsShort;
582 <    property AsString: String read GetAsString;
582 >    property AsString: AnsiString read GetAsString;
583      property AsVariant: Variant read GetAsVariant ;
584      property AsBlob: IBlob read GetAsBlob;
585      property AsArray: IArray read GetAsArray;
586 +    property AsBCD: tBCD read GetAsBCD;
587      property IsNull: Boolean read GetIsNull;
588      property Value: Variant read GetAsVariant;
589    end;
# Line 465 | Line 595 | type
595    }
596  
597    IResults = interface
598 +    ['{e836b2bb-93d1-4bbf-a8eb-7ce535de3bb5}']
599     function getCount: integer;
600 +   function GetStatement: IStatement;
601     function GetTransaction: ITransaction;
602 <   function ByName(Idx: String): ISQLData;
602 >   function ByName(Idx: AnsiString): ISQLData;
603     function getSQLData(index: integer): ISQLData;
604 <   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar);
604 >   procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
605     procedure SetRetainInterfaces(aValue: boolean);
606     property Data[index: integer]: ISQLData read getSQLData; default;
607     property Count: integer read getCount;
# Line 481 | Line 613 | type
613      in turn, used to access the data returned by each field of the current row.
614    }
615    IResultSet = interface(IResults)
616 +    ['{0ae4979b-7857-4e8c-8918-ec6f155b51a0}']
617      function FetchNext: boolean;
618 <    function GetCursorName: string;
618 >    function GetCursorName: AnsiString;
619      function IsEof: boolean;
620      procedure Close;
621    end;
# Line 503 | Line 636 | type
636    }
637  
638    ISQLParam = interface
639 +    ['{b22b4578-6d41-4807-a9a9-d2ec8d1d5a14}']
640      function GetIndex: integer;
641      function GetSQLType: cardinal;
642 <    function GetSQLTypeName: string;
642 >    function GetSQLTypeName: AnsiString;
643      function getSubtype: integer;
644 <    function getName: string;
644 >    function getName: AnsiString;
645      function getScale: integer;
646      function getCharSetID: cardinal;
647      function getCodePage: TSystemCodePage;
# Line 516 | Line 650 | type
650      function GetAsBoolean: boolean;
651      function GetAsCurrency: Currency;
652      function GetAsInt64: Int64;
653 <    function GetAsDateTime: TDateTime;
653 >    function GetAsDateTime: TDateTime; overload;
654 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
655 >    procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
656 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
657 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
658 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
659 >    procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
660 >    function GetAsUTCDateTime: TDateTime;
661      function GetAsDouble: Double;
662      function GetAsFloat: Float;
663      function GetAsLong: Long;
664      function GetAsPointer: Pointer;
665      function GetAsQuad: TISC_QUAD;
666      function GetAsShort: short;
667 <    function GetAsString: String;
667 >    function GetAsString: AnsiString;
668      function GetIsNull: boolean;
669      function GetAsVariant: Variant;
670      function GetAsBlob: IBlob;
671      function GetAsArray: IArray;
672 +    function GetAsBCD: tBCD;
673 +    function GetStatement: IStatement;
674 +    function GetTransaction: ITransaction;
675      procedure Clear;
676      function GetModified: boolean;
677      procedure SetAsBoolean(AValue: boolean);
# Line 535 | Line 679 | type
679      procedure SetAsInt64(aValue: Int64);
680      procedure SetAsDate(aValue: TDateTime);
681      procedure SetAsLong(aValue: Long);
682 <    procedure SetAsTime(aValue: TDateTime);
683 <    procedure SetAsDateTime(aValue: TDateTime);
682 >    procedure SetAsTime(aValue: TDateTime); overload;
683 >    procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
684 >    procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
685 >    procedure SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
686 >    procedure SetAsTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
687 >    procedure SetAsDateTime(aValue: TDateTime); overload;
688 >    procedure SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
689 >    procedure SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
690 >    procedure SetAsUTCDateTime(aUTCTime: TDateTime);
691      procedure SetAsDouble(aValue: Double);
692      procedure SetAsFloat(aValue: Float);
693      procedure SetAsPointer(aValue: Pointer);
694      procedure SetAsShort(aValue: Short);
695 <    procedure SetAsString(aValue: String);
695 >    procedure SetAsString(aValue: AnsiString);
696      procedure SetAsVariant(aValue: Variant);
697      procedure SetIsNull(aValue: Boolean);
698      procedure SetAsBlob(aValue: IBlob);
699      procedure SetAsArray(anArray: IArray);
700      procedure SetAsQuad(aValue: TISC_QUAD);
701      procedure SetCharSetID(aValue: cardinal);
702 +    procedure SetAsBcd(aValue: tBCD);
703      property AsDate: TDateTime read GetAsDateTime write SetAsDate;
704      property AsBoolean:boolean read GetAsBoolean write SetAsBoolean;
705      property AsTime: TDateTime read GetAsDateTime write SetAsTime;
# Line 560 | Line 712 | type
712      property AsLong: Long read GetAsLong write SetAsLong;
713      property AsPointer: Pointer read GetAsPointer write SetAsPointer;
714      property AsShort: Short read GetAsShort write SetAsShort;
715 <    property AsString: String read GetAsString write SetAsString;
715 >    property AsString: AnsiString read GetAsString write SetAsString;
716      property AsVariant: Variant read GetAsVariant write SetAsVariant;
717      property AsBlob: IBlob read GetAsBlob write SetAsBlob;
718      property AsArray: IArray read GetAsArray write SetAsArray;
719 +    property AsBCD: tBCD read GetAsBCD write SetAsBCD;
720      property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad;
721      property Value: Variant read GetAsVariant write SetAsVariant;
722      property IsNull: Boolean read GetIsNull write SetIsNull;
723      property IsNullable: Boolean read GetIsNullable;
724      property Modified: Boolean read getModified;
725 <    property Name: string read GetName;
725 >    property Name: AnsiString read GetName;
726      property SQLType: cardinal read GetSQLType;
727    end;
728  
# Line 579 | Line 732 | type
732    }
733  
734    ISQLParams = interface
735 +    ['{c6d95ac7-b2b7-461b-b890-afef0acbb077}']
736      function getCount: integer;
737      function getSQLParam(index: integer): ISQLParam;
738 <    function ByName(Idx: String): ISQLParam ;
738 >    function ByName(Idx: AnsiString): ISQLParam ;
739      function GetModified: Boolean;
740 +    function GetHasCaseSensitiveParams: Boolean;
741      property Modified: Boolean read GetModified;
742      property Params[index: integer]: ISQLParam read getSQLParam; default;
743      property Count: integer read getCount;
# Line 595 | Line 750 | type
750  
751    TPerfCounters = array[TPerfStats] of Int64;
752  
753 +  {Batch Query Execution Support}
754 +
755 +  TBatchCompletionState = (bcExecuteFailed, bcSuccessNoInfo, bcNoMoreErrors);
756 +
757 +  IBatchCompletion = interface
758 +  ['{9bc3d49d-16d9-4606-94e5-ee987103ad92}']
759 +    function getTotalProcessed: cardinal;
760 +    function getState(updateNo: cardinal): TBatchCompletionState;
761 +    function getStatusMessage(updateNo: cardinal): AnsiString;
762 +    function getUpdated: integer;
763 +    function getErrorStatus(var RowNo: integer; var status: IStatus): boolean;
764 +    end;
765 +
766    {The IStatement interface provides access to an SQL Statement once it has been
767     initially prepared. The interface is returned from the IAttachment interface.
768     }
769  
770    IStatement = interface
771 +    ['{a260576d-a07d-4a66-b02d-1b72543fd7cf}']
772      function GetMetaData: IMetaData;  {Output Metadata}
773      function GetSQLParams: ISQLParams;{Statement Parameters}
774 <    function GetPlan: String;
774 >    function GetPlan: AnsiString;
775      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
776      function GetSQLStatementType: TIBSQLStatementTypes;
777 <    function GetSQLText: string;
777 >    function GetSQLStatementTypeName: AnsiString;
778 >    function GetSQLText: AnsiString;
779 >    function GetProcessedSQLText: AnsiString;
780      function GetSQLDialect: integer;
781      function IsPrepared: boolean;
782 +    function HasBatchMode: boolean;
783 +    function IsInBatchMode: boolean;
784      procedure Prepare(aTransaction: ITransaction=nil);
785      function Execute(aTransaction: ITransaction=nil): IResults;
786      function OpenCursor(aTransaction: ITransaction=nil): IResultSet;
# Line 616 | Line 789 | type
789      procedure SetRetainInterfaces(aValue: boolean);
790      procedure EnableStatistics(aValue: boolean);
791      function GetPerfStatistics(var stats: TPerfCounters): boolean;
792 +    {IBatch interface support}
793 +    procedure AddToBatch;
794 +    function ExecuteBatch(aTransaction: ITransaction=nil): IBatchCompletion;
795 +    procedure CancelBatch;
796 +    function GetBatchCompletion: IBatchCompletion;
797 +    function GetBatchRowLimit: integer;
798 +    procedure SetBatchRowLimit(aLimit: integer);
799 +    {Stale Reference Check}
800 +    procedure SetStaleReferenceChecks(Enable:boolean); {default true}
801 +    function GetStaleReferenceChecks: boolean;
802 +
803      property MetaData: IMetaData read GetMetaData;
804      property SQLParams: ISQLParams read GetSQLParams;
805      property SQLStatementType: TIBSQLStatementTypes read GetSQLStatementType;
# Line 632 | Line 816 | type
816     found in the Interbase 6.0 API Guide.
817    }
818  
819 <  ITPBItem = interface(IParameterBlockItem) end;
819 >  ITPBItem = interface(IParameterBlockItemWithTypeName)
820 >    ['{544c1f2b-7c12-4a87-a4a5-face7ea72671}']
821 >    function getParamTypeName: AnsiString;
822 >  end;
823  
824 <  ITPB = specialize IParameterBlock<ITPBItem>;
824 >  ITPB = interface(IParameterBlockWithTypeNames<ITPBItem>)
825 >    ['{7369b0ff-defe-437b-81fe-19b211d42d25}']
826 >  end;
827  
828    {The ITransactionAction interface provides access to a Transaction once it
829     has been initially started. After a Commit or Rollback, a transaction
# Line 648 | Line 837 | type
837    TTransactionCompletion = TARollback.. TACommit;
838  
839    ITransaction = interface
840 +    ['{30928d0e-a9d7-4c61-b7cf-14f4f38abe2a}']
841      function getTPB: ITPB;
842      procedure Start(DefaultCompletion: TTransactionCompletion=taCommit);
843      function GetInTransaction: boolean;
# Line 675 | Line 865 | type
865    }
866  
867    TEventInfo = record
868 <    EventName: string;
868 >    EventName: AnsiString;
869      Count: integer;
870    end;
871  
# Line 686 | Line 876 | type
876    { IEvents }
877  
878    IEvents = interface
879 +    ['{6a0be233-ed08-4524-889c-2e45d0c20e5f}']
880      procedure GetEvents(EventNames: TStrings);
881      procedure SetEvents(EventNames: TStrings); overload;
882 <    procedure SetEvents(EventName: string); overload;
882 >    procedure SetEvents(EventName: AnsiString); overload;
883      procedure Cancel;
884      function ExtractEventCounts: TEventCounts;
885      procedure WaitForEvent;
# Line 696 | Line 887 | type
887      function GetAttachment: IAttachment;
888    end;
889  
890 +  TTZTextOptions = (tzOffset,      {Time Zone Rendered as an offset to GMT}
891 +                    tzGMT,         {No Time Zone. Time part is always rendered in GMT}
892 +                    tzOriginalID); {Time Zone shown as originally entered}
893 +
894 +  {The ITimeZoneServices interface provides access to the time zone database
895 +   used for the attachment. It may be used in support of TIMESTAMP WITH TIME ZONE
896 +   and TIME WITH TIME ZONE data types.}
897 +
898 +  ITimeZoneServices = interface
899 +    ['{163821f5-ebef-42b9-ac60-8ac4b5c09954}']
900 +    {utility functions}
901 +    function TimeZoneID2TimeZoneName(aTimeZoneID: TFBTimeZoneID): AnsiString;
902 +    function TimeZoneName2TimeZoneID(aTimeZone: AnsiString): TFBTimeZoneID;
903 +    function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
904 +    function LocalTimeToGMT(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
905 +    function GMTToLocalTime(aGMTTime: TDateTime; aTimeZone: AnsiString): TDateTime; overload;
906 +    function GMTToLocalTime(aGMTTime: TDateTime; aTimeZoneID: TFBTimeZoneID): TDateTime; overload;
907 +    function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZone: AnsiString): integer; overload;
908 +    function GetEffectiveOffsetMins(aLocalTime: TDateTime; aTimeZoneID: TFBTimeZoneID): integer; overload;
909 +
910 +    {Time Zone DB Information}
911 +    function UsingRemoteTZDB: boolean;
912 +    procedure SetUseLocalTZDB(useLocalTZDB: boolean);
913 +    function GetLocalTimeZoneName: AnsiString;
914 +    function GetLocalTimeZoneID: TFBTimeZoneID;
915 +    procedure GetTimeZoneInfo(aTimeZone: AnsiString; OnDate: TDateTime;
916 +                           var ZoneOffset, DSTOffset, EffectiveOffset: integer);
917 +    {Configurable Options}
918 +    function GetTimeTZDate: TDateTime;
919 +    procedure SetTimeTZDate(aDate: TDateTime);
920 +    function GetTZTextOption: TTZTextOptions;
921 +    procedure SetTZTextOption(aOptionValue: TTZTextOptions);
922 +  end;
923 +
924    {The IDBInformation Interface.
925  
926     An IDBInformation interface is returned by the  IAttachment GetDBInformation
# Line 719 | Line 944 | type
944    TDBOperationCounts = array of TDBOperationCount;
945  
946    IDBInfoItem = interface
947 +    ['{eeb97b51-ec0f-473f-9f75-c1721f055fcb}']
948      function getItemType: byte;
949      function getSize: integer;
950      procedure getRawBytes(var Buffer);
951 <    function getAsString: string;
952 <    function getAsInteger: integer;
953 <    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: string);
951 >    function getAsString: AnsiString;
952 >    function getAsInteger: int64;
953 >    procedure DecodeIDCluster(var ConnectionType: integer; var DBFileName, DBSiteName: AnsiString);
954      function getAsBytes: TByteArray;
955 <    procedure DecodeVersionString(var Version: byte; var VersionString: string);
955 >    function getAsDateTime: TDateTime;
956 >    procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
957      function getOperationCounts: TDBOperationCounts;
958      procedure DecodeUserNames(UserNames: TStrings);
959  
# Line 734 | Line 961 | type
961      function GetCount: integer;
962      function GetItem(index: integer): IDBInfoItem;
963      function Find(ItemType: byte): IDBInfoItem;
964 <    property AsInteger: integer read getAsInteger;
965 <    property AsString: string read GetAsString;
964 >    property AsInteger: int64 read getAsInteger;
965 >    property AsString: AnsiString read GetAsString;
966      property Count: integer read GetCount;
967      property Items[index: integer]: IDBInfoItem read getItem; default;
968    end;
# Line 743 | Line 970 | type
970    { IDBInformation }
971  
972    IDBInformation = interface
973 +    ['{7ac6777f-f0a9-498a-9f5c-4a57a554df81}']
974      function GetCount: integer;
975      function GetItem(index: integer): IDBInfoItem;
976      function Find(ItemType: byte): IDBInfoItem;
# Line 751 | Line 979 | type
979      property Items[index: integer]: IDBInfoItem read getItem; default;
980    end;
981  
982 +  {The Database Information Request Block is used to pass requests for
983 +   database information where at least one item requested has a parameter.
984 +   At present, this is only fb_info_page_contents which has a single
985 +   integer parameter.}
986 +
987 +  IDIRBItem = interface(IParameterBlockItem)
988 +    ['{d34a7511-8435-4a24-81a7-5103d218d234}']
989 +  end;
990 +
991 +  IDIRB = interface(IParameterBlock<IDIRBItem>)
992 +    ['{1010e5ac-0a8f-403b-a302-91625e9d9579}']
993 +  end;
994 +
995 +
996    {The Database Parameter Block (DPB).
997  
998     The DPB provides the parameters used when connecting to a database. It is allocated
# Line 762 | Line 1004 | type
1004     found in the Interbase 6.0 API Guide.
1005     }
1006  
1007 <  IDPBItem = interface(IParameterBlockItem) end;
1007 >  IDPBItem = interface(IParameterBlockItemWithTypeName)
1008 >    ['{123d4ad0-087a-4cd1-a344-1b3d03b30673}']
1009 >  end;
1010  
1011 <  IDPB = specialize IParameterBlock<IDPBItem>;
1011 >   IDPB = interface(IParameterBlockWithTypeNames<IDPBItem>)
1012 >     ['{e676067b-1cf4-4eba-9256-9724f57e0d16}']
1013 >   end;
1014  
1015    {The IAttachment interface provides access to a Database Connection. It may be
1016     used to:
# Line 794 | Line 1040 | type
1040    { IAttachment }
1041  
1042    IAttachment = interface
1043 +    ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
1044 +    function getFirebirdAPI: IFirebirdAPI;
1045      function getDPB: IDPB;
1046      function AllocateBPB: IBPB;
1047 +    function AllocateDIRB: IDIRB;
1048      procedure Connect;
1049      procedure Disconnect(Force: boolean=false);
1050      function IsConnected: boolean;
1051      procedure DropDatabase;
1052      function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
1053      function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion=taCommit): ITransaction; overload;
1054 <    procedure ExecImmediate(transaction: ITransaction; sql: string; SQLDialect: integer); overload;
1055 <    procedure ExecImmediate(TPB: array of byte; sql: string; SQLDialect: integer); overload;
1056 <    procedure ExecImmediate(transaction: ITransaction; sql: string); overload;
1057 <    procedure ExecImmediate(TPB: array of byte; sql: string); overload;
1058 <    function ExecuteSQL(TPB: array of byte; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
1059 <    function ExecuteSQL(transaction: ITransaction; sql: string; SQLDialect: integer; params: array of const): IResults; overload;
1060 <    function ExecuteSQL(TPB: array of byte; sql: string; params: array of const): IResults; overload;
1061 <    function ExecuteSQL(transaction: ITransaction; sql: string; params: array of const): IResults; overload;
1062 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
1063 <    function OpenCursor(transaction: ITransaction; sql: string; aSQLDialect: integer;
1054 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString; SQLDialect: integer); overload;
1055 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString; SQLDialect: integer); overload;
1056 >    procedure ExecImmediate(transaction: ITransaction; sql: AnsiString); overload;
1057 >    procedure ExecImmediate(TPB: array of byte; sql: AnsiString); overload;
1058 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
1059 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload;
1060 >    function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload;
1061 >    function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload;
1062 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
1063 >    function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1064                               params: array of const): IResultSet; overload;
1065 <    function OpenCursor(transaction: ITransaction; sql: string): IResultSet; overload;
1066 <    function OpenCursor(transaction: ITransaction; sql: string;
1065 >    function OpenCursor(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
1066 >    function OpenCursor(transaction: ITransaction; sql: AnsiString;
1067                               params: array of const): IResultSet; overload;
1068 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer): IResultSet; overload;
1069 <    function OpenCursorAtStart(transaction: ITransaction; sql: string; aSQLDialect: integer;
1068 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload;
1069 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1070                               params: array of const): IResultSet; overload;
1071 <    function OpenCursorAtStart(transaction: ITransaction; sql: string): IResultSet; overload;
1072 <    function OpenCursorAtStart(transaction: ITransaction; sql: string;
1071 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString): IResultSet; overload;
1072 >    function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString;
1073                               params: array of const): IResultSet; overload;
1074 <    function OpenCursorAtStart(sql: string): IResultSet; overload;
1075 <    function OpenCursorAtStart(sql: string;
1074 >    function OpenCursorAtStart(sql: AnsiString): IResultSet; overload;
1075 >    function OpenCursorAtStart(sql: AnsiString;
1076                               params: array of const): IResultSet; overload;
1077 <    function Prepare(transaction: ITransaction; sql: string; aSQLDialect: integer): IStatement; overload;
1078 <    function Prepare(transaction: ITransaction; sql: string): IStatement; overload;
1079 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
1080 <                       aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload;
1081 <    function PrepareWithNamedParameters(transaction: ITransaction; sql: string;
1082 <                       GenerateParamNames: boolean=false): IStatement; overload;
1077 >    function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload;
1078 >    function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload;
1079 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1080 >                       aSQLDialect: integer; GenerateParamNames: boolean=false;
1081 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
1082 >    function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
1083 >                       GenerateParamNames: boolean=false;
1084 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
1085  
1086      {Events}
1087      function GetEventHandler(Events: TStrings): IEvents; overload;
1088 <    function GetEventHandler(Event: string): IEvents; overload;
1088 >    function GetEventHandler(Event: AnsiString): IEvents; overload;
1089  
1090      {Blob - may use to open existing Blobs. However, ISQLData.AsBlob is preferred}
1091  
1092 <    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: string; BPB: IBPB=nil): IBlob; overload;
1092 >    function CreateBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BPB: IBPB=nil): IBlob; overload;
1093      function CreateBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BPB: IBPB=nil): IBlob; overload;
1094      function CreateBlob(transaction: ITransaction; SubType: integer; CharSetID: cardinal=0; BPB: IBPB=nil): IBlob; overload;
1095 <    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: string; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;
1095 >    function OpenBlob(transaction: ITransaction; RelationName, ColumnName: AnsiString; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob; overload;
1096 >    function OpenBlob(transaction: ITransaction; BlobMetaData: IBlobMetaData; BlobID: TISC_QUAD; BPB: IBPB=nil): IBlob;  overload;
1097 >    function GetInlineBlobLimit: integer;
1098 >    procedure SetInlineBlobLimit(limit: integer);
1099  
1100      {Array - may use to open existing arrays. However, ISQLData.AsArray is preferred}
1101  
1102 <    function OpenArray(transaction: ITransaction; RelationName, ColumnName: string; ArrayID: TISC_QUAD): IArray;
1103 <    function CreateArray(transaction: ITransaction; RelationName, ColumnName: string): IArray; overload;
1102 >    function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload;
1103 >    function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload;
1104 >    function CreateArray(transaction: ITransaction; RelationName, ColumnName: AnsiString): IArray; overload;
1105      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload;
1106 <    function CreateArrayMetaData(SQLType: cardinal; tableName: string; columnName: string;
1106 >    function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; columnName: AnsiString;
1107                    Scale: integer; size: cardinal; charSetID: cardinal; dimensions: cardinal;
1108                    bounds: TArrayBounds): IArrayMetaData;
1109  
1110      {Database Information}
1111      function GetSQLDialect: integer;
1112 <    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: string): IBlobMetaData;
1113 <    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: string): IArrayMetaData;
1112 >    function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData;
1113 >    function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData;
1114      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
1115      function GetDBInformation(Request: byte): IDBInformation; overload;
1116 +    function GetDBInformation(Requests: IDIRB): IDBInformation; overload;
1117 +    function GetConnectString: AnsiString;
1118 +    function GetRemoteProtocol: AnsiString;
1119 +    function GetAuthenticationMethod: AnsiString;
1120 +    function GetSecurityDatabase: AnsiString;
1121 +    function GetODSMajorVersion: integer;
1122 +    function GetODSMinorVersion: integer;
1123 +    procedure getFBVersion(version: TStrings);
1124      function HasActivity: boolean;
1125 <  end;
1125 >    function HasDecFloatSupport: boolean;
1126 >    function HasBatchMode: boolean;
1127 >
1128 >    {Character Sets}
1129 >    function HasDefaultCharSet: boolean;
1130 >    function GetDefaultCharSetID: integer;
1131 >    function GetCharsetName(CharSetID: integer): AnsiString;
1132 >    function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean;
1133 >    function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean;
1134 >    function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean;
1135 >    function CharSetWidth(CharSetID: integer; var Width: integer): boolean;
1136 >    procedure RegisterCharSet(CharSetName: AnsiString; CodePage: TSystemCodePage;
1137 >      AllowReverseLookup:boolean; out CharSetID: integer);
1138 >
1139 >    {Time Zone Database}
1140 >    function GetTimeZoneServices: ITimeZoneServices;
1141 >    function HasTimeZoneSupport: boolean;
1142 > end;
1143  
1144 <  TProtocol = (TCP, SPX, NamedPipe, Local);
1144 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
1145 >  TProtocol = TCP..xnet;
1146  
1147    {Service Parameter Block (SPB).
1148  
# Line 875 | Line 1156 | type
1156  
1157    }
1158  
1159 <  ISPBItem = interface(IParameterBlockItem) end;
1159 >  ISPBItem = interface(IParameterBlockItemWithTypeName)
1160 >    ['{5d08ae2b-4519-41bd-8b40-97cd451c3f6a}']
1161 >  end;
1162  
1163 <  ISPB = specialize IParameterBlock<ISPBItem>;
1163 >  ISPB = interface(IParameterBlockWithTypeNames<ISPBItem>)
1164 >    ['{2c5836fd-41ed-4426-9b7d-5af580ec2659}']
1165 >  end;
1166  
1167    {Service Query Parameter Block (SQPB).
1168  
# Line 886 | Line 1171 | type
1171    }
1172  
1173    ISQPBItem = interface(IParameterBlockItem)
1174 +    ['{b07841a6-33b3-47f0-b5a2-028cbc86dc97}']
1175      function CopyFrom(source: TStream; count: integer): integer;
1176    end;
1177  
1178 <  ISQPB = specialize IParameterBlock<ISQPBItem>;
1178 >  ISQPB = interface(IParameterBlock<ISQPBItem>)
1179 >    ['{8553e66b-ee62-498b-8431-dff030211447}']
1180 >  end;
1181  
1182    {Service Request Block (SRB).
1183  
# Line 903 | Line 1191 | type
1191  
1192    }
1193  
1194 <  ISRBItem = interface(IParameterBlockItem) end;
1194 >  ISRBItem = interface(IParameterBlockItem)
1195 >    ['{47ec790e-f265-4b30-9dcd-261e51677245}']
1196 >   end;
1197  
1198 <  ISRB = specialize IParameterBlock<ISRBItem>;
1198 >  ISRB = interface(IParameterBlock<ISRBItem>)
1199 >    ['{9f2e204f-3c33-4e44-90f9-9135e95dafb9}']
1200 >  end;
1201  
1202    {The Service Query Results Interface.
1203  
# Line 923 | Line 1215 | type
1215    }
1216  
1217    IServiceQueryResultSubItem = interface
1218 +    ['{8a4c381e-9923-4cc9-a96b-553729248640}']
1219      function getItemType: byte;
1220      function getSize: integer;
1221      procedure getRawBytes(var Buffer);
1222 <    function getAsString: string;
1223 <    function getAsInteger: integer;
1222 >    function getAsString: AnsiString;
1223 >    function getAsInteger: int64;
1224      function getAsByte: byte;
1225      function CopyTo(stream: TStream; count: integer): integer;
1226 <    property AsString: string read getAsString;
1227 <    property AsInteger: integer read getAsInteger;
1226 >    property AsString: AnsiString read getAsString;
1227 >    property AsInteger: int64 read getAsInteger;
1228      property AsByte: byte read getAsByte;
1229    end;
1230  
1231    IServiceQueryResultItem = interface(IServiceQueryResultSubItem)
1232 +    ['{b2806886-206c-4024-8df9-5fe0a7630a5e}']
1233      function getCount: integer;
1234      function getItem(index: integer): IServiceQueryResultSubItem;
1235      function find(ItemType: byte): IServiceQueryResultSubItem;
# Line 944 | Line 1238 | type
1238    end;
1239  
1240    IServiceQueryResults = interface
1241 +    ['{8fbbef7d-fe03-4409-828a-a787d34ef531}']
1242      function getCount: integer;
1243      function getItem(index: integer): IServiceQueryResultItem;
1244      function find(ItemType: byte): IServiceQueryResultItem;
# Line 952 | Line 1247 | type
1247      property Count: integer read getCount;
1248    end;
1249  
1250 +  IFirebirdLibrary = interface;
1251 +
1252    {The IServiceManager interface provides access to a service manager. It can
1253     used to Detach and re-attach to Service Manager, to start services and to
1254     query the service manager.
# Line 962 | Line 1259 | type
1259    { IServiceManager }
1260  
1261    IServiceManager = interface
1262 +    ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1263 +    function getFirebirdAPI: IFirebirdAPI;
1264      function getSPB: ISPB;
1265 <    function getServerName: string;
1265 >    function getServerName: AnsiString;
1266 >    function getProtocol: TProtocol;
1267 >    function getPortNo: AnsiString;
1268      procedure Attach;
1269      procedure Detach(Force: boolean=false);
1270      function IsAttached: boolean;
1271      function AllocateSRB: ISRB;
1272      function AllocateSQPB: ISQPB;
1273 <    procedure Start(Request: ISRB);
1274 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1275 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1273 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1274 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1275 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1276 >  end;
1277 >
1278 >  {Tbe Firebird Library API used to get information about the Firebird library}
1279 >
1280 >
1281 >  IFirebirdLibrary = interface
1282 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1283 >    function GetHandle: TLibHandle;
1284 >    function GetLibraryName: string;
1285 >    function GetLibraryFilePath: string;
1286 >    function GetFirebirdAPI: IFirebirdAPI;
1287    end;
1288  
1289    {The Firebird API.
# Line 982 | Line 1294 | type
1294     The interface is returned by the FirebirdAPI function.
1295    }
1296  
1297 +  { IFirebirdAPI }
1298 +
1299    IFirebirdAPI = interface
1300 +    ['{edeee691-c8d3-4dcf-a780-cd7e432821d5}']
1301      {Database connections}
1302      function AllocateDPB: IDPB;
1303 <    function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1304 <    function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1305 <    function CreateDatabase(sql: string; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1303 >    function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
1304 >    function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1305 >    function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
1306  
1307      {Start Transaction against multiple databases}
1308      function AllocateTPB: ITPB;
# Line 999 | Line 1314 | type
1314      {Service Manager}
1315      function HasServiceAPI: boolean;
1316      function AllocateSPB: ISPB;
1317 <    function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager;
1317 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1318 >    function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload;
1319  
1320      {Information}
1321      function GetStatus: IStatus;
1006    function GetLibraryName: string;
1322      function HasRollbackRetaining: boolean;
1323      function IsEmbeddedServer: boolean;
1324 <    function GetImplementationVersion: string;
1324 >    function GetImplementationVersion: AnsiString;
1325 >    function GetClientMajor: integer;
1326 >    function GetClientMinor: integer;
1327 >    function HasDecFloatSupport: boolean;
1328 >    function HasLocalTZDB: boolean;
1329 >    function HasTimeZoneSupport: boolean;
1330 >    function HasExtendedTZSupport: boolean;
1331  
1332      {Firebird 3 API}
1333      function HasMasterIntf: boolean;
1334 <    function GetIMaster: TObject;
1335 <
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;
1334 >    function GetIMaster: TObject;  deprecated 'Use FirebirdAPI.QueryInterface and FBClientLib.pas IFBIMasterProvider instead';
1335 >    function GetFBLibrary: IFirebirdLibrary;
1336   end;
1337  
1338   type
# Line 1034 | Line 1349 | type
1349     private
1350       FSQLCode: Long;
1351     public
1352 <     constructor Create(ASQLCode: Long; Msg: string);
1352 >     constructor Create(ASQLCode: Long; Msg: AnsiString);
1353       property SQLCode: Long read FSQLCode;
1354     end;
1355  
# Line 1045 | Line 1360 | type
1360       FIBErrorCode: Long;
1361     public
1362       constructor Create(Status: IStatus); overload;
1363 <     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: string); overload;
1363 >     constructor Create(ASQLCode: Long; AIBErrorCode: Long; Msg: AnsiString); overload;
1364       property IBErrorCode: Long read FIBErrorCode;
1365     end;
1366  
1367     {IB Client Exceptions}
1368     EIBClientError = class(EIBError);
1369  
1370 < {IBError is used internally and by IBX to throw an EIBClientError}
1371 <
1057 < procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1370 >   {Used to explicitly report a Batch Buffer overflow}
1371 >   EIBBatchBufferOverflow = class(EIBError);
1372  
1373   {The Firebird API function is used to access the IFirebirdAPI interface.
1374  
# Line 1065 | Line 1379 | procedure IBError(ErrMess: TIBClientErro
1379   function FirebirdAPI: IFirebirdAPI;
1380  
1381   {IBX support functions. Probably best ignored i.e. always used the FirebirdAPI
1382 < functino to load the library and check if it's loaded.}
1382 > function to load the library and check if it's loaded.}
1383  
1384   function TryIBLoad: Boolean;
1385   procedure CheckIBLoaded;
1386  
1387 + {If you want to explicitly load the Firebird library from a
1388 + non-default location then use this function and its GetFirebirdAPI function
1389 + to get the API.}
1390 +
1391 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1392 +
1393 +
1394   implementation
1395  
1396   uses FBClientAPI
1397    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1398    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1399  
1400 < var FFirebirdAPI: IFirebirdAPI;
1400 > var FDefaultFBLibrary: IFirebirdLibrary;
1401 >
1402 > type
1403 >
1404 >  { TFBLibrary }
1405 >
1406 >  TFBLibraryImpl = class(TFBLibrary)
1407 >  protected
1408 >    function GetFirebird3API: IFirebirdAPI; override;
1409 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1410 >  end;
1411 >
1412 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1413 > begin
1414 > {$IFDEF USEFIREBIRD3API}
1415 > Result := TFB30ClientAPI.Create(self);
1416 > {$ELSE}
1417 > Result := nil;
1418 > {$ENDIF}
1419 > end;
1420 >
1421 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1422 > begin
1423 >  {$IFDEF USELEGACYFIREBIRDAPI}
1424 >  Result := TFB25ClientAPI.Create(self);
1425 >  {$ELSE}
1426 >  Result := nil;
1427 >  {$ENDIF}
1428 > end;
1429  
1430   function FirebirdAPI: IFirebirdAPI;
1431   begin
1432 <  if FFirebirdAPI = nil then
1432 >  if FDefaultFBLibrary = nil then
1433      CheckIBLoaded;
1434 <  Result := FFirebirdAPI;
1434 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1435   end;
1436  
1437   function TryIBLoad: Boolean;
1438 + var fblib: IFirebirdLibrary;
1439   begin
1440 < Result := FFirebirdAPI <> nil;
1440 > Result := FDefaultFBLibrary <> nil;
1441   try
1092  {$IFDEF USEFIREBIRD3API}
1093  if not Result then
1094  begin
1095    FFirebirdAPI := TFB30ClientAPI.Create;
1096    Result := FFirebirdAPI.HasMasterIntf;
1097  end;
1098  {$ENDIF}
1099  {$IFDEF USELEGACYFIREBIRDAPI}
1442    if not Result then
1443    begin
1444 <    FFirebirdAPI := nil;
1445 <    FFirebirdAPI := TFB25ClientAPI.Create;
1446 <    Result := true;
1447 <  end;
1106 <  {$ENDIF}
1107 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1108 <  begin
1109 <    Result := false;
1110 <    FFirebirdAPI := nil;
1444 >    fblib := TFBLibraryImpl.Create;
1445 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1446 >      FDefaultFBLibrary := fblib;
1447 >    Result := FDefaultFBLibrary <> nil;
1448    end;
1449   except
1450     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1121 | Line 1458 | begin
1458      IBError(ibxeInterBaseMissing, [nil]);
1459   end;
1460  
1461 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1462 + var fblib: IFirebirdLibrary;
1463 + begin
1464 +  if trim(aLibPathName) = '' then
1465 +  begin
1466 +    CheckIBLoaded;
1467 +    Result := FDefaultFBLibrary;
1468 +  end
1469 +  else
1470 +  begin
1471 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1472 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1473 +      IBError(ibxeInterBaseMissing, [nil]);
1474 +    Result := fblib;
1475 +  end;
1476 + end;
1477 +
1478   { EIBError }
1479  
1480 < constructor EIBError.Create(ASQLCode: Long; Msg: string);
1480 > constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
1481   begin
1482    inherited Create(Msg);
1483    FSQLCode := ASQLCode;
# Line 1138 | Line 1492 | begin
1492   end;
1493  
1494   constructor EIBInterBaseError.Create(ASQLCode: Long; AIBErrorCode: Long;
1495 <  Msg: string);
1495 >  Msg: AnsiString);
1496   begin
1497    inherited Create(ASQLCode,Msg);
1498    FIBErrorCode := AIBErrorCode;
1499   end;
1500  
1147 procedure IBError(ErrMess: TIBClientError; const Args: array of const);
1148 begin
1149  raise EIBClientError.Create(Ord(ErrMess),
1150                              Format(GetErrorMessage(ErrMess), Args));
1151 end;
1501  
1502   initialization
1503 <  FFirebirdAPI := nil;
1503 >  FDefaultFBLibrary := nil;
1504  
1505 + finalization
1506 +  FDefaultFBLibrary := nil;
1507  
1508   end.
1509  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines