Browse Source

* Patch from Ludo brands to add IsLibraryLoaded sqlite/src/sqlite3.inc

git-svn-id: trunk@22852 -
michael 12 years ago
parent
commit
520d51cf7c

+ 5 - 5
packages/mysql/src/mysql.inc

@@ -1602,6 +1602,7 @@ Function InitialiseMysql(argc:cint = -1; argv:PPchar = nil; groups:PPchar = nil)
 Procedure ReleaseMysql;
 
 var MysqlLibraryHandle : TLibHandle;
+  MysqlLoadedLibrary : String;
 {$ENDIF}
 
 implementation
@@ -1615,7 +1616,6 @@ ResourceString
 
 var 
   RefCount : integer;
-  LoadedLibrary : String;
 
 Function TryInitialiseMysql(Const LibraryName: String; argc: cint; argv: PPchar; groups: PPchar) : Integer;
 
@@ -1627,7 +1627,7 @@ begin
     if (MysqlLibraryHandle=nilhandle) then
       Exit;
     Inc(RefCount);
-    LoadedLibrary:=LibraryName;
+    MysqlLoadedLibrary:=LibraryName;
 // Only the procedure that are given in the c-library documentation are loaded, to
 // avoid problems with 'incomplete' libraries
     pointer(my_init) := GetProcedureAddress(MysqlLibraryHandle,'my_init');
@@ -1768,11 +1768,11 @@ begin
   Result := TryInitialiseMysql(LibraryName,argc,argv,groups);
   If Result = 0 then
     Raise EInOutError.CreateFmt(SErrLoadFailed,[LibraryName])
-  else If (LibraryName<>LoadedLibrary) then
+  else If (LibraryName<>MysqlLoadedLibrary) then
     begin
     Dec(RefCount);
     Result := RefCount;
-    Raise EInOUtError.CreateFmt(SErrAlreadyLoaded,[LoadedLibrary]);
+    Raise EInOUtError.CreateFmt(SErrAlreadyLoaded,[MysqlLoadedLibrary]);
     end;
 end;
 
@@ -1788,7 +1788,7 @@ begin
       begin
       Dec(RefCount);
       MysqlLibraryHandle := NilHandle;
-      LoadedLibrary:='';
+      MysqlLoadedLibrary:='';
       end
     end
 end;

+ 2 - 0
packages/postgres/src/postgres3.pp

@@ -91,6 +91,8 @@ const
 
   function PQprotocolVersion(conn:PPGconn):longint;cdecl;external External_library name 'PQprotocolVersion';
 
+  function PQserverVersion(conn:PPGconn):longint;cdecl;external External_library name 'PQserverVersion';
+
   function PQerrorMessage(conn:PPGconn):Pchar;cdecl;external External_library name 'PQerrorMessage';
 
   function PQsocket(conn:PPGconn):longint;cdecl;external External_library name 'PQsocket';

+ 6 - 4
packages/postgres/src/postgres3dyn.pp

@@ -82,6 +82,7 @@ var
   PQtransactionStatus : function (conn:PPGconn):PGTransactionStatusType;cdecl;
   PQparameterStatus : function (conn:PPGconn; paramName:Pchar):Pchar;cdecl;
   PQprotocolVersion : function (conn:PPGconn):longint;cdecl;
+  PQserverVersion : function (conn:PPGconn):longint;cdecl;
   PQerrorMessage : function (conn:PPGconn):Pchar;cdecl;
   PQsocket : function (conn:PPGconn):longint;cdecl;
   PQbackendPID : function (conn:PPGconn):longint;cdecl;
@@ -224,6 +225,7 @@ Procedure ReleasePostgres3;
 function PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME : pchar) : ppgconn;
 
 var Postgres3LibraryHandle : TLibHandle;
+  Postgres3LoadedLibrary : String;
 
 implementation
 
@@ -233,7 +235,6 @@ resourcestring
 
 var
   RefCount : integer;
-  LoadedLibrary : String;
 
 procedure InitialisePostgres3;
 
@@ -260,7 +261,7 @@ begin
       Raise EInOutError.CreateFmt(SErrLoadFailed,[libpath]);
       end;
 
-    LoadedLibrary:=libpath;
+    Postgres3LoadedLibrary:=libpath;
     pointer(PQconnectStart) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectStart');
     pointer(PQconnectPoll) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectPoll');
     pointer(PQconnectdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectdb');
@@ -283,6 +284,7 @@ begin
     pointer(PQtransactionStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQtransactionStatus');
     pointer(PQparameterStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQparameterStatus');
     pointer(PQprotocolVersion) := GetProcedureAddress(Postgres3LibraryHandle,'PQprotocolVersion');
+    pointer(PQserverVersion) := GetProcedureAddress(Postgres3LibraryHandle,'PQserverVersion');
     pointer(PQerrorMessage) := GetProcedureAddress(Postgres3LibraryHandle,'PQerrorMessage');
     pointer(PQsocket) := GetProcedureAddress(Postgres3LibraryHandle,'PQsocket');
     pointer(PQbackendPID) := GetProcedureAddress(Postgres3LibraryHandle,'PQbackendPID');
@@ -367,10 +369,10 @@ begin
     InitialiseDllist(libpath);
     end
   else
-    if (libpath<>pqlib) and (LoadedLibrary<>libpath) then
+    if (libpath<>pqlib) and (Postgres3LoadedLibrary<>libpath) then
       begin
       Dec(RefCount);
-      Raise EInOUtError.CreateFmt(SErrAlreadyLoaded,[LoadedLibrary]);
+      Raise EInOUtError.CreateFmt(SErrAlreadyLoaded,[Postgres3LoadedLibrary]);
       end;
 end;