ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/IB.pas
(Generate patch)

Comparing ibx/trunk/fbintf/IB.pas (file contents):
Revision 231 by tony, Mon Apr 16 08:32:21 2018 UTC vs.
Revision 266 by tony, Wed Dec 26 18:34:32 2018 UTC

# Line 122 | Line 122 | unit IB;
122   interface
123  
124   uses
125 <  Classes, SysUtils, DB, FBMessages, IBExternals;
125 >  Classes,
126 >  {$IFDEF WINDOWS}Windows, {$ENDIF}
127 >  {$IFDEF FPC} Dynlibs, {$ENDIF}
128 >  SysUtils, DB, FBMessages, IBExternals;
129  
130   const
131    {Interface version information}
132    FBIntf_Major = 1;
133    FBIntf_Minor = 1;
134 <  FBIntf_Release = 2;
135 <  FBIntf_Version = '1.1.2';
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}
# Line 173 | Line 176 | type
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
# Line 200 | Line 211 | type
211    TFBStatusCode = cardinal;
212    TByteArray = array of byte;
213  
214 +  IFirebirdAPI = interface;
215    IAttachment = interface;
216    ITransaction = interface;
217  
# Line 646 | Line 658 | type
658      function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, DeleteCount: integer): boolean;
659      function GetSQLStatementType: TIBSQLStatementTypes;
660      function GetSQLText: AnsiString;
661 +    function GetProcessedSQLText: AnsiString;
662      function GetSQLDialect: integer;
663      function IsPrepared: boolean;
664      procedure Prepare(aTransaction: ITransaction=nil);
# Line 862 | Line 875 | type
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;
# Line 934 | Line 948 | type
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}
# Line 1054 | 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 1065 | Line 1082 | type
1082  
1083    IServiceManager = interface
1084      ['{905b587d-1e1f-4e40-a3f8-a3519f852e48}']
1085 +    function getFirebirdAPI: IFirebirdAPI;
1086      function getSPB: ISPB;
1087      function getServerName: AnsiString;
1088      function getProtocol: TProtocol;
# Line 1079 | Line 1097 | type
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.
1112  
1113     This is the base interface and is used to create/open a database connection, to
# Line 1110 | Line 1139 | type
1139  
1140      {Information}
1141      function GetStatus: IStatus;
1113    function GetLibraryName: string;
1142      function HasRollbackRetaining: boolean;
1143      function IsEmbeddedServer: boolean;
1144      function GetImplementationVersion: AnsiString;
# Line 1118 | Line 1146 | type
1146      {Firebird 3 API}
1147      function HasMasterIntf: boolean;
1148      function GetIMaster: TObject;
1149 +    function GetFBLibrary: IFirebirdLibrary;
1150   end;
1151  
1152   type
# Line 1170 | 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
1192  {$IFDEF USEFIREBIRD3API}
1193  if not Result then
1194  begin
1195    FFirebirdAPI := TFB30ClientAPI.Create;
1196    Result := FFirebirdAPI.HasMasterIntf;
1197  end;
1198  {$ENDIF}
1199  {$IFDEF USELEGACYFIREBIRDAPI}
1256    if not Result then
1257    begin
1258 <    FFirebirdAPI := nil;
1259 <    FFirebirdAPI := TFB25ClientAPI.Create;
1260 <    Result := true;
1261 <  end;
1206 <  {$ENDIF}
1207 <  if Result and not (FFirebirdAPI as TFBClientAPI).IsLibraryLoaded then
1208 <  begin
1209 <    Result := false;
1210 <    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 1221 | 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: AnsiString);
# Line 1251 | Line 1319 | begin
1319   end;
1320  
1321   initialization
1322 <  FFirebirdAPI := nil;
1322 >  FDefaultFBLibrary := nil;
1323  
1324   finalization
1325 <  FFirebirdAPI := nil;
1325 >  FDefaultFBLibrary := nil;
1326  
1327   end.
1328  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines