From 520d51cf7ca8f4af49b9b1e2c22960d7b4877edf Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 26 Oct 2012 17:10:35 +0000 Subject: [PATCH] * Patch from Ludo brands to add IsLibraryLoaded sqlite/src/sqlite3.inc git-svn-id: trunk@22852 - --- packages/mysql/src/mysql.inc | 10 +++++----- packages/postgres/src/postgres3.pp | 2 ++ packages/postgres/src/postgres3dyn.pp | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/mysql/src/mysql.inc b/packages/mysql/src/mysql.inc index 28198893d2..63601b65af 100644 --- a/packages/mysql/src/mysql.inc +++ b/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; diff --git a/packages/postgres/src/postgres3.pp b/packages/postgres/src/postgres3.pp index 8fc927b6c1..dd49267d0f 100644 --- a/packages/postgres/src/postgres3.pp +++ b/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'; diff --git a/packages/postgres/src/postgres3dyn.pp b/packages/postgres/src/postgres3dyn.pp index 7ba19c1104..af947c50c6 100644 --- a/packages/postgres/src/postgres3dyn.pp +++ b/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;