Ver código fonte

* Raise exception when PostgreSQL library is already loaded from a different file
* Checked typo in error-message and converted it to a resourcestring

git-svn-id: trunk@17820 -

joost 14 anos atrás
pai
commit
18e17afc47
1 arquivos alterados com 16 adições e 3 exclusões
  1. 16 3
      packages/postgres/src/postgres3dyn.pp

+ 16 - 3
packages/postgres/src/postgres3dyn.pp

@@ -218,7 +218,13 @@ var Postgres3LibraryHandle : TLibHandle;
 
 implementation
 
-var RefCount : integer;
+resourcestring
+  SErrLoadFailed     = 'Can not load PostgreSQL client library "%s". Check your installation.';
+  SErrAlreadyLoaded  = 'PostgreSQL interface already initialized from library %s.';
+
+var
+  RefCount : integer;
+  LoadedLibrary : String;
 
 Procedure InitialisePostgres3(libpath:string=pqlib);
 
@@ -230,9 +236,10 @@ begin
     if Postgres3LibraryHandle = nilhandle then
       begin
       RefCount := 0;
-      Raise EInOutError.Create('Can not load PosgreSQL client. Is it installed? ('+libpath+')');
+      Raise EInOutError.CreateFmt(SErrLoadFailed,[libpath]);
       end;
 
+    LoadedLibrary:=libpath;
     pointer(PQconnectStart) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectStart');
     pointer(PQconnectPoll) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectPoll');
     pointer(PQconnectdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectdb');
@@ -336,7 +343,13 @@ begin
     pointer(PQenv2encoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding');
 
     InitialiseDllist;
-    end;
+    end
+  else
+    if (libpath<>pqlib) and (LoadedLibrary<>libpath) then
+      begin
+      Dec(RefCount);
+      Raise EInOUtError.CreateFmt(SErrAlreadyLoaded,[LoadedLibrary]);
+      end;
 end;
 
 Procedure ReleasePostgres3;