commit 80afc3dfe2f73cc6f496d5ab41a0a073b4706026
Author:     Pavel Raiskup <praiskup@redhat.com>
AuthorDate: Tue Dec 10 09:35:18 2013 +0100
Commit:     Pavel Raiskup <praiskup@redhat.com>
CommitDate: Tue Dec 10 09:35:18 2013 +0100

    loadlib: better check for PQconnectdbParams
    
    Cleanup things a little: Don't statically link the
    PQconnectdbParams if it is not system available.  Drop the libtool
    requirement as it is not needed now.

diff --git a/configure.ac b/configure.ac
index 14450de..e844ca1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -269,7 +269,13 @@ fi
 
 if test "$with_libpq" != no; then
   AC_CHECK_LIB(pq, PQconnectdb, [],
-	      [AC_MSG_ERROR([libpq library not found])])
+        [AC_MSG_ERROR([libpq library not found])])
+  if test "x$ac_cv_lib_pq_PQconnectdb" = "xyes"; then
+    AC_CHECK_LIB(pq, PQconnectdbParams,
+        [AC_DEFINE(HAVE_PQCONNECTDBPARAMS, 1,
+                   [Define to 1 if you have PQconnectdbParams])])
+
+  fi
 fi
 
 if test "$enable_openssl" = yes; then
@@ -363,9 +369,5 @@ AC_MSG_RESULT(yes)],
               [AC_MSG_RESULT(no)])
 fi
 
-# 8. Libltdl
-AC_CHECK_LIB(ltdl, lt_dlopen)
-
-
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
diff --git a/loadlib.c b/loadlib.c
index b88eb71..b0d6f9c 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -331,13 +331,13 @@ BOOL	connect_with_param_available(void)
 	{
 #if defined(_MSC_DELAY_LOAD_IMPORT)
 		__try {
-#if (_MSC_VER < 1300)
+# if (_MSC_VER < 1300)
 			__pfnDliFailureHook = DliErrorHook;
 			__pfnDliNotifyHook = DliErrorHook;
-#else
+# else
 			__pfnDliFailureHook2 = DliErrorHook;
 			__pfnDliNotifyHook2 = DliErrorHook;
-#endif /* _MSC_VER */
+# endif /* _MSC_VER */
 			PQescapeLiteral(NULL, NULL, 0);
 		}
 		__except (filter_env2encoding(GetExceptionCode())) {
@@ -348,17 +348,11 @@ inolog("connect_withparam_available is set to false\n");
 			connect_withparam_available = 0;
 }
 #else
-#ifdef HAVE_LIBLTDL
-		lt_dlhandle dlhandle = lt_dlopenext(libpqlib);
-
+		/* non MSC platforms */
+		connect_withparam_available = 0;
+# ifdef HAVE_PQCONNECTDBPARAMS
 		connect_withparam_available = 1;
-		if (NULL != dlhandle)
-		{
-			if (NULL == lt_dlsym(dlhandle, checkproc1))
-				connect_withparam_available = 0;
-			lt_dlclose(dlhandle);
-		}
-#endif /* HAVE_LIBLTDL */
+# endif /* HAVE_PQCONNECTDBPARAMS */
 #endif /* _MSC_DELAY_LOAD_IMPORT */
 	}
 
@@ -436,7 +430,9 @@ inolog("calling PQconnectdbParams\n");
 		*/
 	}
 #else
+# ifdef HAVE_PQCONNECTDBPARAMS
 	pqconn = PQconnectdbParams(opts, vals, 0);
+# endif
 #endif /* _MSC_DELAY_LOAD_IMPORT */
 	return pqconn;
 }
