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 154 by tony, Tue Feb 27 16:51:42 2018 UTC vs.
Revision 287 by tony, Thu Apr 11 08:51:23 2019 UTC

# Line 73 | Line 73 | unit IB;
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 122 | Line 126 | unit IB;
126   interface
127  
128   uses
129 <  Classes, SysUtils, DB, FBMessages, IBExternals;
129 >  Classes,
130 >  {$IFDEF WINDOWS}Windows, {$ENDIF}
131 >  {$IFDEF FPC} Dynlibs, {$ENDIF}
132 >  SysUtils, DB, FBMessages, IBExternals;
133  
134   const
135    {Interface version information}
136    FBIntf_Major = 1;
137    FBIntf_Minor = 1;
138 <  FBIntf_Release = 1;
139 <  FBIntf_Version = '1.1.1';
138 >  FBIntf_Release = 5;
139 >  FBIntf_Version = '1.1.5';
140  
141   {These include files are converted from the 'C' originals in the Firebird API
142   and define the various constants used by the API}
# Line 173 | Line 180 | type
180     PISC_QUAD            = ^TISC_QUAD;
181  
182   {$IFNDEF FPC}
183 + {Delphi missing definitions}
184 + type
185 +  TLibHandle = THandle;
186 +
187 + const
188 +  NilHandle = 0;
189 +  DirectorySeparator = '\';
190 +
191   {Delphi only seems to define CP_UTF8 and CP_UTF16}
192   const
193    CP_ACP     = 0;     // default to ANSI code page
# Line 200 | Line 215 | type
215    TFBStatusCode = cardinal;
216    TByteArray = array of byte;
217  
218 +  IFirebirdAPI = interface;
219    IAttachment = interface;
220    ITransaction = interface;
221  
# Line 395 | Line 411 | type
411      the output of an SQL Statement.
412    }
413  
414 +  TIBDateTimeFormats = (dfTimestamp, {SQL TIMESTAMP}
415 +                        dfDateTime,   {SQL DATETIME}
416 +                        dfTime);      {SQL TIME}
417 +
418    { IColumnMetaData }
419  
420    IColumnMetaData = interface
# Line 415 | Line 435 | type
435      function GetSize: cardinal;
436      function GetArrayMetaData: IArrayMetaData; {Valid only for Array SQL Type}
437      function GetBlobMetaData: IBlobMetaData; {Valid only for Blob SQL Type}
438 +    function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer;
439      property Name: AnsiString read GetName;
440      property Size: cardinal read GetSize;
441      property SQLType: cardinal read GetSQLType;
# Line 622 | Line 643 | type
643      function getSQLParam(index: integer): ISQLParam;
644      function ByName(Idx: AnsiString): ISQLParam ;
645      function GetModified: Boolean;
646 +    function GetHasCaseSensitiveParams: Boolean;
647      property Modified: Boolean read GetModified;
648      property Params[index: integer]: ISQLParam read getSQLParam; default;
649      property Count: integer read getCount;
# Line 632 | Line 654 | type
654                  psRealTime, psUserTime, psBuffers,
655                  psReads, psWrites, psFetches,psDeltaMemory);
656  
657 <  TPerfCounters = array[TPerfStats] of comp;
657 >  TPerfCounters = array[TPerfStats] of Int64;
658  
659    {The IStatement interface provides access to an SQL Statement once it has been
660     initially prepared. The interface is returned from the IAttachment interface.
# Line 646 | Line 668 | type
668      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
669      function GetSQLStatementType: TIBSQLStatementTypes;
670      function GetSQLText: AnsiString;
671 +    function GetProcessedSQLText: AnsiString;
672      function GetSQLDialect: integer;
673      function IsPrepared: boolean;
674      procedure Prepare(aTransaction: ITransaction=nil);
# Line 862 | Line 885 | type
885  
886    IAttachment = interface
887      ['{466e9b67-9def-4807-b3e7-e08a35e7185c}']
888 +    function getFirebirdAPI: IFirebirdAPI;
889      function getDPB: IDPB;
890      function AllocateBPB: IBPB;
891      function AllocateDIRB: IDIRB;
# Line 897 | Line 921 | type
921      function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload;
922      function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload;
923      function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
924 <                       aSQLDialect: integer; GenerateParamNames: boolean=false): IStatement; overload;
924 >                       aSQLDialect: integer; GenerateParamNames: boolean=false;
925 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
926      function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString;
927 <                       GenerateParamNames: boolean=false): IStatement; overload;
927 >                       GenerateParamNames: boolean=false;
928 >                       CaseSensitiveParams: boolean = false): IStatement; overload;
929  
930      {Events}
931      function GetEventHandler(Events: TStrings): IEvents; overload;
# Line 931 | Line 957 | type
957      function GetConnectString: AnsiString;
958      function GetRemoteProtocol: AnsiString;
959      function GetAuthenticationMethod: AnsiString;
960 +    function GetSecurityDatabase: AnsiString;
961      function GetODSMajorVersion: integer;
962      function GetODSMinorVersion: integer;
963 +    procedure getFBVersion(version: TStrings);
964      function HasActivity: boolean;
965  
966      {Character Sets}
# Line 947 | Line 975 | type
975        AllowReverseLookup:boolean; out CharSetID: integer);
976    end;
977  
978 <  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, wnet, xnet, unknownProtocol);
978 >  TProtocolAll = (TCP, SPX, NamedPipe, Local, inet, inet4, inet6, wnet, xnet, unknownProtocol);
979    TProtocol = TCP..xnet;
980  
981    {Service Parameter Block (SPB).
# Line 1053 | Line 1081 | type
1081      property Count: integer read getCount;
1082    end;
1083  
1084 +  IFirebirdLibrary = interface;
1085 +
1086    {The IServiceManager interface provides access to a service manager. It can
1087     used to Detach and re-attach to Service Manager, to start services and to
1088     query the service manager.
# Line 1064 | Line 1094 | type
1094  
1095    IServiceManager = interface
1096      ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1097 +    function getFirebirdAPI: IFirebirdAPI;
1098      function getSPB: ISPB;
1099      function getServerName: AnsiString;
1100 +    function getProtocol: TProtocol;
1101 +    function getPortNo: AnsiString;
1102      procedure Attach;
1103      procedure Detach(Force: boolean=false);
1104      function IsAttached: boolean;
1105      function AllocateSRB: ISRB;
1106      function AllocateSQPB: ISQPB;
1107 <    procedure Start(Request: ISRB);
1108 <    function Query(SQPB: ISQPB; Request: ISRB) :IServiceQueryResults; overload;
1109 <    function Query(Request: ISRB) :IServiceQueryResults; overload;
1107 >    function Start(Request: ISRB; RaiseExceptionOnError: boolean=true): boolean;
1108 >    function Query(SQPB: ISQPB; Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1109 >    function Query(Request: ISRB; RaiseExceptionOnError: boolean=true) :IServiceQueryResults; overload;
1110 >  end;
1111 >
1112 >  {Tbe Firebird Library API used to get information about the Firebird library}
1113 >
1114 >
1115 >  IFirebirdLibrary = interface
1116 >    ['{3c04e0a1-12e0-428a-b2e1-bc6fcd97b79b}']
1117 >    function GetHandle: TLibHandle;
1118 >    function GetLibraryName: string;
1119 >    function GetLibraryFilePath: string;
1120 >    function GetFirebirdAPI: IFirebirdAPI;
1121    end;
1122  
1123    {The Firebird API.
# Line 1107 | Line 1151 | type
1151  
1152      {Information}
1153      function GetStatus: IStatus;
1110    function GetLibraryName: string;
1154      function HasRollbackRetaining: boolean;
1155      function IsEmbeddedServer: boolean;
1156      function GetImplementationVersion: AnsiString;
# Line 1115 | Line 1158 | type
1158      {Firebird 3 API}
1159      function HasMasterIntf: boolean;
1160      function GetIMaster: TObject;
1161 +    function GetFBLibrary: IFirebirdLibrary;
1162   end;
1163  
1164   type
# Line 1167 | Line 1211 | function FirebirdAPI: IFirebirdAPI;
1211   function TryIBLoad: Boolean;
1212   procedure CheckIBLoaded;
1213  
1214 + {If you want to explicitly load the Firebird library from a
1215 + non-default location then use this function and its GetFirebirdAPI function
1216 + to get the API.}
1217 +
1218 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1219 +
1220   implementation
1221  
1222   uses FBClientAPI
1223    {$IFDEF USELEGACYFIREBIRDAPI}, FB25ClientAPI {$ENDIF}
1224    {$IFDEF USEFIREBIRD3API}, FB30ClientAPI {$ENDIF};
1225  
1226 < var FFirebirdAPI: IFirebirdAPI;
1226 > var FDefaultFBLibrary: IFirebirdLibrary;
1227 >
1228 > type
1229 >
1230 >  { TFBLibrary }
1231 >
1232 >  TFBLibraryImpl = class(TFBLibrary)
1233 >  protected
1234 >    function GetFirebird3API: IFirebirdAPI; override;
1235 >    function GetLegacyFirebirdAPI: IFirebirdAPI; override;
1236 >  end;
1237 >
1238 > function TFBLibraryImpl.GetFirebird3API: IFirebirdAPI;
1239 > begin
1240 > {$IFDEF USEFIREBIRD3API}
1241 > Result := TFB30ClientAPI.Create(self);
1242 > {$ELSE}
1243 > Result := nil;
1244 > {$ENDIF}
1245 > end;
1246 >
1247 > function TFBLibraryImpl.GetLegacyFirebirdAPI: IFirebirdAPI;
1248 > begin
1249 >  {$IFDEF USELEGACYFIREBIRDAPI}
1250 >  Result := TFB25ClientAPI.Create(self);
1251 >  {$ELSE}
1252 >  Result := nil;
1253 >  {$ENDIF}
1254 > end;
1255  
1256   function FirebirdAPI: IFirebirdAPI;
1257   begin
1258 <  if FFirebirdAPI = nil then
1258 >  if FDefaultFBLibrary = nil then
1259      CheckIBLoaded;
1260 <  Result := FFirebirdAPI;
1260 >  Result := FDefaultFBLibrary.GetFirebirdAPI;
1261   end;
1262  
1263   function TryIBLoad: Boolean;
1264 + var fblib: IFirebirdLibrary;
1265   begin
1266 < Result := FFirebirdAPI <> nil;
1266 > Result := FDefaultFBLibrary <> nil;
1267   try
1189  {$IFDEF USEFIREBIRD3API}
1190  if not Result then
1191  begin
1192    FFirebirdAPI := TFB30ClientAPI.Create;
1193    Result := FFirebirdAPI.HasMasterIntf;
1194  end;
1195  {$ENDIF}
1196  {$IFDEF USELEGACYFIREBIRDAPI}
1268    if not Result then
1269    begin
1270 <    FFirebirdAPI := nil;
1271 <    FFirebirdAPI := TFB25ClientAPI.Create;
1272 <    Result := true;
1273 <  end;
1203 <  {$ENDIF}
1204 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1205 <  begin
1206 <    Result := false;
1207 <    FFirebirdAPI := nil;
1270 >    fblib := TFBLibraryImpl.Create;
1271 >    if (fblib <> nil) and (fblib.GetFirebirdAPI <> nil) then
1272 >      FDefaultFBLibrary := fblib;
1273 >    Result := FDefaultFBLibrary <> nil;
1274    end;
1275   except
1276     SysUtils.showexception(ExceptObject,ExceptAddr);
# Line 1218 | Line 1284 | begin
1284      IBError(ibxeInterBaseMissing, [nil]);
1285   end;
1286  
1287 + function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
1288 + var fblib: IFirebirdLibrary;
1289 + begin
1290 +  if trim(aLibPathName) = '' then
1291 +  begin
1292 +    CheckIBLoaded;
1293 +    Result := FDefaultFBLibrary;
1294 +  end
1295 +  else
1296 +  begin
1297 +    fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
1298 +    if (fblib = nil) or (fblib.GetFirebirdAPI = nil) then
1299 +      IBError(ibxeInterBaseMissing, [nil]);
1300 +    Result := fblib;
1301 +  end;
1302 + end;
1303 +
1304   { EIBError }
1305  
1306   constructor EIBError.Create(ASQLCode: Long; Msg: AnsiString);
# Line 1248 | Line 1331 | begin
1331   end;
1332  
1333   initialization
1334 <  FFirebirdAPI := nil;
1334 >  FDefaultFBLibrary := nil;
1335  
1336 + finalization
1337 +  FDefaultFBLibrary := nil;
1338  
1339   end.
1340  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines